/* ========================================
   QuestLog - Midnight Arcade Theme
   ======================================== */

:root {
  --bg-deep: #0a0a0f;
  --bg-surface: #12121a;
  --bg-elevated: #1a1a26;
  --bg-input: #0f0f17;
  --accent-primary: #8b5cf6;
  --accent-primary-hover: #a78bfa;
  --accent-secondary: #22d3ee;
  --success: #34d399;
  --error: #f87171;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-subtle: #1e1e2e;
  --border-default: #2a2a3e;

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'IBM Plex Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: 80px;
}

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

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ========================================
   Header
   ======================================== */
.header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.logo-icon {
  width: 28px;
  height: 28px;
  color: var(--accent-primary);
}

.logo-text {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.desktop-nav {
  display: none;
  gap: 0.5rem;
}

.nav-link {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  transition: all 0.2s;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.nav-link.active {
  color: var(--accent-primary);
  background: rgba(139, 92, 246, 0.1);
}

@media (min-width: 768px) {
  .desktop-nav {
    display: flex;
  }
}

/* ========================================
   Bottom Navigation (Mobile)
   ======================================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-around;
  padding: 0.5rem 0 max(0.5rem, env(safe-area-inset-bottom));
  z-index: 100;
}

.bottom-nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  transition: color 0.2s;
}

.bottom-nav-link svg {
  width: 24px;
  height: 24px;
}

.bottom-nav-link:hover,
.bottom-nav-link.active {
  color: var(--accent-primary);
}

.bottom-nav-add {
  color: var(--accent-primary);
}

.bottom-nav-add svg {
  background: var(--accent-primary);
  color: white;
  border-radius: 50%;
  padding: 4px;
  width: 32px;
  height: 32px;
}

@media (min-width: 768px) {
  .bottom-nav {
    display: none;
  }

  body {
    padding-bottom: 0;
  }
}

/* ========================================
   Main Content
   ======================================== */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

.page {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.page-header {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.page-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.2s;
}

.back-link:hover {
  color: var(--accent-primary);
}

.back-link svg {
  width: 18px;
  height: 18px;
}

@media (min-width: 768px) {
  .page-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

/* ========================================
   Stats Cards
   ======================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg {
  width: 24px;
  height: 24px;
}

.stat-icon-purple {
  background: rgba(139, 92, 246, 0.15);
  color: var(--accent-primary);
}

.stat-icon-cyan {
  background: rgba(34, 211, 238, 0.15);
  color: var(--accent-secondary);
}

.stat-icon-green {
  background: rgba(52, 211, 153, 0.15);
  color: var(--success);
}

.stat-content {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ========================================
   Sections
   ======================================== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.section-link {
  font-size: 0.875rem;
  color: var(--accent-primary);
  font-weight: 500;
}

.section-link:hover {
  color: var(--accent-primary-hover);
}

/* ========================================
   Games Grid
   ======================================== */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1.25rem;
}

.game-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.game-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-default);
}

.game-cover {
  aspect-ratio: 3 / 4;
  background: var(--bg-elevated);
  overflow: hidden;
}

.game-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.game-cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.game-cover-placeholder svg {
  width: 48px;
  height: 48px;
}

.game-cover-placeholder.large svg {
  width: 64px;
  height: 64px;
}

.game-info {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.game-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.game-platform {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.game-hours {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent-secondary);
  margin-top: 0.25rem;
}

/* ========================================
   Sessions List
   ======================================== */
.sessions-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.session-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  gap: 1rem;
}

.session-cover {
  width: 48px;
  height: 64px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-elevated);
  flex-shrink: 0;
}

.session-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.session-cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.session-cover-placeholder svg {
  width: 20px;
  height: 20px;
}

.session-content {
  flex: 1;
  min-width: 0;
}

.session-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.session-game {
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-game:hover {
  color: var(--accent-primary);
}

.session-duration {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--accent-secondary);
  flex-shrink: 0;
}

.session-meta {
  display: flex;
  gap: 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.session-notes {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Compact session items for game detail */
.sessions-list.compact {
  gap: 0.5rem;
}

.session-item-compact {
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 0.875rem 1rem;
}

.session-compact-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.session-item-compact .session-date {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.session-item-compact .session-duration {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--accent-secondary);
}

.session-item-compact .session-notes {
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ========================================
   Game Detail / Hero
   ======================================== */
.game-hero {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}

.game-hero-cover {
  width: 120px;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-elevated);
  flex-shrink: 0;
}

.game-hero-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.game-hero-info {
  flex: 1;
}

.game-hero-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.game-hero-platform {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.game-hero-stats {
  display: flex;
  gap: 1.5rem;
  margin: 1.25rem 0;
  padding: 1rem 0;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.hero-stat {
  display: flex;
  flex-direction: column;
}

.hero-stat-value {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.hero-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.game-hero-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

@media (min-width: 640px) {
  .game-hero {
    flex-direction: row;
    align-items: flex-start;
  }

  .game-hero-cover {
    width: 160px;
  }
}

/* ========================================
   Achievements
   ======================================== */
.achievements-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.achievement-item {
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 1rem;
  display: flex;
  gap: 1rem;
}

.achievement-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(52, 211, 153, 0.15);
  color: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.achievement-icon svg {
  width: 20px;
  height: 20px;
}

.achievement-content {
  flex: 1;
}

.achievement-name {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.achievement-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.achievement-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ========================================
   Empty States
   ======================================== */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  background: var(--bg-surface);
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-md);
}

.empty-state.small {
  padding: 1.5rem;
}

.empty-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  color: var(--text-muted);
}

.empty-icon svg {
  width: 100%;
  height: 100%;
}

.empty-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.empty-description {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.empty-state.small .empty-icon {
  display: none;
}

.empty-state.small .empty-title {
  display: none;
}

.empty-state.small .empty-description {
  margin-bottom: 1rem;
}

/* ========================================
   Forms
   ======================================== */
.form-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-optional {
  font-weight: 400;
  color: var(--text-muted);
}

.form-input,
.form-select,
.form-textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text-primary);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.duration-inputs {
  display: flex;
  gap: 1rem;
}

.duration-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.duration-field .form-input {
  width: 80px;
  text-align: center;
}

.duration-label {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-primary);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-primary-hover);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}

.btn-secondary:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

/* ========================================
   Alerts
   ======================================== */
.alert {
  padding: 0.875rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
}

.alert-error {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: var(--error);
}

/* ========================================
   Game Sections (Tabs alternative)
   ======================================== */
.game-tabs {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.game-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.game-section .section-header {
  margin-bottom: 1rem;
}

.game-section .section-title {
  font-size: 1rem;
}
