/* =============================================
   Niger Youth Portal — Main Stylesheet
   Green Government Premium Theme
   ============================================= */

:root {
  --primary:        #198754;
  --primary-dark:   #146c43;
  --primary-light:  #d1e7dd;
  --sidebar-width:  260px;
  --topbar-height:  64px;
  --sidebar-bg:     #0d2318;
  --sidebar-text:   rgba(255,255,255,0.8);
  --sidebar-hover:  rgba(255,255,255,0.08);
  --sidebar-active: rgba(25,135,84,0.3);
  --card-radius:    12px;
  --transition:     all 0.25s ease;
  --shadow-sm:      0 2px 8px rgba(0,0,0,0.07);
  --shadow:         0 4px 20px rgba(0,0,0,0.10);
  --shadow-lg:      0 8px 40px rgba(0,0,0,0.15);
}

[data-bs-theme="dark"] {
  --bs-body-bg:       #0f172a;
  --bs-body-color:    #e2e8f0;
  --bs-card-bg:       #1e293b;
  --bs-border-color:  #334155;
  --shadow-sm:        0 2px 8px rgba(0,0,0,0.3);
  --shadow:           0 4px 20px rgba(0,0,0,0.4);
}

/* =============================================
   Base & Typography
   ============================================= */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  background: var(--bs-body-bg, #f0f4f8);
  color: var(--bs-body-color, #1a2332);
  overflow-x: hidden;
}

/* =============================================
   Layout — Sidebar + Main
   ============================================= */
.app-layout {
  display: flex;
  min-height: 100vh;
}

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

.sidebar.collapsed { width: 70px; }
.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .sidebar-user,
.sidebar.collapsed .sidebar-heading,
.sidebar.collapsed .sidebar-link span { display: none; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex-shrink: 0;
}

.brand-name {
  display: block;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  line-height: 1;
}

.brand-sub {
  display: block;
  font-size: 10px;
  color: rgba(255,255,255,0.5);
  margin-top: 2px;
}

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

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(25,135,84,0.5);
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

.sidebar-nav {
  list-style: none;
  padding: 8px 0;
  margin: 0;
  flex: 1;
}

.sidebar-heading {
  padding: 16px 20px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255,255,255,0.3);
}

.sidebar-item { margin: 2px 8px; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: 8px;
  font-size: 13.5px;
  transition: var(--transition);
}

.sidebar-link i { font-size: 16px; flex-shrink: 0; min-width: 20px; }
.sidebar-link:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-item.active .sidebar-link {
  background: var(--sidebar-active);
  color: #6ee7b7;
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

/* =============================================
   Main Content Area
   ============================================= */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  min-height: 100vh;
}

.main-content.expanded { margin-left: 70px; }

/* Topbar */
.topbar {
  height: var(--topbar-height);
  background: var(--bs-card-bg, #fff);
  border-bottom: 1px solid var(--bs-border-color, #e2e8f0);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: var(--shadow-sm);
}

.page-content {
  padding: 24px;
  flex: 1;
}

/* =============================================
   Cards
   ============================================= */
.card {
  border: 1px solid var(--bs-border-color, #e8edf2);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-sm);
  background: var(--bs-card-bg, #fff);
  transition: var(--transition);
}

.card:hover { box-shadow: var(--shadow); }

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--bs-border-color, #e8edf2);
  padding: 16px 20px;
  font-weight: 600;
}

/* =============================================
   Stats Cards (Dashboard)
   ============================================= */
.stat-card {
  border-radius: var(--card-radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
  border: none;
  overflow: hidden;
  position: relative;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: -20px; right: -20px;
  width: 80px; height: 80px;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
}

.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.stat-icon {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #fff;
  flex-shrink: 0;
}

.stat-info { flex: 1; color: #fff; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; opacity: 0.85; margin-top: 4px; }
.stat-change { font-size: 11px; margin-top: 6px; }

/* =============================================
   Buttons & Forms
   ============================================= */
.btn {
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  padding: 8px 16px;
  transition: var(--transition);
}

.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  cursor: pointer;
}
.btn-icon:hover { background: var(--bs-border-color, #e2e8f0); }

.form-control, .form-select {
  border-radius: 8px;
  border: 1px solid var(--bs-border-color, #d0d8e4);
  font-size: 13.5px;
  padding: 10px 14px;
  transition: var(--transition);
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(25,135,84,0.15);
}

.input-group-text {
  border-radius: 8px 0 0 8px;
  background: var(--bs-border-color, #f0f4f8);
  border-color: var(--bs-border-color, #d0d8e4);
}

/* =============================================
   Tables
   ============================================= */
.table {
  font-size: 13.5px;
  --bs-table-bg: transparent;
}

.table th {
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--bs-secondary-color, #6c757d);
  border-bottom-width: 1px;
  white-space: nowrap;
}

.table td { vertical-align: middle; }

/* =============================================
   Badges & Status
   ============================================= */
.badge { border-radius: 6px; font-weight: 500; font-size: 11px; padding: 4px 8px; }

.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 5px;
}

/* =============================================
   Auth Pages
   ============================================= */
.auth-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0d2318 0%, #1a4731 50%, #0d2318 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.auth-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: rgba(25,135,84,0.15);
  top: -200px; right: -200px;
}

.auth-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: rgba(25,135,84,0.1);
  bottom: -150px; left: -100px;
}

.auth-card {
  background: var(--bs-card-bg, #fff);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 10;
  animation: slideUp 0.4s ease;
}

.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo img { width: 64px; height: 64px; }
.auth-logo h4 { margin-top: 10px; font-weight: 700; color: var(--primary); }
.auth-logo p  { color: var(--bs-secondary-color, #6c757d); font-size: 13px; margin: 0; }

/* =============================================
   Notifications
   ============================================= */
.badge-dot {
  position: absolute;
  top: 4px; right: 4px;
  width: 18px; height: 18px;
  border-radius: 50%;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
}

.notification-dropdown {
  width: 320px;
  max-height: 400px;
  overflow-y: auto;
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--bs-border-color, #f0f4f8);
}

.notif-item.unread { background: rgba(25,135,84,0.05); }

.notif-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.notif-body p { font-size: 13px; line-height: 1.4; }

.dropdown-header {
  padding: 12px 16px;
  font-weight: 600;
  font-size: 13px;
  border-bottom: 1px solid var(--bs-border-color, #e2e8f0);
}

/* =============================================
   Progress Bars
   ============================================= */
.progress { border-radius: 50px; background: var(--bs-border-color, #e2e8f0); }
.progress-bar { border-radius: 50px; transition: width 1s ease; }

/* =============================================
   Toast Container
   ============================================= */
#toastContainer {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast-msg {
  background: #fff;
  border-radius: 10px;
  padding: 14px 18px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  max-width: 380px;
  border-left: 4px solid;
  animation: slideInRight 0.3s ease;
}

.toast-msg.success { border-color: #198754; }
.toast-msg.danger  { border-color: #dc3545; }
.toast-msg.warning { border-color: #ffc107; }
.toast-msg.info    { border-color: #0dcaf0; }

/* =============================================
   Animations
   ============================================= */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes countUp {
  from { transform: scale(0.8); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.animate-fade { animation: fadeIn 0.4s ease; }
.animate-up   { animation: slideUp 0.4s ease; }
.stat-value   { animation: countUp 0.5s ease; }

/* =============================================
   Loading Spinner
   ============================================= */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spinner-border-lg { width: 3rem; height: 3rem; }

/* =============================================
   Utilities
   ============================================= */
.text-primary { color: var(--primary) !important; }
.bg-primary   { background-color: var(--primary) !important; }
.border-primary { border-color: var(--primary) !important; }

.page-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--bs-body-color);
}

.page-subtitle {
  font-size: 13px;
  color: var(--bs-secondary-color, #6c757d);
  margin-bottom: 20px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--primary-light);
  color: var(--primary-dark);
}

/* =============================================
   Responsive
   ============================================= */
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
  .sidebar-overlay {
    display: block !important;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
  }
}

@media (max-width: 768px) {
  /* Topbar actions collapse gracefully */
  .topbar .d-flex { gap: 6px !important; }
  /* Page titles */
  .page-title { font-size: 20px; }
  .page-subtitle { font-size: 13px; }
  /* Stat cards stack */
  .stat-card { min-width: 0; }
  /* Tables: hide less-important columns via utility */
  .d-md-none-mobile { display: none !important; }
  /* Action button bars wrap */
  .d-flex.gap-2.flex-nowrap { flex-wrap: wrap !important; }
  /* Card paddings tighten */
  .card-body.p-4 { padding: 1rem !important; }
  .card-body.p-5 { padding: 1.5rem !important; }
  /* Cert print page */
  .cert-outer { width: 100% !important; }
  /* Forms public page */
  .form-card { padding: 20px !important; }
}

@media (max-width: 576px) {
  .auth-card { padding: 28px 20px; }
  .page-content { padding: 16px; }
  .stat-value { font-size: 22px; }
  /* Stack all flex rows on phones */
  .d-flex.justify-content-between { flex-wrap: wrap; gap: 10px; }
  .actions { flex-direction: column; }
  /* Home navbar collapse button visible */
  .navbar-toggler { display: flex !important; }
  /* Team cards full-width on phone */
  .team-card .team-photo { height: 200px !important; }
  .team-card-body h5 { font-size: 14px; }
  .team-card-body .designation { font-size: 11px; }
  .team-card-body .bio { display: none; }    /* hide bio on tiny screens */
  .team-rank-badge { font-size: 9px; padding: 2px 7px; }
  /* Badge page */
  .badge-body { padding: 52px 20px 20px !important; }
  .badge-name { font-size: 20px !important; }
  /* Certificate print page: scale down on small screens */
  .cert-outer { transform: scale(0.55); transform-origin: top left; width: 182% !important; }
  /* Public form */
  .form-card { padding: 20px !important; }
  /* Issue page recipient list */
  #recipientList .avatar-sm, #teamSortable .avatar-sm { width: 28px !important; height: 28px !important; }
  /* Hide secondary table columns on mobile */
  .table th:nth-child(n+5),
  .table td:nth-child(n+5) { display: none; }
  /* Opportunity view — sticky apply card */
  .col-lg-4 > .card[style*="sticky"] { position: relative !important; top: 0 !important; }
  /* Prevent horizontal overflow on page */
  .page-content, .main-content { overflow-x: hidden; }
  /* Drag handle bigger touch target */
  .drag-handle { padding: 0 10px !important; }
}

/* Table responsive wrapper */
.table-responsive { border-radius: var(--card-radius); }

/* Avatar */
.avatar-sm { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.avatar-md { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }
.avatar-lg { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; }

/* Dropdown items */
.dropdown-item { font-size: 13.5px; padding: 8px 14px; border-radius: 6px; margin: 1px 4px; }
.dropdown-menu { border-radius: 10px; border: 1px solid var(--bs-border-color, #e2e8f0); box-shadow: var(--shadow); padding: 6px; }

/* Alert styles */
.alert { border-radius: 10px; font-size: 13.5px; }

/* =============================================
   Dark Mode Overrides
   ============================================= */
[data-bs-theme="dark"] .auth-card { background: #1e293b; }
[data-bs-theme="dark"] .topbar { background: #1e293b; }
[data-bs-theme="dark"] .card { background: #1e293b; border-color: #334155; }
[data-bs-theme="dark"] .btn-icon:hover { background: #334155; }
[data-bs-theme="dark"] .table { color: #e2e8f0; }
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select { background: #0f172a; color: #e2e8f0; border-color: #334155; }
[data-bs-theme="dark"] .input-group-text { background: #1e293b; color: #e2e8f0; border-color: #334155; }
[data-bs-theme="dark"] .toast-msg { background: #1e293b; color: #e2e8f0; }
[data-bs-theme="dark"] .dropdown-menu { background: #1e293b; border-color: #334155; }
[data-bs-theme="dark"] .dropdown-item:hover { background: #334155; }
[data-bs-theme="dark"] .dropdown-header { border-color: #334155; }
[data-bs-theme="dark"] .notif-item { border-color: #334155; }
[data-bs-theme="dark"] .notif-item.unread { background: rgba(25,135,84,0.1); }
[data-bs-theme="dark"] .progress { background: #334155; }
