/* ==========================================================================
   TypeMaster Pro / SCTI Typing Learning App — Global Design System & Styles
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500;600;700&display=swap');

:root {
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Colors */
  --bg-body: #090d16;
  --bg-surface: #0f172a;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-solid: #111827;
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-glow: rgba(79, 70, 229, 0.35);

  --accent: #06b6d4;
  --accent-hover: #0891b2;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);

  /* Finger colors for Virtual Keyboard */
  --finger-left-pinky: #ec4899;
  --finger-left-ring: #f97316;
  --finger-left-middle: #eab308;
  --finger-left-index: #10b981;
  --finger-right-index: #06b6d4;
  --finger-right-middle: #3b82f6;
  --finger-right-ring: #8b5cf6;
  --finger-right-pinky: #a855f7;
  --finger-thumb: #64748b;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.25);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
}

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

body {
  background-color: var(--bg-body);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

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

/* Ambient glow */
.ambient-glow {
  position: fixed;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  filter: blur(140px);
  z-index: 0;
  pointer-events: none;
  opacity: 0.15;
}
.ambient-left { top: -100px; left: -100px; background: var(--primary); }
.ambient-right { top: -100px; right: -100px; background: var(--accent); }

/* Navigation */
.navbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}
.nav-brand-logo {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 12px var(--primary-glow);
}
.nav-brand-logo svg { width: 22px; height: 22px; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-link {
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.nav-link:hover, .nav-link.active {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
}

.nav-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-badge {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.825rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Layout */
.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  position: relative;
  z-index: 1;
  flex: 1;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: white;
  box-shadow: 0 4px 14px var(--primary-glow);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.5);
}
.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text-main);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-hover);
}
.btn-danger {
  background: var(--danger-bg);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
  color: white;
}

/* Cards */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: all 0.2s ease;
}
.card:hover {
  border-color: var(--border-hover);
}

/* Stats Metric Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}
.metric-box {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}
.metric-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.metric-val {
  font-size: 1.75rem;
  font-weight: 800;
  font-family: var(--font-mono);
  margin-top: 0.35rem;
}
.metric-val.green { color: var(--success); }
.metric-val.cyan { color: var(--accent); }
.metric-val.amber { color: var(--warning); }
.metric-val.indigo { color: #a5b4fc; }

/* Progress Bar */
.progress-bar-wrap {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

/* Form inputs */
.form-group {
  margin-bottom: 1.25rem;
}
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 0.45rem;
}
.form-input {
  width: 100%;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s ease;
}
.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.25);
}

/* Alerts */
.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.alert-error {
  background: var(--danger-bg);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}
.alert-success {
  background: var(--success-bg);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}

/* ==========================================================================
   Virtual Keyboard Component
   ========================================================================== */
.keyboard-viz {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #090e1a;
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.keyboard-row {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.key {
  height: 44px;
  min-width: 44px;
  padding: 0 8px;
  background: #182235;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-muted);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
  transition: all 0.1s ease;
  user-select: none;
}

.key.home-row {
  border-bottom: 2px solid var(--accent);
}

.key.active-key {
  background: var(--primary) !important;
  color: white !important;
  transform: translateY(2px);
  box-shadow: 0 0 15px var(--primary-glow) !important;
  border-color: white !important;
}

/* Finger guide borders */
.key.left-pinky { border-bottom: 3px solid var(--finger-left-pinky); }
.key.left-ring { border-bottom: 3px solid var(--finger-left-ring); }
.key.left-middle { border-bottom: 3px solid var(--finger-left-middle); }
.key.left-index { border-bottom: 3px solid var(--finger-left-index); }
.key.right-index { border-bottom: 3px solid var(--finger-right-index); }
.key.right-middle { border-bottom: 3px solid var(--finger-right-middle); }
.key.right-ring { border-bottom: 3px solid var(--finger-right-ring); }
.key.right-pinky { border-bottom: 3px solid var(--finger-right-pinky); }

.key.key-wide-2 { flex: 1.5; }
.key.key-wide-3 { flex: 2; }
.key.key-wide-4 { flex: 2.5; }
.key.key-space { flex: 5.5; }

/* Typing Engine Screen */
.typing-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.35);
  position: relative;
}

.typing-display {
  font-family: var(--font-mono);
  font-size: 1.45rem;
  line-height: 2.2rem;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: none;
  min-height: 120px;
}

.char {
  position: relative;
  border-radius: 3px;
  padding: 0 1px;
}
.char.correct {
  color: var(--success);
}
.char.incorrect {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.25);
  text-decoration: underline;
}
.char.current {
  background: rgba(79, 70, 229, 0.35);
  color: white;
  border-bottom: 2px solid var(--accent);
  animation: pulseCursor 1s infinite;
}

@keyframes pulseCursor {
  0%, 100% { border-bottom-color: var(--accent); }
  50% { border-bottom-color: transparent; }
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  background: #1e293b;
  border: 1px solid var(--border-hover);
  color: white;
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  box-shadow: var(--shadow-xl);
}
.toast.success { background: #064e3b; border-color: rgba(16, 185, 129, 0.4); }
.toast.error { background: #7f1d1d; border-color: rgba(239, 68, 68, 0.4); }
.toast.fade-out { opacity: 0; transform: translateY(10px); transition: all 0.35s ease; }

/* Print Styles for A4 Report */
@media print {
  body {
    background: white !important;
    color: #1e293b !important;
  }
  .navbar, .ambient-glow, .btn-print, .no-print {
    display: none !important;
  }
  .container {
    max-width: 100% !important;
    padding: 0 !important;
  }
  .card, .dashboard-panel {
    border: 1px solid #cbd5e1 !important;
    background: white !important;
    box-shadow: none !important;
    color: #1e293b !important;
  }
  table th {
    background: #f1f5f9 !important;
    color: #0f172a !important;
  }
  table td {
    color: #334155 !important;
    border-bottom: 1px solid #e2e8f0 !important;
  }
}