/*
 * client/public/css/main.css
 * Shared design tokens and base styles for Kameleon Platform.
 * Matches the visual language of the training simulator.
 */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,300;9..40,400;9..40,500;9..40,600;9..40,700&family=DM+Mono:wght@400;500&display=swap');

/* ── Dark mode (default) ── */
:root {
  --bg:          #0b0d12;
  --surface:     #13161e;
  --panel:       #1a1e2a;
  --panel-hi:    #1f2535;
  --border:      rgba(255,255,255,0.08);
  --border-hi:   rgba(255,255,255,0.14);
  --text:        #e6eaf4;
  --text-muted:  #9aaac8;
  --text-dim:    #7d8dc1;
  --accent:      #38c87e;
  --accent-lo:   #153d28;
  --gold:        #e6b547;
  --gold-lo:     #6b5018;
  --green:       #38c87e;
  --green-lo:    #153d28;
  --red:         #e55656;
  --orange:      #e6804a;
  --purple:      #9b72f7;
  --r:           12px;
  --r-sm:        8px;
  --shadow:      0 8px 40px rgba(0,0,0,0.5);
  --t:           0.18s cubic-bezier(0.4,0,0.2,1);
  /* theming helpers */
  --header-bg:         rgba(11,13,18,0.9);
  --dot-color:         rgba(201,168,76,0.035);
  --card-shadow:       0 1px 0 rgba(255,255,255,0.05) inset, 0 4px 24px rgba(0,0,0,0.25);
  --row-border:        rgba(37,44,61,0.6);
  --row-hover:         rgba(56,200,126,0.03);
  --accent-subtle:     rgba(56,200,126,0.06);
  --accent-subtle-bdr: rgba(56,200,126,0.2);
}

/* ── Light mode ── */
[data-theme="light"] {
  --bg:          #f8f6f1;
  --surface:     #ffffff;
  --panel:       #f0ede6;
  --panel-hi:    #e8e4dc;
  --border:      rgba(13,59,46,0.1);
  --border-hi:   rgba(13,59,46,0.22);
  --text:        #0d1f1a;
  --text-muted:  #3a5048;
  --text-dim:    #506864;
  --accent:      #0d3b2e;
  --accent-lo:   rgba(13,59,46,0.08);
  --gold:        #c9a84c;
  --gold-lo:     #f5e9c8;
  --green:       #2a7a5c;
  --green-lo:    rgba(42,122,92,0.1);
  --red:         #b83232;
  --orange:      #a0541e;
  --purple:      #5b3ca8;
  --shadow:      0 4px 20px rgba(13,59,46,0.08);
  /* theming helpers */
  --header-bg:         rgba(248,246,241,0.92);
  --dot-color:         rgba(13,59,46,0.025);
  --card-shadow:       0 1px 3px rgba(13,59,46,0.06), 0 4px 16px rgba(13,59,46,0.05);
  --row-border:        rgba(13,59,46,0.12);
  --row-hover:         rgba(13,59,46,0.03);
  --accent-subtle:     rgba(13,59,46,0.05);
  --accent-subtle-bdr: rgba(13,59,46,0.18);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }

body {
  background: var(--bg); color: var(--text);
  font-family: 'DM Sans', sans-serif; font-size: 15px;
  line-height: 1.65; min-height: 100%;
  transition: background 0.2s ease, color 0.2s ease;
}

body::before {
  content: ''; position: fixed; inset: 0; z-index: 0;
  background-image: radial-gradient(circle, var(--dot-color) 1px, transparent 1px);
  background-size: 28px 28px; pointer-events: none;
}

.km-bg-canvas {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none; z-index: 0;
}

/* ── Shared Header ── */
.app-header {
  position: sticky; top: 0; z-index: 100;
  height: 62px; padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--header-bg); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.header-logo { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.header-mark {
  width: 34px; height: 34px; border-radius: 8px;
  background: #ffffff url('/public/icons/chameleon.svg') center/75% no-repeat;
  flex-shrink: 0;
}
.header-name    { font-family: 'DM Sans', sans-serif; font-size: 17px; font-weight: 700; letter-spacing: -0.2px; color: var(--text); }
.header-tagline { font-size: 9px; color: var(--text-dim); font-family: 'DM Mono', monospace; letter-spacing: 1.5px; text-transform: uppercase; }
.header-right   { display: flex; align-items: center; gap: 12px; }
.header-user    { font-size: 13px; color: var(--text-muted); }
.header-role {
  font-family: 'DM Mono', monospace; font-size: 9.5px;
  padding: 3px 9px; border-radius: 20px; text-transform: uppercase; letter-spacing: 1px;
}
.header-role.employee { background: rgba(56,200,126,0.1);  border: 1px solid rgba(56,200,126,0.25); color: var(--accent); }
.header-role.manager  { background: rgba(230,181,71,0.1);  border: 1px solid rgba(230,181,71,0.3);  color: var(--gold); }
.header-role.admin    { background: rgba(229,86,86,0.1);   border: 1px solid rgba(229,86,86,0.3);   color: var(--red); }

/* ── Theme Toggle ── */
.theme-toggle {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  transition: var(--t); flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--border-hi); color: var(--text); }
.theme-toggle svg { display: block; }

/* ── Layout ── */
.page-content { position: relative; z-index: 1; padding: 32px 28px 60px; max-width: 1100px; margin: 0 auto; }

/* ── Typography ── */
.page-title { font-family: 'DM Sans', sans-serif; font-size: clamp(26px, 3vw, 36px); font-weight: 700; letter-spacing: -0.5px; margin-bottom: 6px; }
.page-sub   { font-size: 14px; color: var(--text-muted); margin-bottom: 32px; }
.section-label { font-family: 'DM Mono', monospace; font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--gold); margin-bottom: 14px; display: block; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 22px; border-radius: var(--r-sm);
  font-family: 'DM Sans', sans-serif; font-size: 13.5px; font-weight: 600;
  cursor: pointer; border: none; transition: var(--t); text-decoration: none;
}
.btn-primary { background: #0d3b2e; color: #fff; box-shadow: 0 4px 16px rgba(13,59,46,0.4); }
.btn-primary:hover { background: #1a5c45; transform: translateY(-1px); box-shadow: 0 6px 22px rgba(13,59,46,0.5); }
.btn-ghost   { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--border-hi); color: var(--text); }
.btn-danger  { background: rgba(229,86,86,0.12); color: var(--red); border: 1px solid rgba(229,86,86,0.28); }
.btn-sm { padding: 7px 15px; font-size: 12.5px; }

/* ── Cards / Panels ── */
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r); padding: 22px;
  box-shadow: var(--card-shadow);
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title  { font-size: 15px; font-weight: 600; color: var(--text); }
.card-sub    { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Stat tiles ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 28px; }
.stat-tile {
  background: var(--panel); border: 1px solid var(--border);
  border-top: 2px solid rgba(201,168,76,0.25);
  border-radius: var(--r); padding: 20px 22px;
  box-shadow: var(--card-shadow);
}
[data-theme="light"] .stat-tile { border-top-color: rgba(201,168,76,0.55); }
.stat-label { font-family: 'DM Mono', monospace; font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px; }
.stat-value { font-family: 'DM Sans', sans-serif; font-size: 34px; font-weight: 700; line-height: 1; letter-spacing: -0.5px; }
.stat-note  { font-size: 11.5px; color: var(--text-muted); margin-top: 5px; }
.stat-value.good { color: var(--green); }
.stat-value.warn { color: var(--gold);  }
.stat-value.neutral { color: var(--accent); }

/* ── Tables ── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { font-family: 'DM Mono', monospace; font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-dim); padding: 0 16px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.data-table td { padding: 13px 16px; font-size: 13.5px; color: var(--text-muted); border-bottom: 1px solid var(--row-border); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--row-hover); }
.data-table td.name { color: var(--text); font-weight: 500; }

/* ── Score badge ── */
.score-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 48px; padding: 3px 10px; border-radius: 20px;
  font-family: 'DM Mono', monospace; font-size: 12px; font-weight: 500;
}
.score-badge.high   { background: rgba(56,200,126,0.12); color: var(--green); border: 1px solid rgba(56,200,126,0.25); }
.score-badge.medium { background: rgba(230,181,71,0.12); color: var(--gold);  border: 1px solid rgba(230,181,71,0.25); }
.score-badge.low    { background: rgba(229,86,86,0.12);  color: var(--red);   border: 1px solid rgba(229,86,86,0.25); }
.score-badge.none   { background: var(--border); color: var(--text-dim); border: 1px solid transparent; }

/* ── Progress bars ── */
.progress-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width 0.6s ease; }
.progress-fill.good { background: var(--green); }
.progress-fill.warn { background: var(--gold); }
.progress-fill.low  { background: var(--red); }

/* ── Mode chips ── */
.mode-chip {
  font-family: 'DM Mono', monospace; font-size: 9.5px;
  padding: 3px 9px; border-radius: 20px; text-transform: uppercase; letter-spacing: 1px; border: 1px solid;
}
.mode-chip.Kameleon   { background: rgba(56,200,126,0.1);  border-color: rgba(56,200,126,0.3);  color: var(--accent); }
.mode-chip.benefits   { background: rgba(56,200,126,0.1);  border-color: rgba(56,200,126,0.3);  color: var(--green);  }
.mode-chip.objections { background: rgba(230,128,74,0.1);  border-color: rgba(230,128,74,0.3);  color: var(--orange); }
.mode-chip.closing    { background: rgba(155,114,247,0.1); border-color: rgba(155,114,247,0.3); color: var(--purple); }

[data-theme="light"] .mode-chip.Kameleon  { background: rgba(13,59,46,0.08); border-color: rgba(13,59,46,0.22); }
[data-theme="light"] .header-role.employee { background: rgba(13,59,46,0.08); border-color: rgba(13,59,46,0.2); }

/* ── Logout form (in nav) ── */
.logout-form { display: inline; }
.logout-btn {
  background: none; border: none; cursor: pointer; font-size: 13px;
  color: var(--text-muted); font-family: 'DM Sans', sans-serif;
  padding: 6px 12px; border-radius: var(--r-sm);
  transition: var(--t);
}
.logout-btn:hover { color: var(--red); }

/* ── Accessibility ── */
.skip-link {
  position: absolute; top: -44px; left: 8px; z-index: 9999;
  background: var(--surface); color: var(--text);
  border: 2px solid var(--accent); border-radius: var(--r-sm);
  padding: 8px 18px; font-size: 13px; font-weight: 600;
  text-decoration: none; transition: top 0.1s ease;
}
.skip-link:focus { top: 8px; }
.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;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
:focus:not(:focus-visible) { outline: none; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .app-header { padding: 0 16px; }
  .page-content { padding: 20px 14px 48px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  /* Item 7: declutter header on mobile */
  .header-tagline { display: none; }
  .header-user    { display: none; }
  .header-role    { display: none; }
  .btn.btn-sm     { padding: 6px 10px; font-size: 12px; }
  /* Table overflow */
  .data-table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
}

/* ══════════════════════════════════════
   MICRO-INTERACTIONS
══════════════════════════════════════ */
html { scroll-behavior: smooth; }

/* Tactile button press */
.btn:active        { transform: scale(0.96);  transition-duration: 0.06s; }
.btn-primary:active { box-shadow: 0 2px 8px rgba(13,59,46,0.2); }
.btn-ghost:active  { transform: scale(0.97);  transition-duration: 0.06s; }
.logout-btn:active { transform: scale(0.97);  transition-duration: 0.06s; }

/* Header logo mark — springy bounce on hover */
.header-mark {
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.header-logo:hover .header-mark {
  transform: rotate(-8deg) scale(1.14);
}

/* Stat tile — top border glows gold on hover */
.stat-tile {
  transition: var(--t), border-top-color 0.25s ease, box-shadow 0.25s ease;
}
.stat-tile:hover {
  border-top-color: rgba(201,168,76,0.8);
  box-shadow: 0 6px 28px rgba(0,0,0,0.22);
}
[data-theme="light"] .stat-tile:hover {
  box-shadow: 0 6px 22px rgba(13,59,46,0.1);
}

/* Data table — smooth row background transition */
.data-table td { transition: background 0.12s ease; }

/* Global input / textarea / select focus ring */
input:focus, textarea:focus, select:focus {
  box-shadow: 0 0 0 3px rgba(56,200,126,0.14);
  transition: box-shadow 0.2s ease;
}
[data-theme="light"] input:focus,
[data-theme="light"] textarea:focus,
[data-theme="light"] select:focus {
  box-shadow: 0 0 0 3px rgba(13,59,46,0.11);
}
