/* ── CBIMF Custom Styles ─────────────────────────────────────── */

:root {
  --sidebar-width: 240px;
  --sidebar-bg: #123c2b;
  --sidebar-hover: rgba(255,255,255,.08);
  --sidebar-active: rgba(255,255,255,.15);
  --brand-color: #1b5e3b;
  --brand-deep: #0b2a1e;
  --accent-yellow: #f2c94c;
  --page-surface: #f5f7f1;
  --line-color: #dbe4d7;
  --header-height: 112px;
  --mobile-nav-width: 280px;

  --bs-primary: #1b5e3b;
  --bs-primary-rgb: 27, 94, 59;
  --bs-success: #2f7d4a;
  --bs-success-rgb: 47, 125, 74;
  --bs-warning: #f2c94c;
  --bs-warning-rgb: 242, 201, 76;
  --bs-body-bg: #f5f7f1;
  --bs-body-color: #20352a;
}

/* ── Layout ──────────────────────────────────────────────────── */
body {
  background: var(--page-surface);
  font-size: .925rem;
  color: #20352a;
}

.page-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  width: 100%;
  background: var(--brand-color);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 1050;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .08);
  overflow: visible !important;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .65rem 1rem;
  background: var(--brand-deep);
  flex-wrap: wrap;
}

.header-brand-wrap {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}

.brand-link {
  color: #fff;
  text-decoration: none;
  font-size: 1.05rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
}

.brand-link i {
  font-size: 1.2rem;
}

.branch-label {
  font-size: .9rem;
  opacity: .85;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.header-user {
  font-size: .9rem;
  font-weight: 600;
  color: rgba(255,255,255,.95);
}

.header-action-link {
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .5rem .8rem;
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  transition: background .2s ease;
  font-size: .85rem;
}

.header-action-link:hover {
  background: rgba(255,255,255,.2);
}

.main-nav-wrapper {
  overflow-x: auto;
  overflow-y: visible;
  background: #174a31;
  border-top: 1px solid rgba(255,255,255,.12);
  border-bottom: 1px solid rgba(255,255,255,.12);
  position: relative;
  z-index: 1051;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0;
  white-space: nowrap;
}

/* Mobile menu toggle */
@media (max-width: 767.98px) {
  #mobileNavToggle {
    display: block !important;
  }
}

.main-nav .nav-link,
.main-nav .dropdown-toggle {
  color: #fff;
  text-decoration: none;
  padding: .55rem 1rem;
  border-radius: 0;
  font-size: .9rem;
  font-weight: 500;
  transition: background .2s ease, color .2s ease;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  gap: .4rem;
}

.main-nav .nav-link:hover,
.main-nav .dropdown-toggle:hover {
  background: rgba(0,0,0,.2);
  color: #fff;
}

.main-nav .nav-link.active,
.main-nav .dropdown-toggle.active {
  background: rgba(242, 201, 76, .2);
  box-shadow: inset 0 -3px 0 var(--accent-yellow);
  color: #fff;
}

.main-nav .nav-item.dropdown {
  position: relative;
  display: inline-block;
}

.main-nav .dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 12rem;
  border-radius: 0;
  padding: .25rem 0;
  background: #fff;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  border: 1px solid #e8ecf2;
  display: none;
  z-index: 1055;
}

.main-nav .dropdown-menu.show,
.main-nav .dropdown.show .dropdown-menu {
  display: block;
}

.main-nav .dropdown-item {
  color: #2c5282;
  padding: .6rem 1.25rem;
  font-size: .9rem;
  border: none;
}

.main-nav .dropdown-item:hover {
  background: #f0f4f8;
  color: #2c5282;
}

.main-nav .dropdown-item.active {
  background: #e9eef9;
  color: #2c5282;
  font-weight: 600;
}

.topbar {
  background: #fffef8;
  border-bottom: 1px solid var(--line-color);
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 1030;
}

/* keep existing sidebar styles for legacy templates if needed */
.sidebar {
  display: none;
}

@media (max-width: 1199.98px) {
  .main-nav {
    padding: .4rem .75rem;
  }
}

@media (max-width: 767.98px) {
  .header-top {
    flex-direction: column;
    align-items: flex-start;
  }
  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }
  .main-nav {
    flex-wrap: wrap;
  }
}

/* ── Main content ────────────────────────────────────────────── */
.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid #e8ecf2;
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 1030;
}

.topbar .page-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--brand-deep);
  margin: 0;
}

.content-area {
  padding: 1.5rem;
  flex: 1;
}

/* ── Cards ───────────────────────────────────────────────────── */
.stat-card {
  border: none;
  border-radius: 12px;
  box-shadow: 0 1px 6px rgba(0,0,0,.07);
}

.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.stat-card .stat-value {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1;
}

.stat-card .stat-label {
  font-size: .8rem;
  color: #6c757d;
  margin-top: .2rem;
}

/* ── Tables ──────────────────────────────────────────────────── */
.table th {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #6c757d;
  font-weight: 600;
  border-top: none;
  white-space: nowrap;
}

.table td {
  vertical-align: middle;
  font-size: .875rem;
}

/* ── Cards / panels ──────────────────────────────────────────── */
.card {
  border: 1px solid var(--line-color);
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}

.card-header {
  background: #fffef8;
  border-bottom: 1px solid var(--line-color);
  font-weight: 600;
  padding: .9rem 1.25rem;
}

/* ── Badges ──────────────────────────────────────────────────── */
.badge { font-weight: 500; }

/* ── Login page ──────────────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--brand-deep) 0%, var(--brand-color) 68%, #d8b43f 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 100%;
  max-width: 420px;
}

/* ── Naflak colour chips ─────────────────────────────────────── */
.naflak-teufi  { background: #1b5e3b; }
.naflak-temalu { background: #2f7d4a; }
.naflak-teniu  { background: #d8b43f; color: #20352a; }
.naflak-tefeke { background: #8fae45; }

/* ── Green and yellow theme ─────────────────────────────────── */
.btn-primary,
.bg-primary { background-color: var(--brand-color) !important; border-color: var(--brand-color) !important; }
.btn-primary:hover,
.btn-primary:focus { background-color: var(--brand-deep) !important; border-color: var(--brand-deep) !important; }
.btn-warning,
.bg-warning { background-color: var(--accent-yellow) !important; border-color: var(--accent-yellow) !important; color: #20352a !important; }
.text-primary { color: var(--brand-color) !important; }
.text-warning { color: #8a6a00 !important; }
.form-control:focus,
.form-select:focus { border-color: var(--accent-yellow); box-shadow: 0 0 0 .2rem rgba(242, 201, 76, .25); }
.table thead th { background: #edf3e8; color: var(--brand-deep); }
.stat-card { border-top: 3px solid var(--accent-yellow); }

/* ── Sidebar backdrop ────────────────────────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1044;
  transition: opacity .25s ease;
}
.sidebar-backdrop.show {
  display: block;
}

/* ── Responsive mobile menu ──────────────────────────────────── */
@media (min-width: 992px) {
  #mobileNavToggle {
    display: none !important;
  }
  .main-nav-wrapper {
    position: relative !important;
    left: 0 !important;
    top: 0 !important;
    width: auto !important;
    height: auto !important;
    padding: 0 !important;
    overflow-y: visible !important;
    z-index: 1051;
  }
  .sidebar-backdrop {
    display: none !important;
  }
}

@media (max-width: 991.98px) {
  .header-top {
    gap: .5rem;
  }
  .content-area {
    padding: 1rem;
  }
}
