/* ==========================================================================
   LinkLingo — Backoffice Administrative Stylesheet
   ========================================================================== */

:root {
  --admin-sidebar-bg: #0A192F;
  --admin-sidebar-hover: #112240;
  --admin-sidebar-active: rgba(0, 114, 255, 0.15);
  --admin-sidebar-text: #8892B0;
  --admin-sidebar-light: #CCD6F6;
  
  --admin-bg: #F8FAFC;
  --admin-card-bg: #FFFFFF;
  --admin-border: #E2E8F0;
  --admin-border-subtle: #F1F5F9;

  --navy-dark: #0F172A;
  --blue-electric: #0072FF;
  --blue-hover: #0059CC;
  --mint-teal: #00C897;
  --orange-warm: #FF5200;
  --red-alert: #EF4444;
  --yellow-warn: #F59E0B;

  --text-dark: #1E293B;
  --text-muted: #64748B;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.08);

  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--admin-bg);
  color: var(--text-dark);
  line-height: 1.5;
  overflow-x: hidden;
}

/* ==========================================================================
   1. ADMIN LOGIN OVERLAY
   ========================================================================== */
.admin-login-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at top right, #1E293B, #0F172A);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.admin-login-card {
  background: #FFFFFF;
  width: 100%;
  max-width: 440px;
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  text-align: center;
}

.admin-login-logo {
  height: 48px;
  margin-bottom: 1.2rem;
}

.admin-badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(0, 114, 255, 0.08);
  color: var(--blue-electric);
  padding: 0.35rem 0.9rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 1rem;
}

.admin-form-group {
  text-align: left;
  margin-bottom: 1.2rem;
}

.admin-form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--navy-dark);
  margin-bottom: 0.4rem;
}

.admin-form-control {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--admin-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

.admin-form-control:focus {
  outline: none;
  border-color: var(--blue-electric);
  box-shadow: 0 0 0 3px rgba(0, 114, 255, 0.12);
}

.btn-admin-primary {
  width: 100%;
  padding: 0.9rem;
  background: var(--blue-electric);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background 0.2s ease;
  margin-top: 0.5rem;
}

.btn-admin-primary:hover {
  background: var(--blue-hover);
}

/* ==========================================================================
   2. MAIN ADMIN LAYOUT (SIDEBAR & MAIN VIEW)
   ========================================================================== */
.admin-layout-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
  width: 260px;
  background: var(--admin-sidebar-bg);
  color: var(--admin-sidebar-text);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: all 0.3s ease;
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-logo-img {
  height: 36px;
  filter: brightness(0) invert(1);
}

.sidebar-nav-list {
  list-style: none;
  padding: 1rem 0.75rem;
  flex: 1;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
  padding: 0.8rem 0.75rem 0.4rem 0.75rem;
}

.sidebar-nav-item a {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.75rem 0.9rem;
  color: var(--admin-sidebar-text);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  margin-bottom: 0.2rem;
}

.sidebar-nav-item a:hover {
  background: var(--admin-sidebar-hover);
  color: var(--admin-sidebar-light);
}

.sidebar-nav-item.active a {
  background: var(--blue-electric);
  color: #FFFFFF;
  font-weight: 700;
}

.sidebar-user-footer {
  padding: 1.2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.15);
}

.user-meta-info {
  display: flex;
  flex-direction: column;
}

.user-meta-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--admin-sidebar-light);
}

.user-meta-role {
  font-size: 0.72rem;
  color: var(--mint-teal);
  font-weight: 800;
  text-transform: uppercase;
}

.btn-logout-icon {
  background: transparent;
  border: none;
  color: var(--admin-sidebar-text);
  font-size: 1.2rem;
  cursor: pointer;
  transition: color 0.2s ease;
}

.btn-logout-icon:hover {
  color: var(--red-alert);
}

/* Main Content Area */
.admin-main-content {
  margin-left: 260px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Top Navbar Header */
.admin-top-header {
  height: 70px;
  background: #FFFFFF;
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 90;
}

.top-header-greeting h2 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--navy-dark);
}

.top-header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn-export-csv {
  padding: 0.55rem 1.1rem;
  background: #F1F5F9;
  color: var(--navy-dark);
  border: 1px solid var(--admin-border);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.btn-export-csv:hover {
  background: var(--blue-electric);
  color: #FFFFFF;
  border-color: var(--blue-electric);
}

/* Body Container */
.admin-page-container {
  padding: 2rem;
  flex: 1;
}

.admin-view-pane {
  display: none;
}

.admin-view-pane.active {
  display: block;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   3. DASHBOARD COMPONENTS & KPI CARDS
   ========================================================================== */
.kpi-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background: #FFFFFF;
  border: 1px solid var(--admin-border);
  border-radius: var(--radius-md);
  padding: 1.4rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.8rem;
}

.kpi-icon-box {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.kpi-icon-blue { background: rgba(0, 114, 255, 0.1); color: var(--blue-electric); }
.kpi-icon-green { background: rgba(0, 200, 151, 0.1); color: var(--mint-teal); }
.kpi-icon-orange { background: rgba(255, 82, 0, 0.1); color: var(--orange-warm); }
.kpi-icon-purple { background: rgba(147, 51, 234, 0.1); color: #9333EA; }

.kpi-card-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}

.kpi-card-value {
  font-family: var(--font-heading);
  font-size: 1.9rem;
  font-weight: 900;
  color: var(--navy-dark);
}

/* CEFR Distribution Progress Bars */
.cefr-distribution-box {
  background: #FFFFFF;
  border: 1px solid var(--admin-border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
}

.cefr-dist-bar-item {
  margin-bottom: 1rem;
}

.cefr-dist-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--navy-dark);
  margin-bottom: 0.3rem;
}

.cefr-dist-track {
  height: 10px;
  background: #F1F5F9;
  border-radius: var(--radius-full);
  overflow: hidden;
}

.cefr-dist-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
}

.fill-a1 { background: #94A3B8; }
.fill-a2 { background: #3B82F6; }
.fill-b1 { background: #00C897; }
.fill-b2 { background: #F59E0B; }
.fill-c1 { background: #8B5CF6; }
.fill-c2 { background: #EC4899; }

/* Data Tables */
.admin-table-container {
  background: #FFFFFF;
  border: 1px solid var(--admin-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 2rem;
}

.table-header-toolbar {
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.table-toolbar-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--navy-dark);
}

.admin-data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.admin-data-table th {
  background: #F8FAFC;
  padding: 0.9rem 1.2rem;
  font-weight: 800;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--admin-border);
}

.admin-data-table td {
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--admin-border-subtle);
  color: var(--text-dark);
  vertical-align: middle;
}

.admin-data-table tr:hover td {
  background: #F8FAFC;
}

/* Badges */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.7rem;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 800;

}

.status-completed { background: rgba(0, 200, 151, 0.12); color: #00A37B; }
.status-progress { background: rgba(0, 114, 255, 0.12); color: var(--blue-electric); }
.status-abandoned { background: rgba(239, 68, 68, 0.12); color: var(--red-alert); }
.status-active { background: rgba(16, 185, 129, 0.12); color: #059669; }
.status-inactive { background: #F1F5F9; color: var(--text-muted); }

.badge-level {
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  font-weight: 900;
  font-size: 0.8rem;
  font-family: var(--font-heading);
}

.lvl-a1 { background: #E2E8F0; color: #475569; }
.lvl-a2 { background: #DBEAFE; color: #1E40AF; }
.lvl-b1 { background: #D1FAE5; color: #065F46; }
.lvl-b2 { background: #FEF3C7; color: #92400E; }
.lvl-c1 { background: #EDE9FE; color: #5B21B6; }
.lvl-c2 { background: #FCE7F3; color: #9D174D; }

/* Table Action Buttons */
.btn-table-action {
  padding: 0.4rem 0.8rem;
  background: #F1F5F9;
  color: var(--navy-dark);
  border: 1px solid var(--admin-border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  text-decoration: none;
}

.btn-table-action:hover {
  background: var(--blue-electric);
  color: #FFFFFF;
  border-color: var(--blue-electric);
}

/* Modals */
.admin-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.admin-modal-overlay.active {
  display: flex;
}

.admin-modal-box {
  background: #FFFFFF;
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 1.4rem 1.8rem;
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--navy-dark);
}

.btn-modal-close {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-body {
  padding: 1.8rem;
  overflow-y: auto;
  flex: 1;
}

/* Responsive Rules */
@media (max-width: 992px) {
  .admin-sidebar {
    transform: translateX(-100%);
  }
  .admin-main-content {
    margin-left: 0;
  }
  .admin-sidebar.mobile-open {
    transform: translateX(0);
  }
}
