/* ==========================================================================
   Quản lý hoạt động Thí nghiệm Vật lý — Stylesheet
   Ưu tiên điện thoại cho Sinh viên (YC60) & màn hình rộng cho Giảng viên (YC61)
   Phân biệt rõ màu sắc nhóm thao tác (YC63)
   ========================================================================== */

:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #cbd5e1;
  --border-light: #e2e8f0;
  --text: #0f172a;
  --text-muted: #475569;

  --primary: #1d4ed8;
  --primary-dark: #1e3a8a;
  --primary-soft: #eff6ff;

  --success: #047857;
  --success-soft: #ecfdf5;
  --warning: #b45309;
  --warning-soft: #fffbeb;
  --purple: #6d28d9;
  --purple-soft: #f5f3ff;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 28px rgba(15, 23, 42, 0.14);
}

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

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
  color: #ffffff;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.18);
}

.header-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #38bdf8, #2563eb);
  color: #ffffff;
  font-weight: 800;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.5px;
}

.brand-title {
  font-weight: 700;
  font-size: 16px;
  line-height: 1.25;
}

.brand-sub {
  font-size: 12px;
  color: #cbd5e1;
}

.header-user-area {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.12);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
}

.app-main {
  flex: 1;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 16px;
}

.app-footer {
  background: #ffffff;
  border-top: 1px solid var(--border-light);
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.card-title {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.card-subtitle {
  margin: -6px 0 14px;
  font-size: 13px;
  color: var(--text-muted);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--primary-dark);
  line-height: 1.2;
}

.stat-note {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.session-hero {
  border-radius: 14px;
  padding: 18px 20px;
  color: #ffffff;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(30, 58, 138, 0.2);
}

.session-hero.upcoming {
  background: linear-gradient(135deg, #1d4ed8 0%, #0284c7 100%);
}

.session-hero.ongoing {
  background: linear-gradient(135deg, #047857 0%, #0d9488 100%);
}

.session-hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.session-hero-label {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.2);
  padding: 4px 10px;
  border-radius: 999px;
}

.badge-updated {
  background: #fef08a;
  color: #854d0e;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}

.session-hero-time {
  font-size: 20px;
  font-weight: 800;
  margin: 6px 0;
}

.session-hero-countdown {
  display: inline-block;
  background: rgba(15, 23, 42, 0.28);
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  margin-top: 4px;
}

.alert {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  border-left: 4px solid transparent;
  font-size: 14px;
}

.alert-danger {
  background: var(--danger-soft);
  border-left-color: var(--danger);
  color: #7f1d1d;
}

.alert-warning {
  background: var(--warning-soft);
  border-left-color: var(--warning);
  color: #78350f;
}

.alert-success {
  background: var(--success-soft);
  border-left-color: var(--success);
  color: #064e3b;
}

.alert-info {
  background: var(--primary-soft);
  border-left-color: var(--primary);
  color: #1e3a8a;
}

.praise-card {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 1px solid #fcd34d;
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}

.praise-title {
  font-weight: 800;
  font-size: 16px;
  color: #92400e;
  margin-bottom: 4px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease, opacity 0.15s ease;
  text-align: center;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-sm {
  min-height: 36px;
  padding: 5px 11px;
  font-size: 13px;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-success {
  background: var(--success);
  color: #ffffff;
}
.btn-success:hover:not(:disabled) { background: #065f46; }

.btn-warning {
  background: #d97706;
  color: #ffffff;
}
.btn-warning:hover:not(:disabled) { background: var(--warning); }

.btn-purple {
  background: var(--purple);
  color: #ffffff;
}
.btn-purple:hover:not(:disabled) { background: #5b21b6; }

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}
.btn-danger:hover:not(:disabled) { background: #991b1b; }

.btn-outline {
  background: #ffffff;
  color: var(--text);
  border-color: var(--border);
}
.btn-outline:hover:not(:disabled) { background: var(--surface-alt); }

.btn-ghost-light {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.25);
}
.btn-ghost-light:hover:not(:disabled) { background: rgba(255, 255, 255, 0.24); }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-muted { background: #e2e8f0; color: #334155; }

.tabs-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  background: var(--surface);
  padding: 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.tab-btn {
  min-height: 40px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.tab-btn.active {
  background: var(--primary);
  color: #ffffff;
}

.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.input, .select, .textarea {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: #ffffff;
}

.textarea {
  min-height: 90px;
  resize: vertical;
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.14);
}

.input-sm {
  min-height: 36px;
  padding: 5px 8px;
  font-size: 13px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: #ffffff;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

table.data-table th, table.data-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border-light);
  text-align: left;
  vertical-align: middle;
}

table.data-table th {
  background: #f8fafc;
  color: #1e293b;
  font-weight: 700;
  white-space: nowrap;
}

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

.cell-lowest {
  background: #fef2f2 !important;
  color: #b91c1c;
  font-weight: 800;
}

.progress-track {
  width: 100%;
  height: 10px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #0d9488);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.quiz-question-card {
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  background: #ffffff;
}

.quiz-q-header {
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
  background: #ffffff;
  min-height: 46px;
}

.quiz-option:hover {
  border-color: #93c5fd;
  background: #f8fafc;
}

.quiz-option.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.quiz-option.correct {
  border-color: var(--success);
  background: var(--success-soft);
}

.quiz-option.wrong {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.quiz-option input[type="radio"] {
  margin-top: 4px;
  transform: scale(1.2);
  flex-shrink: 0;
}

.math-content {
  overflow-wrap: break-word;
  word-break: break-word;
}

.math-content .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0;
}

.explanation-box {
  margin-top: 10px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  border-left: 3px solid var(--primary);
  font-size: 14px;
}

.rubric-block {
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
  background: #ffffff;
}

.rubric-level {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  margin-top: 8px;
  cursor: pointer;
  min-height: 46px;
}

.rubric-level.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.login-container {
  max-width: 500px;
  margin: 32px auto;
  text-align: center;
}

.google-btn-wrap {
  display: flex;
  justify-content: center;
  margin: 20px 0;
  min-height: 44px;
}

.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 16px;
  color: var(--text-muted);
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3.5px solid #cbd5e1;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  margin-bottom: 12px;
}

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

.toast-container {
  position: fixed;
  top: 72px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(400px, calc(100vw - 32px));
}

.toast {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  color: #ffffff;
  font-size: 14px;
  font-weight: 500;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: #b45309; }
.toast-info { background: var(--primary); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.56);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-box {
  background: #ffffff;
  border-radius: 14px;
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
  box-shadow: var(--shadow-lg);
}

.modal-box.modal-lg {
  max-width: 960px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
}

.mobile-bottom-nav {
  display: none;
}

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

@media (max-width: 640px) {
  .app-main { padding: 12px 10px 84px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .brand-title { font-size: 14.5px; }
  .card { padding: 14px; }
  .session-hero-time { font-size: 17px; }
  .student-desktop-tabs { display: none; }

  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ffffff;
    border-top: 1px solid var(--border);
    z-index: 60;
    padding: 4px 4px env(safe-area-inset-bottom, 6px);
    box-shadow: 0 -2px 10px rgba(15, 23, 42, 0.08);
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 54px;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 2px;
    border-radius: 8px;
  }

  .mobile-nav-item.active {
    color: var(--primary);
    background: var(--primary-soft);
  }

  .mobile-nav-icon {
    font-size: 18px;
    line-height: 1.2;
    margin-bottom: 2px;
  }
}
