/* ═══════════════════════════════════════════════════════════════
   Union Operations System — Main Stylesheet
   Design: Professional green theme inspired by Fairtrade Africa
   ═══════════════════════════════════════════════════════════════ */

:root {
  --primary:       #1a472a;
  --primary-light: #2d6a4f;
  --primary-dark:  #0d2b18;
  --accent:        #52b788;
  --accent-light:  #74c69d;
  --gold:          #d4a017;
  --text:          #212529;
  --text-muted:    #6c757d;
  --bg:            #f4f6f4;
  --surface:       #ffffff;
  --border:        #dee2e6;
  --sidebar-w:     260px;
  --topbar-h:      64px;
  --radius:        10px;
  --shadow:        0 2px 8px rgba(0,0,0,.08);
  --shadow-md:     0 4px 20px rgba(0,0,0,.12);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  font-size: 14px;
}

/* ── Scrollbar ────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #aeb7b0; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #7f8f84; background-clip: padding-box; }

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--primary);
  display: flex;
  flex-direction: column;
  z-index: 1050;
  transition: transform .25s ease;
  overflow-y: auto;
  scrollbar-width: auto;
  scrollbar-color: rgba(116,198,157,.75) rgba(255,255,255,.08);
}

.sidebar::-webkit-scrollbar { width: 14px; }
.sidebar::-webkit-scrollbar-track { background: rgba(255,255,255,.08); }
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(116,198,157,.82);
  border: 3px solid var(--primary);
  border-radius: 14px;
}
.sidebar::-webkit-scrollbar-thumb:hover { background: var(--accent-light); }

.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex; align-items: center; justify-content: space-between;
}

.sidebar-logo { display: flex; align-items: center; gap: 12px; }

.logo-icon {
  width: 44px; height: 44px; border-radius: 50%;
  background: #fff; display: grid; place-items: center;
  padding: 3px; box-shadow: 0 6px 16px rgba(0,0,0,.18);
  overflow: hidden; flex-shrink: 0;
}

.logo-icon img {
  width: 100%; height: 100%; object-fit: contain; display: block;
}

.logo-title { color: #fff; font-weight: 700; font-size: 15px; line-height: 1.2; }
.logo-sub   { color: rgba(255,255,255,.6); font-size: 11px; }

.sidebar-close {
  background: none; border: none; color: rgba(255,255,255,.6);
  font-size: 18px; cursor: pointer; padding: 4px;
}

.sidebar-user {
  padding: 16px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.user-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--accent); color: var(--primary);
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px; flex-shrink: 0;
}

.user-name { color: #fff; font-size: 13px; font-weight: 600; }
.user-role { color: rgba(255,255,255,.55); font-size: 11px; }

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex; flex-direction: column; gap: 2px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  border-radius: 8px;
  font-size: 13.5px;
  transition: all .2s;
  cursor: pointer;
}

.nav-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-item.active {
  position: relative;
  background: linear-gradient(90deg, var(--accent-light), var(--accent));
  color: var(--primary);
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(0,0,0,.24);
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 9px;
  bottom: 9px;
  width: 4px;
  border-radius: 8px;
  background: #fff;
}
.nav-item.active .nav-icon { color: var(--primary-dark); }
.nav-item.active span::after {
  content: "Active";
  margin-left: 8px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255,255,255,.8);
  color: var(--primary-dark);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .03em;
  vertical-align: middle;
}
.nav-icon { width: 18px; text-align: center; font-size: 14px; flex-shrink: 0; }
.nav-divider { height: 1px; background: rgba(255,255,255,.1); margin: 8px 4px; }

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1040;
}

/* ── Main Layout ──────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex; flex-direction: column;
  transition: margin-left .25s;
}

/* ── Top Navbar ───────────────────────────────────────────────── */
.top-navbar {
  position: sticky; top: 0;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  z-index: 1000;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.navbar-left { display: flex; align-items: center; gap: 16px; }
.navbar-right { display: flex; align-items: center; gap: 12px; }

.active-module-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(82,183,136,.16);
  border: 1px solid rgba(26,71,42,.14);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(26,71,42,.08);
}
.active-module-chip:hover { color: var(--primary-dark); background: rgba(82,183,136,.24); }
.active-module-chip strong {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.sidebar-toggle {
  background: none; border: none; font-size: 18px;
  color: var(--text-muted); cursor: pointer; padding: 6px;
  border-radius: 6px; display: none;
  transition: color .2s;
}
.sidebar-toggle:hover { color: var(--primary); }

.breadcrumb { font-size: 13px; }
.breadcrumb-item a { color: var(--primary); text-decoration: none; }

.navbar-union-badge {
  font-size: 12px; padding: 4px 10px; border-radius: 20px;
  background: rgba(26,71,42,.1); color: var(--primary);
  font-weight: 500; white-space: nowrap;
}
.badge-global { background: rgba(212,160,23,.1); color: var(--gold); }

.navbar-user-btn {
  background: none; border: none;
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 500; color: var(--text);
  cursor: pointer; padding: 6px 8px; border-radius: 6px;
}
.navbar-user-btn:hover { background: var(--bg); }
.navbar-user-btn::after { display: none; }

.user-avatar-sm {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
}

/* ── Page Content ─────────────────────────────────────────────── */
.page-content { padding: 24px; flex: 1; }

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}

.page-title { font-size: 22px; font-weight: 700; color: var(--primary); margin: 0; }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ── Cards ────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: transparent;
  border-radius: var(--radius) var(--radius) 0 0;
}

.card-title { font-size: 15px; font-weight: 600; color: var(--primary); margin: 0; }
.card-body  { padding: 20px; }

/* ── Stat Cards ───────────────────────────────────────────────── */
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
  position: relative; overflow: hidden;
  transition: transform .2s, box-shadow .2s;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card::after {
  content: '';
  position: absolute; top: 0; left: 0;
  width: 4px; height: 100%;
  background: var(--accent);
}
.stat-card.danger::after  { background: #dc3545; }
.stat-card.warning::after { background: #ffc107; }
.stat-card.info::after    { background: #0dcaf0; }
.stat-card.gold::after    { background: var(--gold); }

.stat-icon {
  width: 52px; height: 52px; border-radius: 12px;
  background: rgba(26,71,42,.1); color: var(--primary);
  display: grid; place-items: center; font-size: 22px; flex-shrink: 0;
}
.stat-card.danger  .stat-icon { background: rgba(220,53,69,.1);  color: #dc3545; }
.stat-card.warning .stat-icon { background: rgba(255,193,7,.15); color: #b8860b; }
.stat-card.info    .stat-icon { background: rgba(13,202,240,.1); color: #0dcaf0; }
.stat-card.gold    .stat-icon { background: rgba(212,160,23,.1); color: var(--gold); }

.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Tables ───────────────────────────────────────────────────── */
.table-responsive { border-radius: 0 0 var(--radius) var(--radius); }

.table { margin: 0; font-size: 13.5px; }
.table thead th {
  background: #f8faf8;
  color: var(--primary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 11px 16px; vertical-align: middle; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: #f8faf8; }

/* ── Badges ───────────────────────────────────────────────────── */
.badge { font-size: 11px; font-weight: 500; padding: 4px 8px; border-radius: 6px; }
.badge-success   { background: #d4edda; color: #155724; }
.badge-warning   { background: #fff3cd; color: #856404; }
.badge-danger    { background: #f8d7da; color: #721c24; }
.badge-info      { background: #cff4fc; color: #055160; }
.badge-secondary { background: #e2e3e5; color: #383d41; }
.badge-primary   { background: rgba(26,71,42,.15); color: var(--primary); }
.badge-dark      { background: #d3d3d4; color: #1b1e21; }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn-primary {
  background: var(--primary); border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-light); border-color: var(--primary-light); }

.btn-success { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-success:hover { background: var(--accent-light); }

.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }

/* ── Forms ────────────────────────────────────────────────────── */
.form-label { font-size: 13px; font-weight: 500; margin-bottom: 4px; }
.form-control, .form-select {
  font-size: 13.5px; border-radius: 7px;
  border-color: var(--border);
  transition: border-color .2s, box-shadow .2s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(82,183,136,.2);
}
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(220,53,69,.15); }

/* ── Filters Bar ──────────────────────────────────────────────── */
.filters-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.module-hero {
  border-radius: 8px;
  padding: 26px;
  margin-bottom: 22px;
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: 0 14px 34px rgba(13,43,24,.14);
  background: linear-gradient(135deg, #173b4a, #1a472a 58%, #52b788);
}
.module-hero::after {
  content: '';
  position: absolute;
  width: 220px;
  height: 220px;
  right: -80px;
  bottom: -90px;
  border: 34px solid rgba(255,255,255,.10);
  border-radius: 50%;
}
.module-hero .hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.14);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.module-hero h1 {
  font-size: 28px;
  font-weight: 800;
  margin: 14px 0 8px;
  letter-spacing: 0;
}
.module-hero p {
  max-width: 760px;
  color: rgba(255,255,255,.84);
  margin-bottom: 0;
}
.module-hero .hero-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}
.module-hero .hero-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
  position: relative;
  z-index: 1;
}
.module-hero .hero-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border-radius: 8px;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.18);
  font-weight: 700;
}
.module-hero .hero-chip small {
  color: rgba(255,255,255,.72);
  font-weight: 600;
}
.hero-hr { background: linear-gradient(135deg, #19324a, #1a472a 62%, #74c69d); }
.hero-clmrs { background: linear-gradient(135deg, #5a3c18, #1a472a 58%, #f0c35a); }
.hero-governance { background: linear-gradient(135deg, #202f4f, #1a472a 58%, #60c2d8); }
.hero-premium { background: linear-gradient(135deg, #493817, #1a472a 55%, #d4a017); }
.hero-credit { background: linear-gradient(135deg, #184236, #2d6a4f 55%, #79c267); }
.hero-finance { background: linear-gradient(135deg, #1c2d3f, #1a472a 58%, #4aa3df); }
.hero-production {
  background:
    linear-gradient(90deg, rgba(25,35,20,.94) 0%, rgba(36,43,20,.84) 48%, rgba(49,37,18,.64) 100%),
    url('../img/cocoa-production-hero.jpg') center 48% / cover no-repeat;
}
.hero-contract { background: linear-gradient(135deg, #203346, #1a472a 58%, #52b788); }
@media (max-width: 575.98px) {
  .module-hero { padding: 22px; }
  .module-hero h1 { font-size: 23px; }
}

/* ── Alerts ───────────────────────────────────────────────────── */
.alert { border-radius: var(--radius); font-size: 13.5px; border: none; }
.alert-success { background: #d4edda; color: #155724; }
.alert-danger   { background: #f8d7da; color: #721c24; }
.alert-warning  { background: #fff3cd; color: #856404; }
.alert-info     { background: #cff4fc; color: #055160; }

/* ── Login Page ───────────────────────────────────────────────── */
.login-bg {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.login-logo {
  text-align: center; margin-bottom: 28px;
}
.login-logo .logo-circle {
  width: 82px; height: 82px; border-radius: 50%;
  background: #fff; border: 1px solid rgba(26,71,42,.12);
  display: inline-grid; place-items: center; padding: 5px;
  margin-bottom: 12px;
  box-shadow: 0 14px 34px rgba(26,71,42,.16);
}
.login-logo .logo-circle img { width: 100%; height: 100%; object-fit: contain; display: block; }
.login-logo h2 { font-size: 20px; font-weight: 700; color: var(--primary); margin: 0; }
.login-logo p  { font-size: 13px; color: var(--text-muted); margin: 4px 0 0; }

/* ── Dashboard Charts ─────────────────────────────────────────── */
.chart-container { position: relative; height: 260px; }

/* ── Overdue indicator ────────────────────────────────────────── */
.overdue-row { background: rgba(220,53,69,.04) !important; }

/* ── Priority colors ──────────────────────────────────────────── */
.priority-critical { border-left: 3px solid #dc3545; }
.priority-high     { border-left: 3px solid #fd7e14; }
.priority-medium   { border-left: 3px solid #ffc107; }
.priority-low      { border-left: 3px solid #6c757d; }

/* ── Empty State ──────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; opacity: .4; }
.empty-state h5 { font-size: 16px; margin-bottom: 6px; }
.empty-state p  { font-size: 13px; }

/* ── Action Buttons ───────────────────────────────────────────── */
.action-btns { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.btn-icon { width: 30px; height: 30px; padding: 0; display: inline-grid; place-items: center; border-radius: 6px; font-size: 13px; }

/* ── Detail View ──────────────────────────────────────────────── */
.detail-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); font-weight: 600; margin-bottom: 2px; }
.detail-value { font-size: 14px; color: var(--text); }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,.3);
  }
  .sidebar-overlay.show { display: block; }
  .main-content { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .page-content { padding: 16px; }
  .active-module-chip { max-width: 44vw; }
  .active-module-chip span { overflow: hidden; text-overflow: ellipsis; }
}

@media (max-width: 575.98px) {
  .page-header { flex-direction: column; }
  .stat-value { font-size: 22px; }
  .active-module-chip strong { display: none; }
}

/* ── Animations ───────────────────────────────────────────────── */
@keyframes fadeIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }
.page-content > * { animation: fadeIn .3s ease; }

/* ── Print ────────────────────────────────────────────────────── */
@media print {
  .sidebar, .top-navbar, .btn, .filters-bar { display: none !important; }
  .main-content { margin-left: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}
