/* ============================================
   CogniCare - Main Stylesheet
   ============================================ */

/* -- Variables -- */
:root {
  --red: #e74c3c;
  --green: #27ae60;
  --blue: #2980b9;
  --bg: #f4f6f9;
  --white: #ffffff;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --text: #1a202c;
  --text-muted: #64748b;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --header-h: 64px;
  --accent: #2980b9;
}

body.dark {
  --bg: #0f1117;
  --white: #1a1d27;
  --card-bg: #1e2130;
  --border: #2d3148;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --shadow: 0 2px 12px rgba(0,0,0,0.4);
}

/* -- Reset -- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
img, svg { display: block; }
input, select, textarea { font-family: inherit; }

/* -- Splash Screen -- */
.splash {
  position: fixed; inset: 0;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s ease;
}
.splash.hidden { opacity: 0; pointer-events: none; }
.splash-box { text-align: center; padding: 40px; }
.splash-logo { display: flex; gap: 10px; justify-content: center; margin-bottom: 20px; }
.splash-box h1 { font-size: 2.5rem; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.splash-box p { color: var(--text-muted); margin-bottom: 32px; font-size: 1rem; }
.splash-bar { width: 240px; height: 6px; background: var(--border); border-radius: 99px; margin: 0 auto; overflow: hidden; }
.splash-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--red), var(--green), var(--blue)); border-radius: 99px; transition: width 0.1s linear; }

/* -- Header -- */
.header {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow);
}
.header-brand { display: flex; align-items: center; gap: 6px; font-size: 1.1rem; }
.header-brand strong { font-weight: 700; letter-spacing: -0.3px; }
.header-nav { display: flex; gap: 4px; flex: 1; margin-left: 24px; }
.nav-link {
  padding: 8px 14px; border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 500; color: var(--text-muted);
  transition: all 0.2s;
}
.nav-link:hover, .nav-link.active {
  background: var(--bg); color: var(--text);
}
.nav-link.active { color: var(--accent); font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.clock-display { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); min-width: 44px; }

/* -- Dots / Logo -- */
.dot {
  display: inline-block; border-radius: 50%;
  width: 18px; height: 18px;
}
.dot.sm { width: 10px; height: 10px; }
.dot.red { background: var(--red); }
.dot.green { background: var(--green); }
.dot.blue { background: var(--blue); }

/* -- Buttons -- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 600; border: none;
  cursor: pointer; transition: all 0.2s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #1d6fa4; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(41,128,185,0.4); }
.btn-outline { background: transparent; color: var(--text); border: 2px solid var(--border); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-large { padding: 14px 28px; font-size: 1rem; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.icon-btn {
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 10px;
  font-size: 1rem; color: var(--text-muted);
  transition: all 0.2s;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

/* -- Main content area -- */
.main { max-width: 1200px; margin: 0 auto; padding: 32px 24px; }

/* -- Page title row -- */
.page-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.page-title { font-size: 1.6rem; font-weight: 700; }
.page-sub { color: var(--text-muted); margin-top: 4px; font-size: 0.9rem; }

/* -- Hero Section -- */
.hero {
  background: var(--white); border-radius: var(--radius);
  padding: 48px; margin-bottom: 28px;
  display: flex; align-items: center; gap: 40px;
  box-shadow: var(--shadow);
}
.hero-text { flex: 1; }
.hero-eyebrow { color: var(--text-muted); font-size: 0.85rem; font-weight: 500; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.hero-title { font-size: 2.2rem; font-weight: 800; line-height: 1.2; margin-bottom: 16px; }
.hero-sub { color: var(--text-muted); font-size: 1rem; margin-bottom: 28px; max-width: 480px; }
.hero-btns { display: flex; gap: 12px; flex-wrap: wrap; }
.accent { color: var(--accent); }

/* -- Orb visual -- */
.hero-visual { flex-shrink: 0; }
.orb-wrap { position: relative; width: 180px; height: 180px; }
.orb {
  position: absolute; border-radius: 50%;
  width: 100px; height: 100px; opacity: 0.8;
  animation: float 3s ease-in-out infinite;
}
.orb-r { background: var(--red); top: 0; left: 0; animation-delay: 0s; }
.orb-g { background: var(--green); top: 0; right: 0; animation-delay: 0.5s; }
.orb-b { background: var(--blue); bottom: 0; left: 50%; transform: translateX(-50%); animation-delay: 1s; }
.orb-center {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  background: var(--white); border-radius: 50%;
  width: 60px; height: 60px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: var(--shadow-lg); z-index: 2;
}
.orb-num { font-size: 1.4rem; font-weight: 800; color: var(--text); }
.orb-lbl { font-size: 0.6rem; color: var(--text-muted); font-weight: 500; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.orb-b { animation-name: floatB; }
@keyframes floatB { 0%,100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-8px); } }

/* -- Stats Row -- */
.stats-row {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 16px; margin-bottom: 28px;
}
.stat-card {
  background: var(--white); border-radius: var(--radius);
  padding: 20px; display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
}
.stat-icon {
  width: 48px; height: 48px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
}
.blue-bg { background: #dbeafe; }
.green-bg { background: #d1fae5; }
.purple-bg { background: #ede9fe; }
.orange-bg { background: #ffedd5; }
.stat-val { font-size: 1.5rem; font-weight: 700; line-height: 1; }
.stat-lbl { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; margin-top: 4px; }

/* -- Feature Cards -- */
.feature-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 16px; margin-bottom: 28px;
}
.feature-card {
  background: var(--white); border-radius: var(--radius);
  padding: 24px; border: 1px solid var(--border);
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px;
  transition: all 0.25s; cursor: pointer;
}
.feature-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--accent); }
.fc-icon { font-size: 2rem; margin-bottom: 4px; }
.feature-card h3 { font-size: 1.1rem; font-weight: 700; }
.feature-card p { color: var(--text-muted); font-size: 0.85rem; flex: 1; }
.fc-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 0.82rem; color: var(--text-muted); }

/* -- Section Block -- */
.section-block {
  background: var(--white); border-radius: var(--radius);
  padding: 28px; margin-bottom: 28px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
}
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.section-header h3 { font-size: 1.1rem; font-weight: 700; }
.section-header span, .section-header a { color: var(--text-muted); font-size: 0.85rem; }

/* -- Levels Grid -- */
.levels-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 12px; }
.level-card {
  background: var(--bg); border-radius: var(--radius-sm);
  padding: 16px 8px; text-align: center;
  border: 2px solid var(--border); transition: all 0.2s;
}
.level-card:hover { border-color: var(--accent); background: var(--white); }
.level-num { font-size: 1.4rem; font-weight: 800; color: var(--accent); display: block; }
.level-name { font-size: 0.72rem; font-weight: 600; margin: 6px 0 4px; }
.level-desc { font-size: 0.68rem; color: var(--text-muted); }

/* -- Sessions list (home) -- */
.empty-msg { color: var(--text-muted); padding: 20px 0; }
.empty-state-box { text-align: center; padding: 48px; color: var(--text-muted); }
.empty-icon { font-size: 3rem; margin-bottom: 12px; }

/* -- Sessions Table -- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.data-table th { background: var(--bg); padding: 12px 14px; text-align: left; font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg); }
.empty-cell { text-align: center; color: var(--text-muted); padding: 32px; }

/* -- Input Fields -- */
.input-field {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.9rem; background: var(--white); color: var(--text);
  outline: none; transition: border-color 0.2s;
}
.input-field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(41,128,185,0.15); }
.select-field { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; appearance: none; }
.textarea-field { resize: vertical; min-height: 80px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* -- Search Bar -- */
.search-bar { display: flex; gap: 12px; margin-bottom: 20px; }
.search-bar .input-field { flex: 1; }

/* -- Modal -- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; padding: 24px;
}
.modal-box {
  background: var(--white); border-radius: var(--radius);
  padding: 32px; width: 100%; max-width: 560px;
  box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto;
}
.modal-sm { max-width: 400px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.modal-header h3 { font-size: 1.2rem; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 1.2rem; color: var(--text-muted); cursor: pointer; padding: 4px 8px; border-radius: 4px; }
.modal-close:hover { background: var(--bg); color: var(--text); }
.patient-form { display: flex; flex-direction: column; gap: 16px; }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 8px; }

/* -- Patient List -- */
.patient-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.patient-card {
  background: var(--white); border-radius: var(--radius);
  padding: 20px; border: 1px solid var(--border);
  box-shadow: var(--shadow); transition: all 0.2s;
}
.patient-card:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); }
.pc-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.pc-avatar { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; font-weight: 700; color: #fff; flex-shrink: 0; }
.pc-name { font-size: 1rem; font-weight: 700; }
.pc-id { font-size: 0.75rem; color: var(--text-muted); font-family: monospace; }
.pc-detail { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.pc-tag { font-size: 0.75rem; padding: 3px 10px; border-radius: 99px; background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }
.pc-actions { display: flex; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.pc-actions .btn { flex: 1; justify-content: center; }

/* -- Toast -- */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9998; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--white); border-radius: var(--radius-sm);
  padding: 14px 20px; min-width: 280px;
  box-shadow: var(--shadow-lg); border-left: 4px solid var(--green);
  font-size: 0.88rem; font-weight: 500;
  animation: slideIn 0.3s ease; display: flex; align-items: center; gap: 12px;
}
.toast.error { border-left-color: var(--red); }
.toast.warning { border-left-color: #f59e0b; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(20px); } }

/* -- Settings -- */
.settings-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.settings-card {
  background: var(--white); border-radius: var(--radius);
  padding: 24px; border: 1px solid var(--border);
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 16px;
}
.settings-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.settings-card-header h3 { font-size: 1rem; font-weight: 700; }
.settings-icon { font-size: 1.4rem; }
.range-slider { width: 100%; accent-color: var(--accent); cursor: pointer; }
.range-labels { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.range-val { color: var(--accent); font-weight: 700; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-toggle {
  padding: 8px 16px; border-radius: var(--radius-sm);
  border: 2px solid var(--border); background: var(--bg);
  font-size: 0.85rem; font-weight: 500; color: var(--text-muted);
  cursor: pointer; transition: all 0.2s;
}
.btn-toggle.active { border-color: var(--accent); color: var(--accent); background: #dbeafe; font-weight: 600; }
.toggle-label { display: flex; align-items: center; justify-content: space-between; cursor: pointer; gap: 12px; }
.toggle-input { display: none; }
.toggle-switch {
  width: 44px; height: 24px; background: var(--border); border-radius: 99px;
  position: relative; transition: background 0.2s; flex-shrink: 0;
}
.toggle-switch::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; background: #fff; border-radius: 50%;
  transition: transform 0.2s; box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.toggle-input:checked + .toggle-switch { background: var(--accent); }
.toggle-input:checked + .toggle-switch::after { transform: translateX(20px); }
.theme-swatches { display: flex; gap: 10px; }
.swatch { width: 40px; height: 40px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; transition: all 0.2s; }
.swatch.active { border-color: var(--text); transform: scale(1.1); }
.difficulty-info { background: var(--bg); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 0.82rem; color: var(--text-muted); }
.danger-zone { border-color: #fecaca !important; }
.danger-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.danger-row:last-child { border-bottom: none; }
.danger-row p { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.small-link { font-size: 0.8rem; font-weight: 500; color: var(--accent); }
.filter-row { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.filter-row .input-field { flex: 1; min-width: 140px; }

/* -- Footer -- */
.footer {
  background: var(--white); border-top: 1px solid var(--border);
  padding: 16px 24px; display: flex; justify-content: space-between;
  align-items: center; font-size: 0.8rem; color: var(--text-muted);
}

/* -- Animations -- */
@keyframes shake { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-8px)} 40%{transform:translateX(8px)} 60%{transform:translateX(-6px)} 80%{transform:translateX(6px)} }
@keyframes pop { 0%{transform:scale(1)} 50%{transform:scale(1.35)} 100%{transform:scale(0);opacity:0} }
@keyframes bounce { 0%,100%{transform:scale(1)} 50%{transform:scale(1.15)} }
.shake { animation: shake 0.4s ease; }
