/* ============================================================
   Exceed Technology VoIP Readiness Test — Stylesheet
   ============================================================ */

:root {
  --blue:       #0057B8;
  --blue-dark:  #003d82;
  --blue-light: #e8f0fb;
  --green:      #1a7a4a;
  --green-bg:   #e8f5ee;
  --amber:      #92600a;
  --amber-bg:   #fef3e2;
  --red:        #b91c1c;
  --red-bg:     #fef2f2;
  --gray-50:    #f8f9fa;
  --gray-100:   #f1f3f5;
  --gray-200:   #e9ecef;
  --gray-400:   #adb5bd;
  --gray-600:   #6c757d;
  --gray-800:   #343a40;
  --gray-900:   #212529;
  --white:      #ffffff;
  --radius:     10px;
  --radius-lg:  16px;
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 12px rgba(0,0,0,.1);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ──────────────────────────────────────────────── */
.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand { display: flex; align-items: center; gap: .75rem; }
.brand-icon { width: 40px; height: 40px; flex-shrink: 0; }
.brand-name { font-size: 1rem; font-weight: 700; color: var(--blue); line-height: 1.1; }
.brand-tagline { font-size: .7rem; color: var(--gray-600); text-transform: uppercase; letter-spacing: .06em; }

.header-nav { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.nav-link {
  font-size: .85rem; color: var(--gray-600); text-decoration: none;
  padding: .35rem .75rem; border-radius: 6px; transition: all .15s;
}
.nav-link:hover { background: var(--gray-100); color: var(--gray-900); }
.nav-link.active { color: var(--blue); font-weight: 600; }

/* ── Layout ─────────────────────────────────────────────── */
.main { flex: 1; padding: 2rem 0; }
.container { max-width: 800px; margin: 0 auto; padding: 0 1.25rem; }

/* ── Cards ──────────────────────────────────────────────── */
.intro-card, .test-card, .progress-card, .results-card,
.passcode-card, .table-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.intro-card h1 { font-size: 1.4rem; font-weight: 700; color: var(--gray-900); margin-bottom: .5rem; }
.intro-card p  { color: var(--gray-600); margin-bottom: .5rem; }
.intro-note    { font-size: .85rem; background: var(--blue-light); color: var(--blue-dark);
                 padding: .6rem .9rem; border-radius: 6px; border-left: 3px solid var(--blue); margin-top: .75rem !important; }

/* ── Form ───────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

.form-group label { display: block; font-size: .8rem; font-weight: 600;
                    color: var(--gray-600); margin-bottom: .35rem; text-transform: uppercase; letter-spacing: .04em; }
.optional { font-weight: 400; color: var(--gray-400); text-transform: none; }

input[type="text"], input[type="password"] {
  width: 100%; padding: .6rem .85rem; font-size: .95rem;
  border: 1.5px solid var(--gray-200); border-radius: var(--radius);
  background: var(--gray-50); color: var(--gray-900);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
input[type="text"]:focus, input[type="password"]:focus {
  border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,87,184,.12);
  background: var(--white);
}

.options-row { display: flex; gap: 1.5rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.toggle-label { display: flex; align-items: center; gap: .6rem; cursor: pointer;
                font-size: .9rem; color: var(--gray-700); user-select: none; }
.toggle-label input[type="checkbox"] { display: none; }

.toggle-track {
  width: 38px; height: 22px; background: var(--gray-300); border-radius: 11px;
  position: relative; transition: background .2s; flex-shrink: 0;
}
.toggle-thumb {
  width: 16px; height: 16px; background: var(--white); border-radius: 50%;
  position: absolute; top: 3px; left: 3px; transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle-label input:checked + .toggle-track { background: var(--blue); }
.toggle-label input:checked + .toggle-track .toggle-thumb { transform: translateX(16px); }

/* ── Buttons ────────────────────────────────────────────── */
.btn-run {
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  width: 100%; padding: .85rem 1.5rem; font-size: 1rem; font-weight: 700;
  background: var(--blue); color: var(--white); border: none;
  border-radius: var(--radius); cursor: pointer; transition: all .15s;
  letter-spacing: .02em;
}
.btn-run:hover:not(:disabled) { background: var(--blue-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-run:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-primary {
  padding: .45rem 1rem; font-size: .85rem; font-weight: 600;
  background: var(--blue); color: var(--white); border: none;
  border-radius: 8px; cursor: pointer; transition: background .15s; text-decoration: none; display: inline-block;
}
.btn-primary:hover { background: var(--blue-dark); }

.btn-secondary {
  padding: .45rem 1rem; font-size: .85rem; font-weight: 500;
  background: var(--white); color: var(--gray-700);
  border: 1.5px solid var(--gray-200); border-radius: 8px;
  cursor: pointer; transition: all .15s;
}
.btn-secondary:hover:not(:disabled) { border-color: var(--gray-400); background: var(--gray-50); }
.btn-secondary:disabled { opacity: .45; cursor: not-allowed; }

/* ── Progress ───────────────────────────────────────────── */
.progress-header { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; font-weight: 600; color: var(--gray-700); }
.spinner { width: 20px; height: 20px; border: 2.5px solid var(--gray-200); border-top-color: var(--blue);
           border-radius: 50%; animation: spin .7s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

.progress-bar { height: 6px; background: var(--gray-100); border-radius: 3px; overflow: hidden; margin-bottom: 1.25rem; }
.progress-fill { height: 100%; background: var(--blue); border-radius: 3px; width: 0%; transition: width .4s ease; }

.probe-steps { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
@media (max-width: 480px) { .probe-steps { grid-template-columns: 1fr; } }
.probe-step { font-size: .85rem; color: var(--gray-500); padding: .3rem .5rem; border-radius: 6px; transition: all .2s; }
.probe-step.running { color: var(--blue); font-weight: 600; }
.probe-step.done    { color: var(--green); }
.probe-step.failed  { color: var(--red); }

/* ── MOS Score Display ──────────────────────────────────── */
.mos-hero {
  display: flex; align-items: center; gap: 1.5rem;
  padding: 1.5rem; border-radius: var(--radius);
  margin-bottom: 1.5rem;
}
.mos-hero.grade-good   { background: var(--green-bg); border: 1px solid #a7d7b8; }
.mos-hero.grade-fair   { background: var(--amber-bg); border: 1px solid #f3c87e; }
.mos-hero.grade-poor   { background: var(--red-bg);   border: 1px solid #fca5a5; }

.mos-score-big {
  font-size: 3.5rem; font-weight: 800; line-height: 1; min-width: 90px; text-align: center;
}
.mos-hero.grade-good .mos-score-big { color: var(--green); }
.mos-hero.grade-fair .mos-score-big { color: var(--amber); }
.mos-hero.grade-poor .mos-score-big { color: var(--red); }

.mos-info { flex: 1; }
.mos-label    { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--gray-500); margin-bottom: .2rem; }
.mos-verdict  { font-size: 1.2rem; font-weight: 700; margin-bottom: .25rem; }
.mos-perceive { font-size: .9rem; color: var(--gray-600); }
.mos-r        { font-size: .8rem; color: var(--gray-500); margin-top: .25rem; }

/* ── Metrics Grid ───────────────────────────────────────── */
.metrics-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .75rem; margin-bottom: 1.5rem;
}
.metric-tile {
  background: var(--gray-50); border: 1px solid var(--gray-200);
  border-radius: var(--radius); padding: .9rem 1rem;
}
.metric-tile .mt-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
                          color: var(--gray-500); margin-bottom: .3rem; font-weight: 600; }
.metric-tile .mt-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; color: var(--gray-900); }
.metric-tile .mt-unit  { font-size: .75rem; color: var(--gray-500); font-weight: 400; margin-left: .15rem; }
.metric-tile .mt-status { font-size: .75rem; margin-top: .2rem; font-weight: 600; }
.mt-status.good { color: var(--green); }
.mt-status.warn { color: var(--amber); }
.mt-status.bad  { color: var(--red); }
.mt-status.skip { color: var(--gray-400); }

/* ── Check List ─────────────────────────────────────────── */
.section-title { font-size: .85rem; font-weight: 700; text-transform: uppercase;
                 letter-spacing: .06em; color: var(--gray-500); margin-bottom: .75rem; }

.check-list { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1.5rem; }
.check-item {
  display: flex; gap: .85rem; align-items: flex-start;
  padding: .75rem; border-radius: var(--radius);
  border: 1px solid var(--gray-200); background: var(--white);
}
.check-item.pass { border-color: #a7d7b8; background: #f0faf4; }
.check-item.warn { border-color: #f3c87e; background: #fffbf0; }
.check-item.fail { border-color: #fca5a5; background: #fff5f5; }
.check-item.skip { border-color: var(--gray-200); background: var(--gray-50); }

.check-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: .1rem; }
.check-title  { font-weight: 600; font-size: .9rem; margin-bottom: .15rem; }
.check-detail { font-size: .8rem; color: var(--gray-600); line-height: 1.4; }

/* ── Port Grid ──────────────────────────────────────────── */
.port-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .5rem; margin-bottom: 1.5rem;
}
.port-chip {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem .75rem; border-radius: 8px;
  border: 1px solid var(--gray-200); background: var(--gray-50);
  font-size: .8rem;
}
.port-chip.pass { border-color: #a7d7b8; background: #f0faf4; }
.port-chip.fail { border-color: #fca5a5; background: #fff5f5; }
.port-chip.warn { border-color: #f3c87e; background: #fffbf0; }
.port-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.port-chip.pass .port-dot { background: var(--green); }
.port-chip.fail .port-dot { background: var(--red); }
.port-chip.warn .port-dot { background: var(--amber); }
.port-name  { font-weight: 600; }
.port-proto { color: var(--gray-500); font-size: .75rem; }

/* ── Recommendations ────────────────────────────────────── */
.rec-list { display: flex; flex-direction: column; gap: .5rem; }
.rec-item {
  display: flex; gap: .75rem; align-items: flex-start;
  padding: .65rem .85rem; border-radius: 8px; font-size: .85rem;
}
.rec-item.fail { background: var(--red-bg);   border-left: 3px solid #f87171; }
.rec-item.warn { background: var(--amber-bg); border-left: 3px solid #fbbf24; }
.rec-item.info { background: var(--blue-light); border-left: 3px solid var(--blue); }
.rec-area   { font-weight: 700; min-width: 90px; color: var(--gray-700); }
.rec-action { color: var(--gray-700); line-height: 1.5; }

/* ── Results actions ────────────────────────────────────── */
.results-actions {
  display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: 1.5rem;
}

/* ── Session info ───────────────────────────────────────── */
.session-meta {
  display: flex; flex-wrap: wrap; gap: .5rem 1.5rem;
  font-size: .8rem; color: var(--gray-500); margin-bottom: 1.5rem;
  padding-bottom: 1rem; border-bottom: 1px solid var(--gray-200);
}
.session-meta strong { color: var(--gray-700); }

/* ── History page ───────────────────────────────────────── */
.passcode-gate {
  display: flex; align-items: center; justify-content: center;
  min-height: 60vh;
}
.passcode-card {
  text-align: center; max-width: 380px; width: 100%;
  padding: 2.5rem 2rem;
}
.passcode-card h2 { margin: 1rem 0 .5rem; font-size: 1.3rem; }
.passcode-card p  { color: var(--gray-600); margin-bottom: 1.25rem; }
.passcode-input-wrap { display: flex; gap: .5rem; }
.passcode-input-wrap input { flex: 1; }
.passcode-error { color: var(--red); font-size: .85rem; margin-top: .75rem; }

.history-header { display: flex; justify-content: space-between; align-items: flex-start;
                  margin-bottom: 1.25rem; gap: 1rem; flex-wrap: wrap; }
.history-header h2 { font-size: 1.2rem; font-weight: 700; }
.muted { color: var(--gray-500); font-size: .85rem; }

.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .75rem; margin-bottom: 1.25rem;
}
.stat-card { background: var(--white); border: 1px solid var(--gray-200);
             border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.stat-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
              color: var(--gray-500); font-weight: 600; margin-bottom: .35rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); }

.table-card { overflow: hidden; padding: 0; }
.results-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.results-table th {
  background: var(--gray-50); padding: .75rem 1rem; text-align: left;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--gray-500); font-weight: 700; border-bottom: 1px solid var(--gray-200);
}
.results-table td { padding: .75rem 1rem; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.results-table tr:last-child td { border-bottom: none; }
.results-table tr:hover td { background: var(--gray-50); }
.table-loading { text-align: center; color: var(--gray-400); padding: 2rem !important; }

.table-footer { display: flex; align-items: center; justify-content: space-between;
                padding: .75rem 1rem; border-top: 1px solid var(--gray-200); font-size: .85rem; }

.badge {
  display: inline-block; padding: .2rem .55rem; border-radius: 20px;
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
}
.badge-pass { background: var(--green-bg); color: var(--green); }
.badge-warn { background: var(--amber-bg); color: var(--amber); }
.badge-fail { background: var(--red-bg);   color: var(--red); }
.badge-skip { background: var(--gray-100); color: var(--gray-500); }

/* ── Footer ─────────────────────────────────────────────── */
.site-footer {
  background: var(--white); border-top: 1px solid var(--gray-200);
  padding: 1rem 1.25rem; font-size: .8rem; color: var(--gray-500);
}
.site-footer .container { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }

/* ── Print styles ───────────────────────────────────────── */
@media print {
  .no-print, .site-header, .site-footer, .results-actions, header, footer { display: none !important; }

  body { background: white; font-size: 11pt; }
  .container { max-width: 100%; padding: 0; }
  .intro-card, .test-card, .progress-card { display: none; }

  .print-header {
    display: flex !important;
    align-items: center; gap: 1rem;
    margin-bottom: 1.5rem; padding-bottom: 1rem;
    border-bottom: 2px solid var(--blue);
  }
  .print-header .brand-name   { font-size: 1.3rem; font-weight: 800; color: var(--blue); }
  .print-header .brand-tagline { font-size: .85rem; color: var(--gray-600); }

  .results-card, .check-item, .metric-tile, .port-chip, .rec-item {
    box-shadow: none !important;
    border-color: #ddd !important;
    break-inside: avoid;
  }

  .mos-hero { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .check-item, .rec-item { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  .metrics-grid { grid-template-columns: repeat(4, 1fr); }
  .port-grid    { grid-template-columns: repeat(3, 1fr); }

  h2, h3 { color: var(--blue) !important; }
  a { text-decoration: none; color: inherit; }

  @page { margin: 1.5cm; }
}

.print-header { display: none; }
