/* ============================================================
   DESIGN SYSTEM — Website Học Tập Đại Học
   Môn: Thiết Kế Web — ĐH Hùng Vương
   ============================================================ */

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

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

body {
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

/* ---------- CSS Custom Properties ---------- */
:root {
  /* --- Color Palette --- */

  /* Primary: Navy Blue — Đại học Hùng Vương, học thuật */
  --color-primary-50: #E8EDF7;
  --color-primary-100: #C5D1EC;
  --color-primary-200: #9EB3E0;
  --color-primary-300: #7795D3;
  --color-primary-400: #5A7EC9;
  --color-primary-500: #3D67BF;
  --color-primary-600: #2E52A3;
  --color-primary-700: #1E3D87;
  --color-primary-800: #0F2D6B;
  --color-primary-900: #0A2463;
  --color-primary: var(--color-primary-900);

  /* Secondary: Hùng Vương Red — Logo, truyền thống */
  --color-secondary-50: #FDEAEA;
  --color-secondary-100: #F8C0C0;
  --color-secondary-200: #F19696;
  --color-secondary-300: #EB6C6C;
  --color-secondary-400: #E74D4D;
  --color-secondary-500: #E53935;
  --color-secondary-600: #D32F2F;
  --color-secondary-700: #C62828;
  --color-secondary-800: #B71C1C;
  --color-secondary-900: #8E0000;
  --color-secondary: var(--color-secondary-500);

  /* Accent: Cobalt Blue — Chuyển đổi số, công nghệ */
  --color-accent-50: #E3F0FF;
  --color-accent-100: #B3D4FF;
  --color-accent-200: #80B8FF;
  --color-accent-300: #4D9CFF;
  --color-accent-400: #2687FF;
  --color-accent-500: #0070F3;
  --color-accent-600: #005FCC;
  --color-accent-700: #004EA6;
  --color-accent-800: #003D80;
  --color-accent-900: #002B59;
  --color-accent: var(--color-accent-500);

  /* Semantic Colors */
  --color-success-50: #E8F8EC;
  --color-success-100: #B8EBCA;
  --color-success-500: #2DC653;
  --color-success-700: #1E8A3A;
  --color-success: var(--color-success-500);

  --color-error-50: #FCE8EA;
  --color-error-100: #F5B8BD;
  --color-error-500: #E63946;
  --color-error-700: #A32831;
  --color-error: var(--color-error-500);

  --color-warning-50: #FFF3E0;
  --color-warning-500: #FF9800;
  --color-warning-700: #E65100;
  --color-warning: var(--color-warning-500);

  --color-info-50: #E3F2FD;
  --color-info-500: #2196F3;
  --color-info-700: #1565C0;
  --color-info: var(--color-info-500);

  /* Neutrals: Warm Gray */
  --color-neutral-0: #FFFFFF;
  --color-neutral-50: #F8F9FA;
  --color-neutral-100: #F1F3F5;
  --color-neutral-200: #E9ECEF;
  --color-neutral-300: #DEE2E6;
  --color-neutral-400: #CED4DA;
  --color-neutral-500: #ADB5BD;
  --color-neutral-600: #868E96;
  --color-neutral-700: #495057;
  --color-neutral-800: #343A40;
  --color-neutral-900: #212529;

  /* Semantic Mappings */
  --bg-primary: var(--color-neutral-50);
  --bg-secondary: var(--color-neutral-0);
  --bg-tertiary: var(--color-neutral-100);
  --bg-sidebar: var(--color-primary-900);
  --bg-sidebar-hover: rgba(255, 255, 255, 0.08);
  --bg-sidebar-active: rgba(255, 255, 255, 0.15);
  --bg-card: var(--color-neutral-0);
  --bg-code: var(--color-neutral-900);
  --bg-code-inline: var(--color-neutral-100);

  --text-primary: var(--color-neutral-900);
  --text-secondary: var(--color-neutral-700);
  --text-tertiary: var(--color-neutral-600);
  --text-disabled: var(--color-neutral-400);
  --text-inverse: var(--color-neutral-0);
  --text-link: var(--color-primary-600);
  --text-link-hover: var(--color-primary-800);

  --border-color: var(--color-neutral-200);
  --border-color-strong: var(--color-neutral-300);
  --border-focus: var(--color-primary-500);

  /* shadcn-inspired Semantic Tokens */
  --background: var(--color-neutral-0);
  --foreground: var(--color-neutral-900);
  --muted: var(--color-neutral-100);
  --muted-foreground: var(--color-neutral-500);
  --card: var(--color-neutral-0);
  --card-foreground: var(--color-neutral-900);
  --popover: var(--color-neutral-0);
  --popover-foreground: var(--color-neutral-900);
  --input: var(--color-neutral-200);
  --ring: var(--color-primary-500);

  /* --- Typography --- */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;

  /* Type Scale: Major Third (1.25) */
  --text-xs: 0.64rem;     /* 10.24px */
  --text-sm: 0.8rem;      /* 12.8px */
  --text-base: 1rem;      /* 16px */
  --text-md: 1.125rem;    /* 18px */
  --text-lg: 1.25rem;     /* 20px */
  --text-xl: 1.563rem;    /* 25px */
  --text-2xl: 1.953rem;   /* 31.25px */
  --text-3xl: 2.441rem;   /* 39px */
  --text-4xl: 3.052rem;   /* 48.8px */
  --text-5xl: 3.815rem;   /* 61px */

  /* Font Weights */
  --font-light: 300;
  --font-regular: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;
  --font-extrabold: 800;

  /* Line Heights */
  --leading-none: 1;
  --leading-tight: 1.25;
  --leading-snug: 1.375;
  --leading-normal: 1.6;
  --leading-relaxed: 1.75;
  --leading-loose: 2;

  /* Letter Spacing */
  --tracking-tight: -0.025em;
  --tracking-normal: 0;
  --tracking-wide: 0.025em;
  --tracking-wider: 0.05em;

  /* --- Spacing (8-point grid) --- */
  --space-0: 0;
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */
  --space-20: 5rem;     /* 80px */
  --space-24: 6rem;     /* 96px */

  /* --- Borders --- */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  --border-thin: 1px solid var(--border-color);
  --border-medium: 2px solid var(--border-color);

  /* --- Shadows --- */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.18);
  --shadow-inner: inset 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-focus: 0 0 0 3px rgba(10, 36, 99, 0.15);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.06);
  --shadow-card-hover: 0 4px 12px rgba(0,0,0,0.08), 0 8px 24px rgba(0,0,0,0.1);

  /* --- Transitions --- */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 350ms ease;
  --transition-spring: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* --- Z-Index --- */
  --z-base: 0;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-sidebar: 300;
  --z-overlay: 400;
  --z-modal: 500;
  --z-toast: 600;
  --z-tooltip: 700;

  /* --- Layout --- */
  --sidebar-width: 280px;
  --sidebar-collapsed: 64px;
  --header-height: 64px;
  --content-max-width: 900px;
  --toc-width: 240px;
}

/* ---------- Dark Mode ---------- */
[data-theme="dark"] {
  --bg-primary: #0F1419;
  --bg-secondary: #1A1F2E;
  --bg-tertiary: #232A3B;
  --bg-sidebar: #0D1117;
  --bg-sidebar-hover: rgba(255, 255, 255, 0.06);
  --bg-sidebar-active: rgba(255, 255, 255, 0.12);
  --bg-card: #1A1F2E;
  --bg-code: #0D1117;
  --bg-code-inline: #232A3B;

  --text-primary: #E6EDF3;
  --text-secondary: #B1BAC4;
  --text-tertiary: #8B949E;
  --text-disabled: #484F58;
  --text-inverse: #0F1419;
  --text-link: var(--color-accent-300);
  --text-link-hover: var(--color-accent-200);

  --border-color: #30363D;
  --border-color-strong: #484F58;
  --border-focus: var(--color-accent-400);

  /* shadcn dark tokens */
  --background: #0F1419;
  --foreground: #E6EDF3;
  --muted: #232A3B;
  --muted-foreground: #8B949E;
  --card: #1A1F2E;
  --card-foreground: #E6EDF3;
  --popover: #1A1F2E;
  --popover-foreground: #E6EDF3;
  --input: #30363D;
  --ring: var(--color-accent-400);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.2), 0 4px 12px rgba(0,0,0,0.3);
  --shadow-card-hover: 0 4px 12px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.4);
  --shadow-focus: 0 0 0 3px rgba(0, 112, 243, 0.25);
}

/* ---------- Base Styles ---------- */
body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--font-regular);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  transition: background-color var(--transition-base), color var(--transition-base);
}

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
}

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

p {
  color: var(--text-secondary);
  max-width: 72ch;
}

strong {
  font-weight: var(--font-semibold);
}

small {
  font-size: var(--text-sm);
}

/* ---------- Links ---------- */
a:not(.btn) {
  color: var(--text-link);
  transition: color var(--transition-fast);
}

a:not(.btn):hover {
  color: var(--text-link-hover);
}

/* ---------- Code ---------- */
code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-code-inline);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-xs);
  font-weight: var(--font-medium);
}

pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: var(--bg-code);
  color: #E6EDF3;
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  overflow-x: auto;
  line-height: var(--leading-relaxed);
  border: 1px solid var(--border-color);
}

pre code {
  background: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
}

/* ---------- Selection ---------- */
::selection {
  background: var(--color-primary-200);
  color: var(--color-primary-900);
}

[data-theme="dark"] ::selection {
  background: var(--color-secondary-700);
  color: var(--color-neutral-0);
}

/* ---------- Scrollbar (Ultra-thin, shadcn-style) ---------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--color-neutral-300);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-neutral-400);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: var(--color-neutral-700);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: var(--color-neutral-600);
}

/* ---------- Focus Styles (shadcn ring) ---------- */
:focus-visible {
  outline: 2px solid var(--ring, var(--border-focus));
  outline-offset: 2px;
}

/* Remove default focus ring on buttons — use ring variable instead */
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--background, #fff), 0 0 0 4px var(--ring, var(--border-focus));
}

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Utility Classes ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.font-mono { font-family: var(--font-mono); }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

.hidden { display: none !important; }
.block { display: block; }
.inline-block { display: inline-block; }

.w-full { width: 100%; }

.relative { position: relative; }
.absolute { position: absolute; }

.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
