/**
 * @fileoverview Base CSS — Reset, Typography & CSS Custom Properties
 * @description Mobile-first foundation cho Romexfloor SPC Vote App.
 *              Tất cả brand colors, spacing scale, và typography tokens
 *              được định nghĩa tại đây — các file CSS khác chỉ dùng var().
 *
 * Breakpoints:
 *   - Default:   mobile  (≤ 479px)
 *   - sm:        ≥ 480px
 *   - md:        ≥ 768px  (tablet)
 *   - lg:        ≥ 1024px (desktop / large screen leaderboard)
 */

/* ═══════════════════════════════════════════════
   1. CSS Custom Properties (Design Tokens)
   ═══════════════════════════════════════════════ */

:root {
  /* ── Brand Colors ── */
  --color-brand:       #1B4F8A;
  --color-brand-dark:  #153F6E;
  --color-brand-light: #2567AE;
  --color-accent:      #2E86C1;
  --color-accent-light:#5DADE2;
  --color-gold:        #B7950B;
  --color-gold-light:  #D4AC0D;

  /* ── Neutral Palette ── */
  --color-text:        #1A252F;
  --color-text-muted:  #5D6D7E;
  --color-text-light:  #AEB6BF;
  --color-bg:          #F8F9FA;
  --color-bg-card:     #FFFFFF;
  --color-border:      #D5D8DC;
  --color-border-light:#EAECEE;

  /* ── Feedback Colors ── */
  --color-success:     #27AE60;
  --color-error:       #E74C3C;
  --color-warning:     #F39C12;
  --color-info:        #3498DB;

  /* ── Typography ── */
  --font-primary:      'Inter', system-ui, -apple-system, BlinkMacSystemFont,
                        'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --font-mono:         'SF Mono', 'Fira Code', 'Cascadia Code', monospace;

  --text-xs:           0.75rem;   /* 12px */
  --text-sm:           0.875rem;  /* 14px */
  --text-base:         1rem;      /* 16px */
  --text-lg:           1.125rem;  /* 18px */
  --text-xl:           1.25rem;   /* 20px */
  --text-2xl:          1.5rem;    /* 24px */
  --text-3xl:          1.875rem;  /* 30px */

  --leading-tight:     1.25;
  --leading-normal:    1.5;
  --leading-relaxed:   1.75;

  --weight-normal:     400;
  --weight-medium:     500;
  --weight-semibold:   600;
  --weight-bold:       700;

  /* ── Spacing Scale (4px base) ── */
  --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 */

  /* ── Border Radius ── */
  --radius-sm:         0.375rem;  /*  6px */
  --radius-md:         0.5rem;    /*  8px */
  --radius-lg:         0.75rem;   /* 12px */
  --radius-xl:         1rem;      /* 16px */
  --radius-full:       9999px;

  /* ── Shadows ── */
  --shadow-sm:         0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md:         0 4px 6px -1px rgba(0, 0, 0, 0.08),
                       0 2px 4px -2px rgba(0, 0, 0, 0.06);
  --shadow-lg:         0 10px 15px -3px rgba(0, 0, 0, 0.10),
                       0 4px 6px -4px rgba(0, 0, 0, 0.06);
  --shadow-card:       0 2px 8px rgba(27, 79, 138, 0.08);

  /* ── Transitions ── */
  --ease-default:      cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast:     150ms;
  --duration-normal:   250ms;
  --duration-slow:     350ms;

  /* ── Layout ── */
  --container-max:     1200px;
  --container-padding: var(--space-4);
}


/* ═══════════════════════════════════════════════
   2. CSS Reset (Modern Minimal)
   ═══════════════════════════════════════════════ */

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

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

body {
  font-family: var(--font-primary);
  font-size: var(--text-base);
  font-weight: var(--weight-normal);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg, video {
  display: block;
  max-width: 100%;
  height: auto;
}

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

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

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

ul, ol {
  list-style: none;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
}


/* ═══════════════════════════════════════════════
   3. Typography Scale
   ═══════════════════════════════════════════════ */

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl);  }
h3 { font-size: var(--text-lg);  }

@media (min-width: 768px) {
  h1 { font-size: var(--text-3xl); }
  h2 { font-size: var(--text-2xl); }
  h3 { font-size: var(--text-xl);  }
}


/* ═══════════════════════════════════════════════
   4. Layout Utilities
   ═══════════════════════════════════════════════ */

.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-padding);
}

.page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.page__header {
  padding: var(--space-4) 0;
  text-align: center;
  background: var(--color-brand);
  color: #fff;
}

.page__content {
  flex: 1;
  padding: var(--space-6) 0;
}

/** Grid cho floor cards — 1 cột mobile, 2 tablet, 3 desktop */
.grid-floors {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 480px) {
  .grid-floors { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .grid-floors { grid-template-columns: repeat(3, 1fr); }
}


/* ═══════════════════════════════════════════════
   5. Common UI Primitives
   ═══════════════════════════════════════════════ */

/** Primary action button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  border-radius: var(--radius-md);
  transition: background-color var(--duration-fast) var(--ease-default),
              box-shadow var(--duration-fast) var(--ease-default);
}

.btn--primary {
  background: var(--color-brand);
  color: #fff;
}
.btn--primary:hover {
  background: var(--color-brand-dark);
  box-shadow: var(--shadow-md);
}
.btn--primary:active {
  background: var(--color-brand-dark);
  box-shadow: none;
}

.btn--accent {
  background: var(--color-accent);
  color: #fff;
}

.btn--outline {
  background: transparent;
  color: var(--color-brand);
  border: 2px solid var(--color-brand);
}

.btn--block {
  width: 100%;
}

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

/** Form inputs */
.input {
  display: block;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-card);
  transition: border-color var(--duration-fast) var(--ease-default),
              box-shadow var(--duration-fast) var(--ease-default);
}
.input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(46, 134, 193, 0.15);
}
.input--error {
  border-color: var(--color-error);
}

/** Inline field error */
.field-error {
  display: none;
  font-size: var(--text-sm);
  color: var(--color-error);
  margin-top: var(--space-1);
}
.field-error.visible {
  display: block;
}

/** Card surface */
.card {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

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