/**
 * Material Design 3 Expressive Common Styles & Components
 * Edu Vanguard - Realtime Multiple-Choice Quiz Platform
 * Developed by DST Team Developers
 * (Typography: Quicksand | Emerald Forest MD3 Scheme)
 */

@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200');

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

html, body {
  width: 100%;
  height: 100%;
  font-family: var(--md-ref-typeface-plain);
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Material Symbols Rounded standard setup */
.material-symbols-round,
.material-symbols-rounded {
  font-family: 'Material Symbols Rounded' !important;
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  vertical-align: middle;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  user-select: none;
}

.material-symbols-round.filled,
.material-symbols-rounded.filled {
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.material-symbols-round.icon-sm { font-size: 18px; }
.material-symbols-round.icon-md { font-size: 24px; }
.material-symbols-round.icon-lg { font-size: 32px; }
.material-symbols-round.icon-xl { font-size: 48px; }

/* MD3 Typography Utilities */
.display-lg { font: var(--md-sys-typescale-display-large); }
.display-md { font: var(--md-sys-typescale-display-medium); }
.display-sm { font: var(--md-sys-typescale-display-small); }
.headline-lg { font: var(--md-sys-typescale-headline-large); }
.headline-md { font: var(--md-sys-typescale-headline-medium); }
.headline-sm { font: var(--md-sys-typescale-headline-small); }
.title-lg { font: var(--md-sys-typescale-title-large); }
.title-md { font: var(--md-sys-typescale-title-medium); }
.title-sm { font: var(--md-sys-typescale-title-small); }
.body-lg { font: var(--md-sys-typescale-body-large); }
.body-md { font: var(--md-sys-typescale-body-medium); }
.body-sm { font: var(--md-sys-typescale-body-small); }
.label-lg { font: var(--md-sys-typescale-label-large); }
.label-md { font: var(--md-sys-typescale-label-medium); }
.label-sm { font: var(--md-sys-typescale-label-small); }

/* MD3 Buttons */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 24px;
  border-radius: var(--md-shape-corner-full);
  font: var(--md-sys-typescale-label-large);
  text-decoration: none;
  border: none;
  cursor: pointer;
  outline: none;
  transition: background-color var(--md-motion-duration-short) ease,
              transform 100ms ease;
  user-select: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

.btn-filled {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}
.btn-filled:hover:not(:disabled) {
  background-color: #17533c;
}

.btn-tonal {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}
.btn-tonal:hover:not(:disabled) {
  background-color: #badcc6;
}

.btn-outlined {
  background-color: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-primary);
}
.btn-outlined:hover:not(:disabled) {
  background-color: var(--md-sys-color-surface-container-high);
}

.btn-text {
  background-color: transparent;
  color: var(--md-sys-color-primary);
  padding: 8px 16px;
  min-height: 40px;
}
.btn-text:hover:not(:disabled) {
  background-color: var(--md-sys-color-surface-container-low);
}

.btn-danger {
  background-color: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
}
.btn-danger:hover:not(:disabled) {
  background-color: #ffb4ab !important;
}

.btn-success {
  background-color: var(--md-sys-color-success-container);
  color: var(--md-sys-color-on-success-container);
}
.btn-success:hover:not(:disabled) {
  background-color: #8dd5b2;
}

.btn-lg {
  min-height: 48px;
  padding: 10px 24px;
  font-size: 15px;
  border-radius: var(--md-shape-corner-full);
}

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

.btn-icon {
  width: 40px;
  height: 40px;
  min-height: 40px;
  min-width: 40px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* User Account Pill in Top Navbar */
.user-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 14px 4px 6px;
  background-color: var(--md-sys-color-surface-container);
  border-radius: var(--md-shape-corner-full);
  border: none;
  cursor: pointer;
  color: var(--md-sys-color-on-surface);
  transition: background-color var(--md-motion-duration-short) ease;
  user-select: none;
}

.user-pill-btn:hover {
  background-color: var(--md-sys-color-surface-container-high);
}

.user-pill-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-pill-name {
  font: var(--md-sys-typescale-label-large);
  font-weight: 700;
  font-size: 14px;
}

/* Expandable Help FAB */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  min-width: 56px;
  height: 56px;
  border-radius: var(--md-shape-corner-large);
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  display: flex;
  align-items: center;
  border: none;
  cursor: pointer;
  z-index: 500;
  user-select: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  transition: transform var(--md-motion-duration-short) ease,
              background-color var(--md-motion-duration-short) ease;
}

.fab:active {
  transform: scale(0.96);
}

.fab-expandable {
  width: 56px;
  padding: 0;
  overflow: hidden;
  justify-content: center;
  transition: width var(--md-motion-duration-medium) var(--md-motion-easing-emphasized),
              padding var(--md-motion-duration-medium) var(--md-motion-easing-emphasized),
              background-color var(--md-motion-duration-short) ease;
}

.fab-expandable .fab-icon-box {
  min-width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fab-expandable .fab-text {
  font: var(--md-sys-typescale-label-large);
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  max-width: 0;
  overflow: hidden;
  transition: max-width var(--md-motion-duration-medium) var(--md-motion-easing-emphasized),
              opacity var(--md-motion-duration-short) ease;
}

.fab-expandable:hover {
  width: 140px;
  padding-right: 18px;
  background-color: #8dd5b2;
  justify-content: flex-start;
}

.fab-expandable:hover .fab-text {
  opacity: 1;
  max-width: 100px;
}

/* MD3 Input Fields */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.input-label {
  font: var(--md-sys-typescale-label-medium);
  color: var(--md-sys-color-on-surface-variant);
  font-weight: 600;
}

.input-field {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  background-color: var(--md-sys-color-surface-container-low);
  border: none;
  border-radius: var(--md-shape-corner-medium);
  font: var(--md-sys-typescale-body-large);
  font-family: inherit;
  color: var(--md-sys-color-on-surface);
  outline: none;
  transition: background-color var(--md-motion-duration-short) ease,
              box-shadow var(--md-motion-duration-short) ease;
}

.input-field:focus {
  background-color: var(--md-sys-color-surface-container-lowest);
  box-shadow: 0 0 0 2px var(--md-sys-color-primary);
}

.input-field.is-invalid {
  box-shadow: 0 0 0 2px var(--md-sys-color-error) !important;
  background-color: #fff8f8;
}

.input-field::placeholder {
  color: var(--md-sys-color-outline);
}

textarea.input-field {
  min-height: 80px;
  resize: vertical;
}

/* MD3 Custom Select Wrapper (Material Symbols Round Arrow) */
.select-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.select-wrapper select.input-field {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 42px;
  cursor: pointer;
  background-color: var(--md-sys-color-surface-container-low);
}

.select-wrapper .select-arrow-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 24px;
  line-height: 1;
}

/* MD3 True Spec Checkbox (Icon-Only, Clean Touch Area) */
.m3-checkbox-label {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  user-select: none;
  transition: background-color var(--md-motion-duration-short) ease;
}

.m3-checkbox-label:hover {
  background-color: rgba(32, 106, 77, 0.08);
}

.m3-checkbox-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
}

.m3-checkbox-custom {
  width: 18px;
  height: 18px;
  min-width: 18px;
  border-radius: 2px;
  border: 2px solid var(--md-sys-color-outline);
  background-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--md-motion-duration-short) cubic-bezier(0.2, 0, 0, 1);
  color: transparent;
}

.m3-checkbox-input:checked + .m3-checkbox-custom {
  background-color: var(--md-sys-color-primary);
  border-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.m3-checkbox-custom .material-symbols-round {
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
}

/* Dropdown Menu Container with Smooth Enter & Exit Animations */
.menu-anchor {
  position: relative;
  display: inline-flex;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background-color: var(--md-sys-color-surface-container-lowest);
  border-radius: var(--md-shape-corner-medium);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  padding: 6px;
  min-width: 210px;
  display: none;
  flex-direction: column;
  gap: 2px;
  z-index: 150;
  transform-origin: top right;
}

.dropdown-menu.active {
  display: flex;
  animation: menuIn 160ms cubic-bezier(0.05, 0.7, 0.1, 1.0) forwards;
}

.dropdown-menu.closing {
  display: flex;
  animation: menuOut 140ms cubic-bezier(0.3, 0, 0.8, 0.15) forwards;
}

@keyframes menuIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes menuOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-8px) scale(0.95); }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--md-shape-corner-small);
  background: transparent;
  border: none;
  color: var(--md-sys-color-on-surface);
  font: var(--md-sys-typescale-body-medium);
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background-color var(--md-motion-duration-short) ease;
}

.dropdown-item:hover {
  background-color: var(--md-sys-color-surface-container-low);
}

.dropdown-item.text-danger {
  color: var(--md-sys-color-error);
}

.dropdown-item.text-danger:hover {
  background-color: var(--md-sys-color-error-container);
}

/* MD3 Cards (Flat Tonal - No Shadow, No Border) */
.card {
  background-color: var(--md-sys-color-surface-container-lowest);
  border-radius: var(--md-shape-corner-extra-large);
  padding: 24px;
  border: none;
  box-shadow: none;
}

.card-tonal {
  background-color: var(--md-sys-color-surface-container-low);
}

/* MD3 Chips & Badges */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--md-shape-corner-small);
  font: var(--md-sys-typescale-label-medium);
  background-color: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface-variant);
  border: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--md-shape-corner-full);
  font: var(--md-sys-typescale-label-small);
  font-weight: 700;
  border: none;
}

.badge-primary {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

.badge-success {
  background-color: var(--md-sys-color-success-container);
  color: var(--md-sys-color-on-success-container);
}

.badge-error {
  background-color: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
}

.badge-warning {
  background-color: var(--md-sys-color-warning-container);
  color: var(--md-sys-color-on-warning-container);
}

/* Dialog & Modal (Flat Tonal) */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(23, 29, 25, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--md-motion-duration-medium) ease,
              visibility var(--md-motion-duration-medium) ease;
  padding: 20px;
}

.dialog-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.dialog {
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  background-color: var(--md-sys-color-surface-container-lowest);
  border-radius: var(--md-shape-corner-extra-large);
  border: none;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform var(--md-motion-duration-medium) var(--md-motion-easing-emphasized-decelerate);
}

.dialog-lg {
  max-width: 920px;
}

.dialog-sm {
  max-width: 440px;
}

.dialog-backdrop.active .dialog {
  transform: scale(1);
}

.dialog-header {
  padding: 18px 24px 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--md-sys-color-surface-container-low);
}

.dialog-body {
  padding: 22px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background-color: var(--md-sys-color-surface-container-lowest);
  flex: 1;
}

.dialog-footer {
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  background-color: var(--md-sys-color-surface-container-low);
}

/* MD3 Toast / Snackbar with Zero Jitter & Pulse Updates */
#snackbar-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 2000;
  pointer-events: none;
  width: auto;
  max-width: 90vw;
}

.snackbar {
  width: max-content;
  max-width: 90vw;
  background-color: var(--md-sys-color-inverse-surface);
  color: var(--md-sys-color-inverse-on-surface);
  padding: 12px 20px;
  border-radius: var(--md-shape-corner-full);
  display: flex;
  align-items: center;
  gap: 12px;
  font: var(--md-sys-typescale-body-medium);
  font-weight: 600;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  animation: snackbarIn 240ms cubic-bezier(0.05, 0.7, 0.1, 1.0) forwards;
  pointer-events: auto;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

@keyframes snackbarIn {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes snackbarPulse {
  0% { transform: translateY(0) scale(0.96); }
  50% { transform: translateY(-2px) scale(1.02); }
  100% { transform: translateY(0) scale(1); }
}

.snackbar.fade-out {
  animation: snackbarOut 200ms cubic-bezier(0.3, 0, 0.8, 0.15) forwards;
}

@keyframes snackbarOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
}

/* Content Formatting (HTML & Images inside Questions) */
.rich-content {
  font-family: inherit;
  line-height: 1.6;
}

.rich-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--md-shape-corner-medium);
  margin: 8px 0;
  display: block;
}

.rich-content pre,
.rich-content code {
  font-family: var(--md-ref-typeface-code);
  background-color: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
  border-radius: var(--md-shape-corner-small);
  padding: 2px 6px;
  font-size: 0.9em;
}

.rich-content pre {
  padding: 12px;
  overflow-x: auto;
  margin: 8px 0;
}

.rich-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
}

.rich-content th,
.rich-content td {
  padding: 8px 12px;
  text-align: left;
}

.rich-content th {
  background-color: var(--md-sys-color-surface-container);
}

.rich-content td {
  background-color: var(--md-sys-color-surface-container-low);
}
