/* static/css/base.css */
@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=Sora:wght@400;500;600;700&display=swap");

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

:root {
  --bg: #0d1117; --surface: #161b22; --surface2: #1c2330; --surface3: #21262d;
  --border: rgba(240, 246, 252, 0.1); --border2: rgba(240, 246, 252, 0.2);
  --text: #e6edf3; --muted: #8b949e; --accent: #58a6ff; --accent2: #3fb950;
  --warn: #d29922; --danger: #f85149; --purple: #bc8cff; --cyan: #39d353;
  --font: "Sora", sans-serif; --mono: "JetBrains Mono", monospace;
  --radius: 8px; --radius-lg: 12px;
}

body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; }

/* GLOBAL LAYOUT */
.app { display: flex; height: 100vh; height: 100dvh; min-height: 600px; overflow: hidden; }
.main { flex: 1; overflow-y: auto; background: var(--bg); display: flex; flex-direction: column; }
.screen { padding: 24px 28px; flex: 1; }
.screen-content { width: 100%; max-width: 1200px; margin: 0 auto; }
.main:has(.app-layout) { overflow: hidden; }
.screen-content.app-layout { 
    display: flex; 
    flex-direction: column; 
    height: calc(100vh - 60px); 
    height: calc(100dvh - 60px); 
    overflow: hidden; 
    max-width: 1400px; 
}
.screen-content.app-layout .table-card, .screen-content.app-layout .problem-grid, .screen-content.app-layout .assessment-grid { flex: 1; min-height: 0; overflow-y: auto; overflow-x: auto; }
.screen-content.app-layout .page-header, .screen-content.app-layout .filter-card, .screen-content.app-layout .pagination, .screen-content.app-layout .card-header { flex-shrink: 0; }

/* HEADERS & TYPOGRAPHY */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; gap: 16px; }
.title-row { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.page-title { font-size: 22px; font-weight: 700; color: var(--text); }
.page-sub { font-size: 13px; color: var(--muted); margin-top: 3px; }
.count-badge { display: inline-flex; justify-content: center; align-items: center; padding: 2px 10px; background: rgba(88, 166, 255, 0.1); color: var(--accent); border: 1px solid rgba(88, 166, 255, 0.2); border-radius: 999px; font-size: 12px; font-weight: 600; font-family: var(--mono); }

.student-name { font-weight: 600; color: var(--text); font-size: 14px; }
.student-reg, .student-email { font-size: 12px; color: var(--muted); font-family: var(--mono); margin-top: 2px; }
.cohort-text { font-size: 13px; color: var(--text); font-weight: 500; }
.cohort-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.text-danger { color: var(--danger); font-size: 12px; margin-top: 4px; }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--radius); font-size: 13px; font-weight: 500; cursor: pointer; border: 1px solid; transition: all 0.15s; font-family: var(--font); white-space: nowrap; text-decoration: none; }
.btn-primary { background: var(--accent); color: #0d1117; border-color: var(--accent); } .btn-primary:hover { opacity: 0.88; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border2); } .btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-success { background: rgba(63, 185, 80, 0.12); color: var(--accent2); border-color: rgba(63, 185, 80, 0.3); }
.btn-danger { background: rgba(248, 81, 73, 0.1); color: var(--danger); border-color: rgba(248, 81, 73, 0.25); } .btn-danger:hover { background: rgba(248, 81, 73, 0.2); border-color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-xs { padding: 2px 8px; font-size: 11px; font-weight: 500; border-radius: 4px; }
.btn-block { width: 100%; justify-content: center; }

/* Hollow Action Buttons */
.btn-outline-green { background: transparent; border: 1px solid rgba(63, 185, 80, 0.4); color: #3fb950; }
.btn-outline-green:hover { background: rgba(63, 185, 80, 0.1); border-color: #3fb950; }
.btn-outline-muted { background: transparent; border: 1px solid rgba(139, 148, 158, 0.4); color: var(--muted); }
.btn-outline-muted:hover { border-color: var(--text); color: var(--text); }
.btn-outline-danger { background: transparent; border: 1px solid rgba(248, 81, 73, 0.4); color: var(--danger); }
.btn-outline-danger:hover { background: rgba(248, 81, 73, 0.1); border-color: var(--danger); }

/* FORMS & INPUTS */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; font-family: var(--mono); letter-spacing: 0.3px; }
.form-input, .form-select, .form-textarea { width: 100%; padding: 8px 12px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-family: var(--font); font-size: 13px; transition: border-color 0.15s; outline: none; }
.form-textarea { resize: vertical; min-height: 100px; font-family: var(--mono); font-size: 12px; }
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--accent); }
.form-select option { background: var(--surface2); }
.form-select optgroup { background: var(--surface3); color: var(--muted); font-weight: 700; font-style: normal; }
.form-select optgroup option { background: var(--surface2); color: var(--text); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }

/* FILTER SECTION */
.filter-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 18px; margin-bottom: 24px; }
.filter-form { display: flex; flex-wrap: nowrap; gap: 12px; align-items: center; overflow-x: auto; padding-bottom: 4px; }
.filter-form::-webkit-scrollbar { height: 6px; }
.filter-form::-webkit-scrollbar-track { background: transparent; }
.filter-form::-webkit-scrollbar-thumb { background: rgba(139, 148, 158, 0.3); border-radius: 10px; }
.filter-group { flex: 1; min-width: 150px; margin-bottom: 0; }
.filter-group.search-group { flex: 2; min-width: 250px; }

/* CARDS */
.card { background: linear-gradient(145deg, rgba(88, 166, 255, 0.05) 0%, var(--surface) 100%); border: 1px solid rgba(88, 166, 255, 0.15); border-radius: var(--radius-lg); overflow: hidden; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(88, 166, 255, 0.1); transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1); display: flex; flex-direction: column; }
.hover-card:hover { border-color: var(--accent); transform: translateY(-4px); box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3), 0 0 15px rgba(88, 166, 255, 0.15), inset 0 1px 0 rgba(88, 166, 255, 0.3); }
.card-header { padding: 14px 16px; border-bottom: 1px solid rgba(88, 166, 255, 0.15); font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent); background: rgba(88, 166, 255, 0.08); }
.card-header-flex { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: nowrap; }
.card-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; flex: 1; }
.card-footer { padding: 12px 16px; border-top: 1px solid rgba(88, 166, 255, 0.15); background: rgba(0, 0, 0, 0.2); display: flex; justify-content: flex-end; gap: 10px; }

/* =========================================
   PREMIUM DATA TABLES
   ========================================= */
.table-card { 
    background: var(--surface); 
    border: 1px solid var(--border); 
    border-radius: var(--radius-lg); 
    overflow-y: auto; 
    overflow-x: auto; 
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); 
    width: 100%; 
    flex: 1; 
    min-height: 0;
}
.table-card.flat { border: none; border-radius: 0; box-shadow: none; background: transparent; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; }

.data-table th { position: sticky; top: 0; z-index: 10; padding: 10px 18px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); border-bottom: 1px solid rgba(240, 246, 252, 0.06); background: var(--surface); font-family: var(--mono); }
.data-table td { padding: 10px 18px; border-bottom: 1px solid rgba(240, 246, 252, 0.06); vertical-align: middle; transition: background-color 0.15s ease; font-size: 13px; }
.data-table tr:hover td { background: rgba(255, 255, 255, 0.02); }

.clickable-row { cursor: pointer; }
.col-id { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.item-title { font-weight: 600; color: var(--text); font-size: 14px; }
.item-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.col-stats { font-family: var(--mono); font-size: 13px; color: var(--text); }

/* DASHBOARD GRIDS */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; align-items: stretch; }
.grid-66-33 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 20px; align-items: stretch; }

/* DASHBOARD WIDGETS: STATS */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }

.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 16px; }
.stat-label { font-size: 10.5px; color: var(--muted); font-family: var(--mono); letter-spacing: 0.5px; margin-bottom: 4px; }
.stat-value { font-size: 20px; font-weight: 700; font-family: var(--mono); line-height: 1.2; }
.stat-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.stat-blue { color: var(--accent); } .stat-green { color: var(--accent2); } .stat-purple { color: var(--purple); } .stat-warn { color: var(--warn); }

/* DASHBOARD WIDGETS: ASSESSMENTS LIST */
.assessments-list { padding: 12px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.contest-item { padding: 12px; border-radius: var(--radius); cursor: pointer; transition: border-color 0.15s ease; }
.active-item { background: rgba(88, 166, 255, 0.05); border: 1px solid rgba(88, 166, 255, 0.2); }
.active-item:hover { border-color: var(--accent); }
.upcoming-item { background: var(--surface2); border: 1px solid var(--border); }
.upcoming-item:hover { border-color: var(--border2); }
.item-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.contest-meta { font-size: 11.5px; color: var(--muted); }
.progress-container { margin-top: 6px; display: flex; align-items: center; gap: 10px; }
.progress-bar-wrap { flex: 1; background: var(--surface3); border-radius: 999px; height: 5px; overflow: hidden; box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2); }
.progress-bar { height: 100%; width: var(--progress, 0%); border-radius: 999px; background: var(--accent); transition: width 0.3s ease; }
.progress-text { font-size: 10.5px; color: var(--muted); font-family: var(--mono); }

/* DASHBOARD WIDGETS: ASSESSMENT GRID */
.assessment-grid { display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: max-content; gap: 20px; flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 4px 8px 24px 4px; align-content: start; }

/* =========================================
   PREMIUM BADGES & TAGS
   ========================================= */
.status-badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: uppercase; font-family: var(--mono); white-space: nowrap; }
.status-acc, .status-active { background: rgba(34, 197, 94, 0.15); color: #22c55e; border: 1px solid rgba(34, 197, 94, 0.25); }
.status-wa, .status-danger { background: rgba(239, 68, 68, 0.15); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.25); }
.status-upcoming, .status-re, .status-info { background: rgba(88, 166, 255, 0.15); color: #58a6ff; border: 1px solid rgba(88, 166, 255, 0.25); }
.status-past, .status-muted, .status-pen, .status-archived { background: rgba(148, 163, 184, 0.15); color: #94a3b8; border: 1px solid rgba(148, 163, 184, 0.25); }

/* Difficulty Capsules */
.badge-easy { color: #3fb950; background: rgba(63, 185, 80, 0.08); border: 1px solid rgba(63, 185, 80, 0.2); padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; font-family: var(--mono);}
.badge-medium { color: #d29922; background: rgba(210, 153, 34, 0.08); border: 1px solid rgba(210, 153, 34, 0.2); padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; font-family: var(--mono);}
.badge-hard { color: #f85149; background: rgba(248, 81, 73, 0.08); border: 1px solid rgba(248, 81, 73, 0.2); padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; font-family: var(--mono);}

/* Topic Tags */
.tag-badge { padding: 2px 10px; background: rgba(255, 255, 255, 0.03); color: var(--muted); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 999px; font-size: 10.5px; font-weight: 500; text-transform: uppercase; font-family: var(--mono); }

/* EMPTY STATES */
.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); background: var(--surface); border-radius: var(--radius-lg); border: 1px dashed var(--border); }
.empty-state-icon { font-size: 36px; margin-bottom: 10px; opacity: 0.6; }
.empty-state h3 { color: var(--text); font-size: 15px; margin-bottom: 4px; }
.empty-state p { font-size: 13px; }

/* ALERTS & MESSAGES */
.messages-container { padding: 20px 28px 0 28px; display: flex; flex-direction: column; gap: 10px; }
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 13px; border: 1px solid transparent; display: flex; align-items: center; justify-content: flex-start; gap: 10px; }
.alert-success { background: rgba(63, 185, 80, 0.15); color: #3fb950; border-color: rgba(63, 185, 80, 0.3); }
.alert-error, .alert-danger { background: rgba(248, 81, 73, 0.15); color: #f85149; border-color: rgba(248, 81, 73, 0.3); }
.alert-warning { background: rgba(210, 153, 34, 0.15); color: #d29922; border-color: rgba(210, 153, 34, 0.3); }
.alert-info { background: rgba(88, 166, 255, 0.15); color: #58a6ff; border-color: rgba(88, 166, 255, 0.3); }

/* PAGINATION */
.pagination { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 24px; }
.page-link { padding: 7px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); text-decoration: none; font-size: 13px; font-weight: 600; transition: all 0.15s ease; }
.page-link:hover { border-color: var(--accent); color: var(--accent); }
.page-current { font-size: 12px; color: var(--muted); font-family: var(--mono); }

/* FORM HELP TEXT */
.help-text { font-size: 11.5px; color: var(--muted); margin-top: 5px; line-height: 1.4; font-weight: 400; font-family: var(--font); }
.help-text-inline { font-size: 11px; color: var(--muted); font-weight: 400; font-family: var(--mono); }

/* UTILITIES & SCROLLBARS */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(139, 148, 158, 0.3); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(139, 148, 158, 0.6); }

.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1000; opacity: 0; pointer-events: none; transition: 0.2s; padding: 16px; }
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); width: 100%; max-width: 450px; box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5); transform: translateY(20px); transition: 0.2s; }
.modal-overlay.active .modal-card { transform: translateY(0); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; border-bottom: 1px solid var(--border); background: var(--surface); }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 24px; cursor: pointer; }
.modal-body { padding: 24px; }


/* =========================================
    RESPONSIVE BREAKPOINTS (ALL DEVICES)
   ========================================= */

/* Tablets and Smaller Laptops (max-width: 992px) */
@media (max-width: 992px) {
  .grid-66-33, .grid-2 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .assessment-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Mobile Devices and Small Tablets (max-width: 768px) */
@media (max-width: 768px) {
  .screen { 
    padding: 16px 16px 32px 16px; 
  }
  .screen-content.app-layout { 
    height: calc(100vh - 80px); 
    height: calc(100dvh - 80px); 
  }
  .messages-container { padding: 16px 16px 0 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: stretch; gap: 12px; }
  .card-header-flex { flex-wrap: wrap; gap: 12px; }
  
  /* Filter Form Fix: Smart Flexbox */
  .filter-form { 
      display: flex !important; 
      flex-wrap: wrap !important;
      gap: 12px; 
      padding-bottom: 4px;
  }
  .filter-group { 
      /* Try to take 50% width, but expand to 100% if sitting alone */
      flex: 1 1 calc(50% - 12px) !important; 
      min-width: 0 !important; 
      margin-bottom: 0; 
  }
  .filter-group.search-group { 
      /* Always force the search bar to 100% width */
      flex: 1 1 100% !important; 
  }
}

/* Small Mobile Phones (max-width: 500px) */
@media (max-width: 500px) {
  .stats-grid { grid-template-columns: 1fr; }
  .assessment-grid { grid-template-columns: 1fr; }
  body { font-size: 13.5px; }
  .page-title { font-size: 19px; }
}