/**
 * Pace Planner - Core Styles & Design Tokens
 * Responsive layout, glassmorphic surfaces, curated dark/light palettes, and typography.
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
  /* Font Families */
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Color Accents (Brand Identity) */
  --primary-hue: 246;
  --primary: hsl(var(--primary-hue), 85%, 62%);
  --primary-hover: hsl(var(--primary-hue), 85%, 56%);
  --primary-active: hsl(var(--primary-hue), 85%, 50%);
  --primary-subtle: hsla(var(--primary-hue), 85%, 62%, 0.12);
  --primary-glow: hsla(var(--primary-hue), 85%, 62%, 0.35);

  --secondary: #8b5cf6;
  --accent: #06b6d4;
  --success: #10b981;
  --success-subtle: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b;
  --warning-subtle: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-subtle: rgba(239, 68, 68, 0.15);
  --info: #3b82f6;

  /* Layout dimensions */
  --sidebar-width: 260px;
  --header-height: 70px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 0 25px var(--primary-glow);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 350ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Light Theme Variables */
:root[data-theme="light"] {
  --bg-app: #f8fafc;
  --bg-sidebar: #ffffff;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-surface-hover: #e2e8f0;
  --border-color: #e2e8f0;
  --border-subtle: #f1f5f9;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;
  --text-inverse: #ffffff;

  --glass-bg: rgba(255, 255, 255, 0.90);
  --glass-border: rgba(226, 232, 240, 0.85);
}

/* Dark Theme Variables (Default) */
:root,
:root[data-theme="dark"] {
  --bg-app: #080c14;
  --bg-sidebar: #0e1422;
  --bg-surface: #121829;
  --bg-surface-elevated: #182238;
  --bg-surface-hover: #1f2b47;
  --border-color: #24314c;
  --border-subtle: #192238;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #7e8da6;
  --text-inverse: #080c14;

  --glass-bg: rgba(18, 24, 41, 0.88);
  --glass-border: rgba(36, 49, 76, 0.85);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Accessible Focus States */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

/* Accessible Skip to Content Link */
.skip-to-content {
  position: absolute;
  top: -60px;
  left: 1.5rem;
  background: var(--primary);
  color: #ffffff;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-md);
  z-index: 10000;
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
  box-shadow: 0 4px 14px var(--primary-glow);
  transition: top var(--transition-fast);
}

.skip-to-content:focus {
  top: 1rem;
  outline: 3px solid #ffffff;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.25;
}

h1 { font-size: 2.25rem; letter-spacing: -0.025em; }
h2 { font-size: 1.75rem; letter-spacing: -0.02em; }
h3 { font-size: 1.25rem; letter-spacing: -0.015em; }
h4 { font-size: 1.05rem; }

p {
  color: var(--text-muted);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-hover);
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text-main);
}

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

/* App Layout Grid */
.app-container {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* Sidebar Styles */
.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: transform var(--transition-normal), background-color var(--transition-normal);
}

.sidebar-header {
  height: var(--header-height);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-logo {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.brand-logo svg {
  width: 22px;
  height: 22px;
  color: #ffffff;
}

.brand-name {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text-main) 30%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
  background: var(--primary-subtle);
  color: var(--primary);
  margin-left: auto;
}

.sidebar-nav {
  flex: 1;
  padding: 1.25rem 0.85rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav-heading {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 0.75rem 0.75rem 0.35rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.92rem;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.nav-link:hover {
  background-color: var(--bg-surface-elevated);
  color: var(--text-main);
  transform: translateX(3px);
}

.nav-link.active {
  background: linear-gradient(90deg, var(--primary-subtle) 0%, transparent 100%);
  color: var(--primary);
  font-weight: 600;
  border-left: 3px solid var(--primary);
}

.nav-link .icon {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  transition: transform var(--transition-fast);
}

.nav-link:hover .icon {
  transform: scale(1.1);
}

.sidebar-footer {
  padding: 1.25rem;
  border-top: 1px solid var(--border-subtle);
}

.sidebar-quick-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  text-align: center;
}

.sidebar-quick-card p {
  font-size: 0.8rem;
  margin-bottom: 0.65rem;
}

/* Main Content Area */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header Styles */
.app-header {
  height: var(--header-height);
  background-color: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  transition: background-color var(--transition-normal);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-time-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.35rem 0.85rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  color: var(--text-muted);
}

.header-live-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

/* View Sections Containers */
.view-viewport {
  flex: 1;
  padding: 2rem;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.app-section {
  display: none;
  animation: fadeIn 250ms ease-out forwards;
}

.app-section.is-active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-header {
  margin-bottom: 2rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.section-title-wrap h1 {
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.section-title-wrap p {
  font-size: 0.95rem;
}

/* Subtle utility classes */
.icon {
  width: 20px;
  height: 20px;
  display: inline-block;
  vertical-align: middle;
}

.icon-sm {
  width: 16px;
  height: 16px;
}

.icon-lg {
  width: 28px;
  height: 28px;
}

.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-primary { color: var(--primary); }

.highlight-name {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
