/* ============================================================
   LERN AKADEMİ — GLOBAL DESIGN SYSTEM
   Premium edtech design tokens & reusable utilities
   ============================================================ */

:root {
  /* ── Brand Colors ── */
  --primary:       #6366f1;
  --primary-dark:  #4f46e5;
  --primary-light: #818cf8;
  --primary-bg:    #eef2ff;
  --secondary:     #8b5cf6;
  --accent:        #06b6d4;
  --accent-green:  #10b981;
  --accent-amber:  #f59e0b;
  --accent-rose:   #f43f5e;

  /* ── Neutrals ── */
  --ink:           #0f172a;
  --ink-2:         #1e293b;
  --ink-3:         #334155;
  --muted:         #64748b;
  --muted-2:       #94a3b8;
  --border:        #e2e8f0;
  --border-2:      #f1f5f9;
  --surface:       #f8fafc;
  --surface-2:     #f1f5f9;
  --white:         #ffffff;

  /* ── Dark Surface (for hero/sidebar) ── */
  --dark:          #0a0f1e;
  --dark-2:        #111827;
  --dark-3:        #1f2937;
  --dark-border:   rgba(255,255,255,0.08);
  --dark-muted:    rgba(255,255,255,0.45);

  /* ── Gradients ── */
  --grad-primary:  linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --grad-dark:     linear-gradient(135deg, #0a0f1e 0%, #1a1040 100%);
  --grad-glow:     radial-gradient(ellipse at 50% 0%, rgba(99,102,241,0.35) 0%, transparent 70%);
  --grad-amber:    linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
  --grad-green:    linear-gradient(135deg, #10b981 0%, #059669 100%);
  --grad-cyan:     linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);

  /* ── Typography ── */
  --font-display:  'Plus Jakarta Sans', sans-serif;
  --font-body:     'Inter', sans-serif;

  /* ── Spacing Scale ── */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* ── Radii ── */
  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-xl:   20px;
  --r-2xl:  24px;
  --r-3xl:  32px;
  --r-full: 9999px;

  /* ── Shadows ── */
  --shadow-xs:   0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm:   0 2px 8px rgba(0,0,0,0.07);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.10);
  --shadow-xl:   0 16px 48px rgba(0,0,0,0.14);
  --shadow-2xl:  0 24px 64px rgba(0,0,0,0.18);
  --shadow-glow: 0 0 40px rgba(99,102,241,0.25);
  --shadow-primary: 0 8px 24px rgba(99,102,241,0.35);

  /* ── Transitions ── */
  --ease:       cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out:   cubic-bezier(0, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast:   0.15s;
  --dur-base:   0.25s;
  --dur-slow:   0.4s;

  /* ── Z-Index ── */
  --z-base:    1;
  --z-above:   10;
  --z-nav:     100;
  --z-sticky:  200;
  --z-modal:   1000;
  --z-toast:   2000;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; }
body { font-family: var(--font-body); color: var(--ink); background: var(--white); line-height: 1.6; }
h1,h2,h3,h4,h5,h6 { font-family: var(--font-display); font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; }
a { text-decoration: none; color: inherit; }
img { display: block; max-width: 100%; }
button { font-family: var(--font-body); cursor: pointer; }

/* ── Utility: Container ── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }
.container-sm { max-width: 900px; margin: 0 auto; padding: 0 1.5rem; }
.container-lg { max-width: 1400px; margin: 0 auto; padding: 0 1.5rem; }

/* ── Utility: Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.75rem 1.5rem; border-radius: var(--r-full);
  font-family: var(--font-display); font-weight: 600; font-size: 0.9rem;
  border: none; transition: all var(--dur-base) var(--ease);
  white-space: nowrap;
}
.btn-primary {
  background: var(--grad-primary); color: white;
  box-shadow: var(--shadow-primary);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 32px rgba(99,102,241,0.45); }
.btn-secondary {
  background: var(--primary-bg); color: var(--primary);
  border: 1.5px solid rgba(99,102,241,0.2);
}
.btn-secondary:hover { background: #dde4ff; border-color: var(--primary); }
.btn-dark {
  background: var(--ink); color: white;
  box-shadow: var(--shadow-md);
}
.btn-dark:hover { background: var(--ink-2); transform: translateY(-2px); }
.btn-ghost {
  background: transparent; color: var(--muted);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }
.btn-white {
  background: white; color: var(--ink);
  box-shadow: var(--shadow-md);
}
.btn-white:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.btn-lg { padding: 1rem 2rem; font-size: 1rem; }
.btn-sm { padding: 0.5rem 1rem; font-size: 0.8rem; }
.btn-icon { padding: 0.75rem; border-radius: var(--r-md); }

/* ── Utility: Cards ── */
.card {
  background: white; border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: 1.5rem;
  box-shadow: var(--shadow-xs);
  transition: all var(--dur-base) var(--ease);
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card-dark {
  background: var(--dark-2); border: 1px solid var(--dark-border);
  color: white;
}
.card-glass {
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.12);
}

/* ── Utility: Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.3rem 0.75rem; border-radius: var(--r-full);
  font-size: 0.75rem; font-weight: 600;
  font-family: var(--font-display);
}
.badge-primary { background: var(--primary-bg); color: var(--primary); }
.badge-green   { background: #d1fae5; color: #065f46; }
.badge-amber   { background: #fef3c7; color: #92400e; }
.badge-rose    { background: #ffe4e6; color: #9f1239; }
.badge-dark    { background: var(--ink); color: white; }
.badge-muted   { background: var(--surface-2); color: var(--muted); }

/* ── Utility: Inputs ── */
.input {
  width: 100%; padding: 0.75rem 1rem;
  border: 1.5px solid var(--border); border-radius: var(--r-md);
  font-family: var(--font-body); font-size: 0.95rem; color: var(--ink);
  background: white; transition: border-color var(--dur-fast) var(--ease);
  outline: none;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.12); }
.input::placeholder { color: var(--muted-2); }

/* ── Utility: Skeleton ── */
@keyframes shimmer {
  from { background-position: -600px 0; }
  to   { background-position:  600px 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, #e8eaed 50%, var(--surface-2) 75%);
  background-size: 1200px 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r-md);
}

/* ── Utility: Animations ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes slideRight {
  from { opacity: 0; transform: translateX(-16px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-8px); }
}
@keyframes pulse-ring {
  0%   { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}
@keyframes spin { to { transform: rotate(360deg); } }

.animate-fade-up   { animation: fadeUp var(--dur-slow) var(--ease) both; }
.animate-fade-in   { animation: fadeIn var(--dur-base) var(--ease) both; }
.animate-scale-in  { animation: scaleIn var(--dur-base) var(--ease-spring) both; }
.animate-float     { animation: float 3s ease-in-out infinite; }

/* ── Section spacing ── */
.section { padding: var(--space-24) 0; }
.section-sm { padding: var(--space-16) 0; }
.section-label {
  font-family: var(--font-display);
  font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--primary); margin-bottom: 0.75rem;
}
.section-title {
  font-size: clamp(1.8rem, 3.5vw, 2.8rem);
  font-weight: 800; letter-spacing: -0.03em;
  color: var(--ink); margin-bottom: 1rem;
}
.section-title-white { color: white; }
.section-desc {
  font-size: 1.05rem; color: var(--muted);
  max-width: 560px; line-height: 1.7;
}

/* ── Divider ── */
.divider { height: 1px; background: var(--border); margin: 0; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }

/* ── Toast notifications ── */
.toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  display: flex; flex-direction: column; gap: 0.75rem;
  z-index: var(--z-toast);
}
.toast {
  background: var(--ink-2); color: white;
  padding: 0.875rem 1.25rem; border-radius: var(--r-lg);
  display: flex; align-items: center; gap: 0.75rem;
  box-shadow: var(--shadow-xl); font-size: 0.9rem;
  animation: fadeUp 0.3s var(--ease-spring);
  max-width: 360px;
}
.toast-icon { font-size: 1.1rem; }
.toast-success { border-left: 3px solid var(--accent-green); }
.toast-error   { border-left: 3px solid var(--accent-rose); }
.toast-info    { border-left: 3px solid var(--primary); }

/* ── Responsive helpers ── */
@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
  .section { padding: var(--space-16) 0; }
}
@media (min-width: 769px) {
  .show-mobile { display: none !important; }
}

/* ============================================================
   MOBILE & TOUCH IMPROVEMENTS
   ============================================================ */

/* ── Touch target helpers ── */
.touch-target {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── Responsive grid utilities ── */
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.grid-auto-sm { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.75rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
@media (max-width: 900px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .grid-auto { grid-template-columns: 1fr; }
}

/* ── Responsive card spacing ── */
@media (max-width: 768px) {
  .card { padding: 1rem; border-radius: var(--r-lg); }
  .container, .container-sm, .container-lg { padding: 0 1rem; }
  .section { padding: var(--space-12) 0; }
  .section-sm { padding: var(--space-8) 0; }
  .btn { padding: 0.65rem 1.25rem; font-size: 0.85rem; }
  .btn-lg { padding: 0.875rem 1.5rem; font-size: 0.95rem; }
}

/* ── Mobile bottom nav ── */
.mobile-bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 60px;
  background: white;
  border-top: 1px solid var(--border);
  z-index: 150;
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
}
.mobile-bottom-nav .mbn-inner {
  display: flex; align-items: stretch; height: 100%;
}
.mbn-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: 0.6rem; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: color 0.15s;
  border: none; background: none; padding: 0;
  -webkit-tap-highlight-color: transparent;
}
.mbn-item i { font-size: 1.1rem; }
.mbn-item.active, .mbn-item:active { color: var(--primary); }
.mbn-item .mbn-dot {
  position: absolute; top: 8px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-rose); border: 1.5px solid white;
}
@media (max-width: 768px) {
  .mobile-bottom-nav { display: block; }
  /* Push page content above bottom nav */
  .page-content, main, .lb-page { padding-bottom: calc(72px + env(safe-area-inset-bottom, 0)) !important; }
}

/* ── Sticky mobile actions bar ── */
.sticky-mobile-actions {
  display: none;
  position: fixed; bottom: 60px; left: 0; right: 0;
  padding: 0.75rem 1rem;
  background: white;
  border-top: 1px solid var(--border);
  z-index: 140;
  gap: 0.5rem;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
}
@media (max-width: 768px) {
  .sticky-mobile-actions { display: flex; }
}

/* ── Mobile modal ── */
.mobile-sheet {
  position: fixed; inset: 0;
  z-index: var(--z-modal);
  pointer-events: none;
}
.mobile-sheet.open { pointer-events: all; }
.mobile-sheet-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.5);
  opacity: 0; transition: opacity 0.3s;
}
.mobile-sheet.open .mobile-sheet-overlay { opacity: 1; }
.mobile-sheet-panel {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: white;
  border-radius: var(--r-2xl) var(--r-2xl) 0 0;
  padding: 1.25rem 1.5rem calc(1.5rem + env(safe-area-inset-bottom, 0));
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 85vh;
  overflow-y: auto;
}
.mobile-sheet.open .mobile-sheet-panel { transform: translateY(0); }
.mobile-sheet-handle {
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--border); margin: 0 auto 1.25rem;
}
.mobile-sheet-title {
  font-size: 1rem; font-weight: 800; color: var(--ink);
  margin-bottom: 1rem;
}

/* ── Swipeable tabs (horizontal scroll) ── */
.tabs-scroll {
  display: flex; gap: 0.25rem;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; padding-bottom: 2px;
}
.tabs-scroll::-webkit-scrollbar { display: none; }
.tab-pill {
  flex-shrink: 0; padding: 0.45rem 1rem; border-radius: var(--r-full);
  font-size: 0.8rem; font-weight: 600; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border);
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
  border: none; font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
}
.tab-pill.active {
  background: var(--primary); color: white;
  box-shadow: 0 2px 8px rgba(99,102,241,0.35);
}
.tab-pill:hover:not(.active) { background: var(--surface-2); color: var(--ink); }

/* ── Pull-to-refresh indicator ── */
.ptr-indicator {
  display: flex; align-items: center; justify-content: center;
  gap: 0.5rem; padding: 0.75rem;
  font-size: 0.8rem; color: var(--muted);
  height: 0; overflow: hidden;
  transition: height 0.2s;
}
.ptr-indicator.visible { height: 48px; }

/* ── Safe area padding ── */
.safe-bottom { padding-bottom: env(safe-area-inset-bottom, 0); }
.safe-top    { padding-top: env(safe-area-inset-top, 0); }

/* ── Touch-optimized list items ── */
.list-item-touch {
  min-height: 52px; display: flex; align-items: center;
  padding: 0.75rem 1rem; gap: 0.875rem;
  border-bottom: 1px solid var(--border-2);
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s;
  cursor: pointer;
}
.list-item-touch:active { background: var(--surface); }
.list-item-touch:last-child { border-bottom: none; }

/* ── Responsive stat cards ── */
.stats-grid-responsive {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
}
@media (max-width: 480px) {
  .stats-grid-responsive { grid-template-columns: 1fr 1fr; }
}

/* ── Full-width on mobile ── */
@media (max-width: 768px) {
  .mobile-full { width: 100% !important; }
  .mobile-stack { flex-direction: column !important; }
  .mobile-stack > * { width: 100% !important; }
  .mobile-p0 { padding: 0 !important; }
  .mobile-gap-sm { gap: 0.5rem !important; }
}

/* ── Compact topbar on mobile ── */
@media (max-width: 768px) {
  .topbar { padding: 0 1rem; }
  .topbar-user-name { display: none; }
  .ai-float-btn { bottom: 4.5rem; right: 1rem; width: 46px; height: 46px; font-size: 1.05rem; }
  .ai-float-panel { right: 1rem; bottom: 8rem; width: calc(100vw - 2rem); }
  .toast-container { bottom: 4.5rem; right: 0.75rem; left: 0.75rem; }
  .toast { max-width: 100%; }
}

/* ── Notch-aware sidebar overlay on mobile ── */
@media (max-width: 1024px) {
  .sb-overlay { padding-top: env(safe-area-inset-top, 0); }
}

/* ============================================================
   DASHBOARD LAYOUT SYSTEM — Mobile-first responsive overrides
   Applied globally; !important beats page-specific CSS
   ============================================================ */

/* ── Tablet (≤1024px): 2-column grids ── */
@media (max-width: 1024px) {
  /* 4-col stat grids → 2 col */
  .dash-stats,
  .stat-grid,
  .kpi-grid,
  .kpi-row,
  .metric-grid        { grid-template-columns: repeat(2, 1fr) !important; }

  /* Multi-column content rows → single column */
  .dash-row-2,
  .dash-row-3,
  .dash-row-4,
  .content-grid,
  .panel-grid         { grid-template-columns: 1fr !important; }
}

/* ── Mobile (≤768px): tight layout ── */
@media (max-width: 768px) {
  /* Stat cards: 2 columns on phone */
  .dash-stats,
  .stat-grid,
  .kpi-grid           { grid-template-columns: repeat(2, 1fr) !important; gap: 0.625rem !important; }

  /* All multi-col grids → single column */
  .dash-row-2,
  .dash-row-3,
  .dash-row-4,
  .db-grid,
  .content-grid,
  .panel-grid,
  .quick-actions      { grid-template-columns: 1fr !important; gap: 0.75rem !important; }

  /* Cards: compact padding */
  .dash-card,
  .dash-stat-card,
  .stat-card          { padding: 1rem !important; }

  /* Stat value sizes */
  .stat-val           { font-size: 1.25rem !important; }

  /* Tables: horizontal scroll */
  .table-wrap,
  .table-scroll,
  .table-container    { overflow-x: auto !important; -webkit-overflow-scrolling: touch !important; }
  .adm-table,
  .data-table,
  table               { min-width: 480px; }

  /* Tabs: horizontal scroll */
  .tab-bar,
  .tabs-bar,
  .filter-bar         { overflow-x: auto !important; -webkit-overflow-scrolling: touch !important; flex-wrap: nowrap !important; scrollbar-width: none; }
  .tab-bar::-webkit-scrollbar,
  .tabs-bar::-webkit-scrollbar,
  .filter-bar::-webkit-scrollbar { display: none; }

  /* Modal/sheet sizes */
  .modal-box,
  .modal-content      { width: calc(100vw - 2rem) !important; max-width: none !important; margin: 1rem !important; }

  /* AI float panel adapts */
  .ai-float-panel     { width: calc(100vw - 2rem) !important; right: 1rem !important; }

  /* Page headings */
  .page-header        { flex-direction: column !important; align-items: flex-start !important; gap: 0.75rem !important; }
  .page-title         { font-size: 1.25rem !important; }
}

/* ── Small phone (≤480px): single column everywhere ── */
@media (max-width: 480px) {
  .dash-stats,
  .stat-grid,
  .kpi-grid           { grid-template-columns: 1fr !important; }

  .quick-actions      { grid-template-columns: 1fr !important; }
}

/* ── Viewport meta: ensure no content clips on mobile ── */
html { -webkit-text-size-adjust: 100%; }

/* ── Image & media overflow guards ── */
img, video, iframe, canvas, svg { max-width: 100%; }

/* ── Responsive form fields ── */
@media (max-width: 768px) {
  input, textarea, select, .input { font-size: 16px !important; } /* prevent iOS zoom */
  .form-row         { flex-direction: column !important; gap: 0.75rem !important; }
  .form-row > *     { width: 100% !important; }
}
