/* ========================================================
   COOPERATIVE MANAGEMENT SYSTEM — Shared Styles
   ======================================================== */

:root {
  --coop-primary:   #1a3a5c;
  --coop-secondary: #2563a8;
  --coop-accent:    #f0a500;
  --coop-success:   #198754;
  --coop-danger:    #dc3545;
  --coop-warning:   #ffc107;
  --coop-info:      #0dcaf0;
  --coop-light-bg:  #f4f7fb;
  --coop-sidebar-w: 260px;
  --coop-header-h:  64px;
  --shadow-card:    0 2px 12px rgba(26,58,92,0.08);
  --shadow-hover:   0 6px 24px rgba(26,58,92,0.15);
  --radius-card:    12px;
  --radius-badge:   6px;
}

/* ── Base ── */
body {
  font-family: 'Sarabun', 'Noto Sans Thai', sans-serif;
  background: var(--coop-light-bg);
  color: #1e2a3a;
  font-size: 15px;
}
[x-cloak] { display: none !important; }

/* ── Sidebar ── */
.sidebar {
  width: var(--coop-sidebar-w);
  height: 100vh;
  background: var(--coop-primary);
  position: fixed;
  top: 0; left: 0;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: transform .3s ease;
  box-shadow: 2px 0 16px rgba(0,0,0,.18);
}
.sidebar-brand {
  flex-shrink: 0;
  padding: 20px 24px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-brand .brand-logo {
  width: 40px; height: 40px;
  background: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.sidebar-brand .brand-logo img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  opacity: .96;
}
.sidebar-brand .brand-text { color: #fff; font-weight: 700; font-size: .95rem; line-height: 1.3; }
.sidebar-brand .brand-sub  { color: rgba(255,255,255,.55); font-size: .72rem; }

.sidebar-nav {
  padding: 12px 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
}
.sidebar-nav::-webkit-scrollbar {
  width: 5px;
}
.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 4px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.38);
}
.sidebar-nav-pending {
  min-height: calc(100vh - 170px);
}
.sidebar-nav-pending::before {
  content: '';
  display: block;
  height: calc(100vh - 220px);
  margin: 12px 22px;
  border-radius: 8px;
  background:
    linear-gradient(rgba(255,255,255,.18) 0 0) 0 0 / 56% 10px no-repeat,
    linear-gradient(rgba(255,255,255,.12) 0 0) 0 34px / 86% 12px no-repeat,
    linear-gradient(rgba(255,255,255,.12) 0 0) 0 66px / 78% 12px no-repeat,
    linear-gradient(rgba(255,255,255,.12) 0 0) 0 98px / 90% 12px no-repeat,
    linear-gradient(rgba(255,255,255,.18) 0 0) 0 150px / 40% 10px no-repeat,
    linear-gradient(rgba(255,255,255,.12) 0 0) 0 184px / 82% 12px no-repeat,
    linear-gradient(rgba(255,255,255,.12) 0 0) 0 216px / 72% 12px no-repeat;
}
.sidebar-section-label {
  color: rgba(255,255,255,.4);
  font-size: .68rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  padding: 14px 22px 6px;
}
.sidebar-nav .nav-link {
  color: rgba(255,255,255,.75);
  padding: 9px 22px;
  border-radius: 0;
  display: flex; align-items: center; gap: 10px;
  font-size: .88rem;
  transition: background .18s, color .18s;
  border-left: 3px solid transparent;
}
.sidebar-nav .nav-link:hover   { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav .nav-link.active  {
  background: rgba(37,99,168,.4);
  color: #fff; font-weight: 600;
  border-left-color: var(--coop-accent);
}
.sidebar-nav .nav-link i { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-footer {
  flex-shrink: 0;
  padding: 16px 22px;
  border-top: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.55); font-size: .8rem;
}

/* ── Top navbar ── */
.topbar {
  height: var(--coop-header-h);
  background: #fff;
  border-bottom: 1px solid #e3eaf3;
  display: flex; align-items: center;
  padding: 0 24px;
  position: fixed;
  top: 0; left: var(--coop-sidebar-w); right: 0;
  z-index: 1030;
  box-shadow: 0 1px 6px rgba(26,58,92,.06);
}
.topbar .page-title { font-size: 1.05rem; font-weight: 700; color: var(--coop-primary); }
.topbar .breadcrumb  { margin: 0; font-size: .8rem; }
.topbar .breadcrumb-item + .breadcrumb-item::before { color: #aab4c4; }

.topbar-user-info { line-height: 1.25; }
.topbar-user-name { font-size: .85rem; font-weight: 600; color: var(--coop-primary); }
.topbar-user-role { font-size: .72rem; color: #7a8fa6; }
.topbar-user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--coop-primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0;
}

/* ── Auth buttons ── */
.btn-auth-login {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 14px;
  background: var(--coop-primary);
  color: #fff !important;
  border-radius: 8px;
  font-size: .85rem; font-weight: 600;
  text-decoration: none;
  transition: background .18s;
}
.btn-auth-login:hover { background: var(--coop-secondary); color: #fff !important; }

.btn-auth-logout {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border: 1.5px solid #dce8f5;
  border-radius: 8px;
  background: #fff;
  color: #7a8fa6;
  cursor: pointer;
  transition: all .18s;
  flex-shrink: 0;
}
.btn-auth-logout:hover {
  background: #fde8e8;
  border-color: #f5c2c7;
  color: var(--coop-danger);
}

.sidebar-logout {
  color: rgba(255,255,255,.45);
  font-size: .78rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: color .15s;
}
.sidebar-logout:hover { color: rgba(255,255,255,.75); }

/* ── Main content area ── */
.main-content {
  margin-left: var(--coop-sidebar-w);
  margin-top: var(--coop-header-h);
  padding: 28px 28px 40px;
  min-height: calc(100vh - var(--coop-header-h));
}

/* ── Summary Cards ── */
.summary-card {
  background: #fff;
  border-radius: var(--radius-card);
  padding: 22px 24px;
  box-shadow: var(--shadow-card);
  border: none;
  display: flex; align-items: center; gap: 18px;
  transition: box-shadow .2s, transform .2s;
  height: 100%;
  min-height: 112px;
}
.summary-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.summary-card .sc-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
}
.summary-card .sc-label { font-size: .78rem; color: #7a8fa6; font-weight: 500; margin-bottom: 2px; }
.summary-card .sc-value { font-size: 1.6rem; font-weight: 700; color: var(--coop-primary); line-height: 1.1; min-height: 1.8rem; min-width: 7.5ch; }
.summary-card .sc-sub   { font-size: .75rem; color: #a0b0c4; margin-top: 2px; }

/* ── Data Card (table wrapper) ── */
.data-card {
  background: #fff;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.data-card .card-header-custom {
  padding: 18px 24px 14px;
  border-bottom: 1px solid #eaf0f8;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
}
.data-card .card-header-custom .card-title {
  font-size: 1rem; font-weight: 700; color: var(--coop-primary); margin: 0;
}

/* ── Filter bar ── */
.filter-bar { padding: 14px 24px; background: #f8fafd; border-bottom: 1px solid #eaf0f8; }
.filter-bar .form-control, .filter-bar .form-select {
  border: 1.5px solid #d0dcea; font-size: .88rem;
}
.filter-bar .form-control:focus, .filter-bar .form-select:focus {
  border-color: var(--coop-secondary); box-shadow: 0 0 0 3px rgba(37,99,168,.12);
}

/* ── Table ── */
.coop-table { width: 100%; margin: 0; }
.coop-table thead th {
  background: #f0f5fb;
  color: #4a6278; font-size: .78rem;
  font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase;
  padding: 11px 16px;
  border-bottom: 2px solid #dce8f5;
  white-space: nowrap;
}
.coop-table tbody td {
  padding: 12px 16px;
  font-size: .88rem;
  vertical-align: middle;
  border-bottom: 1px solid #f0f4fa;
  color: #2c3e50;
}
.coop-table tbody tr:last-child td { border-bottom: none; }
.coop-table tbody tr:hover td { background: #f7faff; }
.coop-table .col-action { width: 120px; text-align: center; }

/* ── Status Badges ── */
.badge-status {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: var(--radius-badge);
  font-size: .76rem; font-weight: 600; white-space: nowrap;
}
.badge-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.badge-pending    { background: #fff8e1; color: #b07d00; }
.badge-review     { background: #e8f0fe; color: #1a56db; }
.badge-approved   { background: #e6f9ef; color: #1a7a45; }
.badge-rejected   { background: #fde8e8; color: #c0392b; }
.badge-active     { background: #e6f9ef; color: #1a7a45; }
.badge-inactive   { background: #f0f0f0; color: #666; }
.badge-disbursed  { background: #e8f4fd; color: #1565c0; }
.badge-closed     { background: #f3e8fd; color: #7b1fa2; }
.badge-overdue    { background: #fde8e8; color: #c0392b; }
.badge-committee  { background: #fff3e0; color: #e65100; }
.badge-draft      { background: #f5f5f5; color: #555; }
.badge-reconciled { background: #e0f7fa; color: #00695c; }

/* ── Action buttons ── */
.btn-action {
  border: none; background: transparent;
  width: 30px; height: 30px;
  border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .95rem; cursor: pointer;
  transition: background .15s, color .15s;
}
.btn-action:hover { background: #eaf0f8; }
.btn-action.view  { color: var(--coop-secondary); }
.btn-action.edit  { color: #f0a500; }
.btn-action.approve { color: var(--coop-success); }
.btn-action.reject  { color: var(--coop-danger); }

/* Primary buttons */
.btn-coop-primary {
  background: var(--coop-primary);
  color: #fff; border: none;
  padding: 8px 20px; border-radius: 8px;
  font-size: .88rem; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .18s, box-shadow .18s;
}
.btn-coop-primary:hover { background: var(--coop-secondary); color: #fff; box-shadow: 0 4px 12px rgba(37,99,168,.3); }

.btn-coop-success {
  background: var(--coop-success); color: #fff; border: none;
  padding: 8px 20px; border-radius: 8px;
  font-size: .88rem; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .18s;
}
.btn-coop-success:hover { background: #146c43; color: #fff; }

.btn-coop-danger {
  background: var(--coop-danger); color: #fff; border: none;
  padding: 8px 20px; border-radius: 8px;
  font-size: .88rem; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .18s;
}
.btn-coop-danger:hover { background: #b02a37; color: #fff; }

/* ── Modal ── */
.modal-content { border: none; border-radius: 14px; box-shadow: 0 16px 64px rgba(26,58,92,.22); }
.modal-header  { background: var(--coop-primary); color: #fff; border-radius: 14px 14px 0 0; padding: 18px 24px; }
.modal-header .modal-title { font-weight: 700; font-size: 1rem; }
.modal-header .btn-close { filter: invert(1) brightness(2); }
.modal-body   { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid #eaf0f8; }
.modal-footer .btn { border-radius: 8px; font-size: .88rem; font-weight: 600; }

/* ── Detail fields in modal ── */
.detail-row { display: flex; padding: 8px 0; border-bottom: 1px solid #f0f4fa; }
.detail-row:last-child { border-bottom: none; }
.detail-label { width: 160px; flex-shrink: 0; font-size: .82rem; color: #7a8fa6; font-weight: 600; }
.detail-value { font-size: .88rem; color: #1e2a3a; flex: 1; }

/* ── Pagination ── */
.pagination .page-link {
  border: 1.5px solid #dce8f5;
  color: var(--coop-secondary);
  font-size: .84rem;
  padding: 6px 12px;
  border-radius: 6px !important;
  margin: 0 2px;
  transition: background .15s;
}
.pagination .page-link:hover     { background: #e8f0fe; color: var(--coop-primary); }
.pagination .page-item.active .page-link { background: var(--coop-primary); border-color: var(--coop-primary); color: #fff; }
.pagination .page-item.disabled .page-link { color: #c0cdd8; border-color: #e8eef5; }

/* ── Utility ── */
.section-title { font-size: 1.15rem; font-weight: 700; color: var(--coop-primary); margin-bottom: 0; }
.text-muted-sm { font-size: .78rem; color: #8a9bb0; }
.loading-overlay {
  position: absolute; inset: 0;
  background: rgba(255,255,255,.7);
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-card);
  z-index: 10;
}
.empty-state { padding: 48px 24px; text-align: center; color: #a0b0c4; }
.empty-state i { font-size: 3rem; margin-bottom: 12px; opacity: .5; }

/* ── Responsive ── */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .topbar { left: 0; }
}

/* ── Custom scrollbar ── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c8d8ea; border-radius: 10px; }

/* ── SweetAlert2 ── */
.swal2-popup {
  font-family: 'Sarabun', sans-serif !important;
  border-radius: 12px !important;
}
.swal2-title { font-weight: 600 !important; }
.swal2-confirm { font-family: 'Sarabun', sans-serif !important; }
.swal2-cancel { font-family: 'Sarabun', sans-serif !important; }
