/* ============================================================
   OMZE ACADEMY OS — Tema Dark Premium
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
@import url('variables.css');

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--font-normal);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

/* ============================================================
   SCROLLBAR CUSTOM
   ============================================================ */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ============================================================
   LINKS
   ============================================================ */

a { color: var(--accent); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--accent-light); }

/* ============================================================
   HEADINGS
   ============================================================ */

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--space-4);
  font-weight: var(--font-semi);
  line-height: var(--leading-tight);
  color: var(--text-primary);
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-base); }
h6 { font-size: var(--text-sm); }

p { margin: 0 0 var(--space-4); color: var(--text-secondary); }

/* ============================================================
   LAYOUT
   ============================================================ */

.app-wrapper {
  display: flex;
  min-height: 100vh;
}

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

.app-content.sidebar-collapsed {
  margin-left: var(--sidebar-collapsed);
}

.page-body {
  flex: 1;
  padding: var(--space-6) var(--space-8);
  max-width: var(--content-max);
  width: 100%;
}

@media (max-width: 768px) {
  .app-content { margin-left: 0; }
  .page-body { padding: var(--space-4); }
}

/* ============================================================
   SIDEBAR
   ============================================================ */

.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  transition: width var(--transition-slow);
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-logo {
  padding: var(--space-6) var(--space-5);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--header-height);
  flex-shrink: 0;
}

.sidebar-logo .logo-mark {
  width: 36px; height: 36px;
  background: var(--gradient-accent);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-weight: var(--font-bold);
  font-size: var(--text-sm);
  color: var(--text-inverse);
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: var(--shadow-glow);
}

.sidebar-logo .logo-text {
  display: flex; flex-direction: column;
  opacity: 1; transition: opacity var(--transition-slow);
}

.sidebar.collapsed .logo-text { opacity: 0; }

.sidebar-logo .logo-name {
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  white-space: nowrap;
}

.sidebar-logo .logo-sub {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-4) var(--space-3);
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-group {
  margin-bottom: var(--space-6);
}

.nav-group-label {
  font-size: 10px;
  font-weight: var(--font-semi);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 var(--space-3);
  margin-bottom: var(--space-2);
  white-space: nowrap;
  transition: opacity var(--transition);
}

.sidebar.collapsed .nav-group-label { opacity: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  transition: var(--transition);
  position: relative;
  white-space: nowrap;
  margin-bottom: 2px;
  cursor: pointer;
  text-decoration: none;
}

.nav-item:hover {
  background: var(--accent-muted);
  color: var(--accent);
}

.nav-item.active {
  background: var(--accent-muted);
  color: var(--accent);
  border-left: 2px solid var(--accent);
}

.nav-item .nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item .nav-label {
  opacity: 1; transition: opacity var(--transition-slow);
}
.sidebar.collapsed .nav-item .nav-label { opacity: 0; width: 0; }

.nav-item .nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: var(--text-inverse);
  font-size: 10px;
  font-weight: var(--font-bold);
  padding: 2px 6px;
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
  transition: opacity var(--transition);
}
.sidebar.collapsed .nav-badge { opacity: 0; }

.sidebar-user {
  padding: var(--space-4) var(--space-3);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-user .user-avatar {
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  background: var(--accent-muted);
  border: 1px solid var(--accent-border);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
  color: var(--accent);
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-user .user-info {
  flex: 1; min-width: 0;
  transition: opacity var(--transition-slow);
}
.sidebar.collapsed .user-info { opacity: 0; }

.sidebar-user .user-name {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user .user-role {
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
}

/* ============================================================
   HEADER
   ============================================================ */

.app-header {
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-8);
  gap: var(--space-4);
  position: sticky;
  top: 0;
  z-index: var(--z-header);
}

.header-toggle {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.header-toggle:hover { background: var(--bg-card); color: var(--accent); }

.header-breadcrumb {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.header-breadcrumb .current {
  color: var(--text-primary);
  font-weight: var(--font-medium);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.card:hover { border-color: var(--border-light); }

.card.card-glass {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border-color: var(--glass-border);
}

.card.card-accent {
  border-color: var(--accent-border);
  background: linear-gradient(135deg, var(--bg-card), rgba(0, 212, 170, 0.03));
}

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

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  gap: var(--space-4);
}

.card-title {
  font-size: var(--text-base);
  font-weight: var(--font-semi);
  color: var(--text-primary);
  margin: 0;
}

.card-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

/* ============================================================
   STAT CARDS
   ============================================================ */

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  transition: var(--transition);
}

.stat-card:hover {
  border-color: var(--accent-border);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.stat-icon.accent { background: var(--accent-muted); color: var(--accent); }
.stat-icon.success { background: var(--success-muted); color: var(--success); }
.stat-icon.warning { background: var(--warning-muted); color: var(--warning); }
.stat-icon.danger  { background: var(--danger-muted);  color: var(--danger); }
.stat-icon.gold    { background: var(--gold-muted);    color: var(--gold); }

.stat-body { flex: 1; min-width: 0; }

.stat-value {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: var(--space-1);
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.stat-change {
  font-size: var(--text-xs);
  margin-top: var(--space-2);
  display: flex; align-items: center; gap: var(--space-1);
}

.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ============================================================
   GRID
   ============================================================ */

.grid { display: grid; gap: var(--space-6); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

@media (max-width: 1024px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px)  { .grid-2,.grid-3,.grid-4 { grid-template-columns: 1fr; } }

/* ============================================================
   BADGES / TAGS
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  white-space: nowrap;
}

.badge-accent  { background: var(--accent-muted);   color: var(--accent); }
.badge-success { background: var(--success-muted); color: var(--success); }
.badge-warning { background: var(--warning-muted); color: var(--warning); }
.badge-danger  { background: var(--danger-muted);  color: var(--danger); }
.badge-info    { background: var(--info-muted);    color: var(--info); }
.badge-gold    { background: var(--gold-muted);    color: var(--gold); }
.badge-muted   { background: rgba(74,85,104,0.2);  color: var(--text-muted); }

/* OTC Status */
.otc-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-semi);
}
.otc-badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.otc-badge.green  { background: var(--success-muted); color: var(--otc-green); }
.otc-badge.yellow { background: var(--warning-muted); color: var(--otc-yellow); }
.otc-badge.red    { background: var(--danger-muted);  color: var(--otc-red); }

/* ============================================================
   PROGRESS BAR
   ============================================================ */

.progress-track {
  width: 100%;
  height: 6px;
  background: var(--bg-primary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--accent-dark), var(--accent));
  transition: width 600ms cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.progress-fill::after {
  content: '';
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 12px;
  background: rgba(255,255,255,0.3);
  border-radius: var(--radius-full);
}

.progress-fill.success { background: linear-gradient(90deg, #059669, var(--success)); }
.progress-fill.warning { background: linear-gradient(90deg, #D97706, var(--warning)); }
.progress-fill.danger  { background: linear-gradient(90deg, #DC2626, var(--danger)); }

/* ============================================================
   OTC SCORE WIDGET
   ============================================================ */

.otc-widget {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

.otc-ring {
  position: relative;
  width: 100px; height: 100px;
}

.otc-ring svg {
  transform: rotate(-90deg);
}

.otc-ring .ring-bg { stroke: var(--bg-primary); }
.otc-ring .ring-fill { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 1s ease; }
.otc-ring.yellow .ring-fill { stroke: var(--otc-yellow); }
.otc-ring.red    .ring-fill { stroke: var(--otc-red); }

.otc-score-text {
  position: absolute;
  inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}

.otc-score-number {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  line-height: 1;
}

.otc-score-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ============================================================
   LESSON CARD
   ============================================================ */

.lesson-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: var(--transition);
  text-decoration: none;
  color: inherit;
}

.lesson-card:hover {
  border-color: var(--accent-border);
  background: var(--bg-card-hover);
}

.lesson-type-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.lesson-type-icon.video       { background: rgba(239,68,68,0.12);  color: #EF4444; }
.lesson-type-icon.text        { background: rgba(59,130,246,0.12); color: #3B82F6; }
.lesson-type-icon.pdf         { background: rgba(245,158,11,0.12); color: #F59E0B; }
.lesson-type-icon.quiz        { background: var(--accent-muted);   color: var(--accent); }
.lesson-type-icon.simulation  { background: rgba(139,92,246,0.12); color: #8B5CF6; }
.lesson-type-icon.checklist   { background: var(--success-muted);  color: var(--success); }

/* ============================================================
   AVATAR
   ============================================================ */

.avatar {
  border-radius: var(--radius-full);
  object-fit: cover;
  display: flex; align-items: center; justify-content: center;
  font-weight: var(--font-bold);
  background: var(--accent-muted);
  color: var(--accent);
  flex-shrink: 0;
}

.avatar-xs  { width: 24px; height: 24px; font-size: 10px; }
.avatar-sm  { width: 32px; height: 32px; font-size: var(--text-xs); }
.avatar-md  { width: 40px; height: 40px; font-size: var(--text-sm); }
.avatar-lg  { width: 48px; height: 48px; font-size: var(--text-base); }
.avatar-xl  { width: 64px; height: 64px; font-size: var(--text-xl); }

/* ============================================================
   ALERTS / FLASH
   ============================================================ */

.alert {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}

.alert-success { background: var(--success-muted); color: var(--success); border: 1px solid rgba(16,185,129,0.2); }
.alert-error   { background: var(--danger-muted);  color: var(--danger);  border: 1px solid rgba(239,68,68,0.2); }
.alert-warning { background: var(--warning-muted); color: var(--warning); border: 1px solid rgba(245,158,11,0.2); }
.alert-info    { background: var(--info-muted);    color: var(--info);    border: 1px solid rgba(59,130,246,0.2); }

/* ============================================================
   RANKING TABLE
   ============================================================ */

.ranking-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.ranking-item:hover { background: var(--bg-card-hover); }

.ranking-position {
  width: 28px; height: 28px;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
  flex-shrink: 0;
}

.ranking-position.pos-1 { background: var(--gold-muted);   color: var(--gold); }
.ranking-position.pos-2 { background: rgba(148,163,184,0.12); color: #94A3B8; }
.ranking-position.pos-3 { background: rgba(180,120,60,0.12);  color: #B4783C; }
.ranking-position.other { background: var(--bg-primary);   color: var(--text-muted); }

/* ============================================================
   MODAL
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 15, 0.85);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  transition: opacity var(--transition);
}

.modal-overlay.active { opacity: 1; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(20px);
  transition: transform var(--transition-slow);
}

.modal-overlay.active .modal { transform: scale(1) translateY(0); }

.modal-header {
  padding: var(--space-6) var(--space-6) 0;
  display: flex; align-items: flex-start; justify-content: space-between;
}

.modal-body { padding: var(--space-6); }
.modal-footer {
  padding: 0 var(--space-6) var(--space-6);
  display: flex; justify-content: flex-end; gap: var(--space-3);
}

/* ============================================================
   DIVIDER
   ============================================================ */

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--space-6) 0;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */

.empty-state {
  text-align: center;
  padding: var(--space-16) var(--space-8);
  color: var(--text-muted);
}

.empty-state .empty-icon {
  width: 64px; height: 64px;
  margin: 0 auto var(--space-4);
  opacity: 0.3;
}

.empty-state h3 { color: var(--text-secondary); margin-bottom: var(--space-2); }

/* ============================================================
   LOADING
   ============================================================ */

.spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: var(--radius-full);
  animation: spin 600ms linear infinite;
}

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

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   GLOW ANIMATION
   ============================================================ */

@keyframes pulse-glow {
  0%, 100% { box-shadow: var(--shadow-glow); }
  50%       { box-shadow: var(--shadow-glow-lg); }
}

.animate-glow { animation: pulse-glow 3s ease-in-out infinite; }

/* ============================================================
   GRADIENT TEXT
   ============================================================ */

.gradient-text {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gradient-text-gold {
  background: linear-gradient(135deg, var(--gold), #E8C56A);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ============================================================
   PAGE HEADER
   ============================================================ */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
  flex-wrap: wrap;
}

.page-header .page-title {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  margin: 0;
}

.page-header .page-sub {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1024px) {
  :root {
    --sidebar-width: 220px;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition-slow);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .app-content { margin-left: 0 !important; }
  .page-header { flex-direction: column; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
