/* ============================================================
   SAB Farm Finance Portal — Custom Stylesheet
   Bootstrap 5 base + custom layout
   ============================================================ */

/* ---- Font -------------------------------------------------- */
:root {
  --font-base: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 0px;
  --topbar-height: 60px;
  --color-primary: #198754;
  --color-primary-dark: #145c38;
  --color-sidebar-bg: #1a2e1e;
  --color-sidebar-text: rgba(255,255,255,0.85);
  --color-sidebar-hover: rgba(255,255,255,0.1);
  --color-sidebar-active: rgba(255,255,255,0.15);
  --color-sidebar-section: rgba(255,255,255,0.35);
}

* { font-family: var(--font-base); }
body { background: #f5f7f5; color: #1a2e1e; }

/* ---- Layout ------------------------------------------------ */
.sab-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ----------------------------------------------- */
.sab-sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--color-sidebar-bg);
  color: var(--color-sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.3s ease;
  overflow-x: hidden;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1030;
}

.sab-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  transition: margin-left 0.3s ease;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.sidebar-collapsed .sab-sidebar {
  width: 0;
}
.sidebar-collapsed .sab-content {
  margin-left: 0;
}

/* Brand */
.sab-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sab-brand-icon {
  font-size: 1.8rem;
  flex-shrink: 0;
}
.sab-brand-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
  white-space: nowrap;
  line-height: 1.2;
}
.sab-brand-sub {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.45);
  white-space: nowrap;
}

/* Nav */
.sab-nav {
  list-style: none;
  padding: 8px 0;
  margin: 0;
  flex: 1;
  overflow-y: auto;
}
.sab-nav-section {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-sidebar-section);
  padding: 12px 20px 4px;
}
.sab-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  color: var(--color-sidebar-text);
  text-decoration: none;
  border-radius: 0;
  font-size: 0.875rem;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.sab-nav-link:hover {
  background: var(--color-sidebar-hover);
  color: #fff;
}
.sab-nav-link.active {
  background: var(--color-sidebar-active);
  color: #fff;
  font-weight: 600;
  border-left: 3px solid #4ade80;
}
.sab-nav-link i {
  font-size: 1rem;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

/* ---- Top Bar ----------------------------------------------- */
.sab-topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e8ede9;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.sab-topbar-breadcrumb {
  font-size: 0.9rem;
  color: #6c757d;
}
.sab-user-btn {
  background: transparent;
  border: 1px solid #dee2e6;
  display: flex;
  align-items: center;
  font-size: 0.875rem;
  border-radius: 8px;
  padding: 5px 10px;
}
.sab-user-btn:hover { background: #f8f9fa; }

/* ---- Avatar ----------------------------------------------- */
.sab-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.sab-avatar-lg {
  width: 72px;
  height: 72px;
  font-size: 1.4rem;
}

/* ---- Bell -------------------------------------------------- */
.sab-bell { padding: 4px 8px; border-radius: 6px; }
.sab-bell:hover { background: #f0f0f0; }

/* ---- Messages --------------------------------------------- */
.sab-messages { flex-shrink: 0; }

/* ---- Main content ----------------------------------------- */
.sab-main {
  flex: 1;
  padding: 1.5rem;
  max-width: 1400px;
  width: 100%;
}
.sab-footer {
  text-align: center;
  padding: 12px;
  border-top: 1px solid #e8ede9;
  background: #fff;
}

/* ---- KPI Cards -------------------------------------------- */
.sab-kpi-card {
  background: #fff;
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  height: 100%;
  transition: transform 0.15s, box-shadow 0.15s;
}
.sab-kpi-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.sab-kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.sab-kpi-label {
  font-size: 0.75rem;
  color: #6c757d;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.sab-kpi-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: #1a2e1e;
  line-height: 1.2;
}
.sab-kpi-link {
  font-size: 0.78rem;
  color: var(--color-primary);
  text-decoration: none;
}
.sab-kpi-link:hover { text-decoration: underline; }

/* ---- Cards ----------------------------------------------- */
.card { border-radius: 12px !important; }
.card-header {
  padding: 1rem 1.25rem 0.75rem;
  font-size: 0.875rem;
}

/* ---- Tables ---------------------------------------------- */
.table { font-size: 0.875rem; }
.table th {
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6c757d;
}

/* ---- Badges ---------------------------------------------- */
.badge { font-weight: 500; font-size: 0.72rem; padding: 0.3em 0.6em; border-radius: 6px; }

/* ---- Forms ----------------------------------------------- */
.form-control, .form-select {
  border-radius: 8px;
  font-size: 0.875rem;
  border-color: #dee2e6;
}
.form-control:focus, .form-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 0.2rem rgba(25,135,84,0.15);
}
.btn { border-radius: 8px; font-weight: 500; font-size: 0.875rem; }
.btn-primary { background: var(--color-primary); border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-dark); border-color: var(--color-primary-dark); }

/* ---- Login page ------------------------------------------ */
.sab-login-card {
  background: #fff;
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.sab-login-icon {
  font-size: 3rem;
  display: block;
}

/* ---- Status timeline (claims) ---------------------------- */
.sab-timeline {
  position: relative;
  padding-left: 24px;
}
.sab-timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0; bottom: 0;
  width: 2px;
  background: #dee2e6;
}
.sab-timeline-item {
  position: relative;
  margin-bottom: 1rem;
}
.sab-timeline-dot {
  position: absolute;
  left: -20px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary);
}

/* ---- Filters sidebar form --------------------------------- */
.sab-filter-card {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  font-size: 0.85rem;
}

/* ---- Responsive ------------------------------------------ */

/* Tablet: sidebar slightly narrower */
@media (max-width: 991px) {
  :root { --sidebar-width: 220px; }
}

/* Mobile: sidebar hidden by default, slides in as overlay */
@media (max-width: 767px) {
  .sab-sidebar {
    width: var(--sidebar-width) !important;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 1050;
  }
  .sab-content {
    margin-left: 0 !important;
  }
  /* When open on mobile */
  .sab-wrapper.mobile-sidebar-open .sab-sidebar {
    transform: translateX(0);
  }
  /* Dark overlay behind sidebar */
  .sab-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1040;
  }
  .sab-wrapper.mobile-sidebar-open .sab-overlay {
    display: block;
  }
  /* Stack KPI cards on mobile */
  .sab-kpi-card { margin-bottom: 0.75rem; }
  /* Reduce main padding */
  .sab-main { padding: 1rem; }
  /* Topbar compact */
  .sab-topbar { padding: 0 0.75rem; }
  .sab-topbar-breadcrumb { font-size: 0.8rem; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
