/* ==========================================================================
   Skylearn Design System — Audio Event Recognition Marketplace Application
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:ital,wght@0,400;0,700;1,400;1,700&family=Hubot+Sans:wght@500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Skylearn Color Palette */
  --sky: #3B82F6;
  --sky-bright: #60A5FA;
  --sky-deep: #1D4ED8;
  --sky-soft: #DBEAFE;
  --sun: #FBBF24;
  --sun-bright: #FCD34D;
  --sun-deep: #D97706;
  --sun-soft: #FEF3C7;
  --leaf: #22C55E;
  --leaf-soft: #DCFCE7;
  --leaf-deep: #16A34A;
  --coral: #F87171;
  --coral-soft: #FEE2E2;
  --berry: #A855F7;
  --berry-soft: #F3E8FF;

  --bg-page: #FFFFFF;
  --surface: #F8FAFC;
  --surface-elevated: #FFFFFF;
  --surface-sunken: #F1F5F9;

  --ink: #0F172A;
  --ink-muted: #475569;
  --ink-subtle: #94A3B8;
  --ink-faint: #CBD5E1;
  --outline: #E2E8F0;
  --outline-strong: #94A3B8;

  /* Typography */
  --font-display: 'Hubot Sans', 'Nunito', sans-serif;
  --font-body: 'Atkinson Hyperlegible', 'Nunito Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-card: 20px;
  --radius-panel: 28px;
  --radius-pill: 999px;

  /* Shadows */
  --shadow-card: 0 4px 16px rgba(15, 23, 42, 0.04);
  --shadow-hover: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-active: 0 12px 32px rgba(59, 130, 246, 0.15);
  --shadow-modal: 0 24px 48px rgba(15, 23, 42, 0.12);
  --shadow-sun-glow: 0 0 24px rgba(252, 211, 77, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--surface);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  letter-spacing: 0.01em;
  font-size: 18px;
}

/* Header */
.header {
  background: var(--surface-elevated);
  border-bottom: 2px solid var(--outline);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03);
}

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

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

.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--sky-soft);
  color: var(--sky);
}

.logo-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--ink);
}

.logo-badge {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--sky-soft);
  color: var(--sky-deep);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-pill);
}

/* User Account & Marketplace Status Bar */
.user-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface-sunken);
  padding: 0.4rem 1rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--outline);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  background: var(--sky);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
}

.user-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
}

.balance-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--sun-soft);
  color: var(--sun-deep);
  border: 1.5px solid var(--sun-bright);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-pill);
}

.sub-badge {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
}

.sub-badge.active {
  background: var(--leaf-soft);
  color: var(--leaf-deep);
  border: 1px solid var(--leaf);
}

.sub-badge.none {
  background: var(--coral-soft);
  color: var(--coral);
  border: 1px solid var(--coral);
}

.btn-auth {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--sky);
  color: white;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1rem;
  padding: 0.6rem 1.4rem;
  border-radius: var(--radius-lg);
  text-decoration: none;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-auth:hover {
  background: var(--sky-deep);
  transform: translateY(-2px);
}

.btn-auth:active {
  transform: scale(0.97);
}

.btn-logout {
  background: var(--surface-sunken);
  color: var(--ink-muted);
  border: 1px solid var(--outline);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-lg);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: var(--coral-soft);
  color: var(--coral);
  border-color: var(--coral);
}

/* Hero Section */
.hero {
  text-align: center;
  padding: 3rem 1.5rem 2rem;
  max-width: 900px;
  margin: 0 auto;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--sky-soft);
  color: var(--sky-deep);
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-pill);
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}

.hero-tag .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--leaf);
}

.hero-title {
  font-family: var(--font-display);
  font-size: 2.8rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.25;
  margin-bottom: 1rem;
}

.hero-sub {
  font-size: 1.15rem;
  color: var(--ink-muted);
  max-width: 720px;
  margin: 0 auto;
}

/* Main Container */
.app-container {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto 3rem;
  padding: 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Panels (Cards) */
.panel {
  background: var(--surface-elevated);
  border: 2px solid var(--outline);
  border-radius: var(--radius-panel);
  padding: 2rem;
  box-shadow: var(--shadow-card);
  transition: transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.24s ease;
}

.panel:hover {
  box-shadow: var(--shadow-hover);
}

/* Tab Switcher */
.panel-tabs {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--outline);
  padding-bottom: 1rem;
}

.tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem 1.6rem;
  border-radius: var(--radius-lg);
  border: none;
  background: var(--surface-sunken);
  color: var(--ink-muted);
  font-family: var(--font-body);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  min-height: 56px;
}

.tab:hover {
  background: var(--sky-soft);
  color: var(--sky-deep);
}

.tab.active {
  background: var(--sky);
  color: white;
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.25);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Drop Zone (Skylearn Drag & Drop) */
.drop-zone {
  border: 3px dashed var(--outline-strong);
  background: var(--surface-sunken);
  border-radius: var(--radius-card);
  padding: 3.5rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.24s ease;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--sky);
  background: var(--sky-soft);
}

.drop-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: var(--sky-soft);
  color: var(--sky);
  display: flex;
  align-items: center;
  justify-content: center;
}

.drop-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.5rem;
}

.drop-sub {
  color: var(--ink-muted);
  font-size: 1rem;
  margin-bottom: 1.5rem;
}

.drop-formats {
  display: flex;
  justify-content: center;
  gap: 0.5rem;

}

.drop-formats span {
  background: var(--surface-elevated);
  border: 1px solid var(--outline);
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
}

/* Live Recording Zone */
.record-zone {
  text-align: center;
  padding: 2rem 1rem;
}

.mic-visualizer {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mic-btn {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--sky);
  color: white;
  border: 4px solid white;
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 2;
  min-height: 56px;
}

.mic-btn:hover {
  background: var(--sky-deep);
  transform: scale(1.06);
}

.mic-btn.recording {
  background: var(--coral);
  animation: pulse-mic 1.5s infinite;
}

@keyframes pulse-mic {
  0% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.6); }
  70% { box-shadow: 0 0 0 24px rgba(248, 113, 113, 0); }
  100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0); }
}

.record-status {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 1rem;
}

.record-timer {
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--coral);
}

.live-waveform {
  background: var(--surface-sunken);
  border-radius: var(--radius-card);
  padding: 1rem;
  margin-top: 1.5rem;
}

/* Waveform Panel */
.wf-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.wf-file-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.wf-icon {
  font-size: 2.2rem;
}

.wf-filename {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
}

.wf-meta {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--ink-muted);
}

.waveform-wrap {
  position: relative;
  width: 100%;
  height: 140px;
  background: var(--surface-sunken);
  border-radius: var(--radius-card);
  border: 2px solid var(--outline);
  overflow: hidden;
}

#waveformCanvas, #overlayCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--sun-deep);
  box-shadow: 0 0 8px var(--sun);
  left: 0%;
  z-index: 10;
  pointer-events: none;
}

.timeline-ruler {
  position: relative;
  height: 24px;
  margin-top: 0.5rem;
}

/* Player Controls */
.player-controls {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-top: 1.5rem;
  background: var(--surface-sunken);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-card);
}

.ctrl-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--sky);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  flex-shrink: 0;
}

.ctrl-btn:hover {
  background: var(--sky-deep);
  transform: scale(1.05);
}

.seek-bar-wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
}

.time-current, .time-total {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink-muted);
}

input[type="range"].seek-bar {
  flex: 1;
  height: 10px;
  accent-color: var(--sky);
  cursor: pointer;
}

.volume-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink-muted);
}

input[type="range"].volume-bar {
  width: 90px;
  accent-color: var(--sky);
}

/* Big Friendly Analyze Button */
.analyze-wrap {
  text-align: center;
  margin-top: 2rem;
}

.btn-analyze {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 64px;
  padding: 0 2.5rem;
  border-radius: var(--radius-lg);
  background: var(--sky);
  color: white;
  font-family: var(--font-body);
  font-size: 1.25rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.3);
  transition: all 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-analyze:hover {
  background: var(--sky-deep);
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(59, 130, 246, 0.4);
}

.btn-analyze:active {
  transform: scale(0.97);
}

.analyze-hint {
  font-size: 0.95rem;
  color: var(--ink-muted);
  margin-top: 0.75rem;
}

/* Skylearn Progress Bar */
.progress-wrap {
  margin-top: 2rem;
  background: var(--surface-sunken);
  padding: 1.5rem;
  border-radius: var(--radius-card);
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.75rem;
}

.progress-bar-bg {
  height: 14px;
  background: var(--sky-soft);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--leaf);
  border-radius: var(--radius-pill);
  transition: width 0.3s ease;
}

/* Results Panel */
.results-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.results-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--ink);
}

.results-sub {
  color: var(--ink-muted);
  font-size: 1rem;
}

.results-actions {
  display: flex;
  gap: 0.75rem;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface-sunken);
  color: var(--ink);
  border: 1px solid var(--outline);
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-lg);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 48px;
}

.btn-ghost:hover {
  background: var(--sky-soft);
  color: var(--sky-deep);
}

.results-filter {
  display: flex;
  gap: 1rem;
}

.search-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.search-wrap svg {
  position: absolute;
  left: 1rem;
  color: var(--ink-subtle);
}

.search-wrap input {
  width: 100%;
  padding: 0.8rem 1rem 0.8rem 2.8rem;
  border-radius: var(--radius-md);
  border: 2px solid var(--outline);
  background: var(--surface-elevated);
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ink);
  outline: none;
}

.search-wrap input:focus {
  border-color: var(--sky);
  box-shadow: 0 0 0 4px var(--sky-soft);
}

.sort-select {
  padding: 0.8rem 1.2rem;
  border-radius: var(--radius-md);
  border: 2px solid var(--outline);
  background: var(--surface-elevated);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  outline: none;
  cursor: pointer;
}

/* Event Cards Grid */
.events-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.event-card {
  background: var(--surface-elevated);
  border: 2px solid var(--outline);
  border-radius: var(--radius-card);
  padding: 1.25rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: all 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: var(--shadow-card);
}

.event-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: var(--sky-bright);
}

.event-time {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-muted);
}

.event-label {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--ink);
}

.event-conf {
  display: inline-flex;
  align-self: flex-start;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-pill);
}

.event-conf.conf-high {
  background: var(--leaf-soft);
  color: var(--leaf-deep);
  border: 1px solid var(--leaf);
}

.event-conf.conf-med {
  background: var(--sun-soft);
  color: var(--sun-deep);
  border: 1px solid var(--sun);
}

.event-conf.conf-low {
  background: var(--coral-soft);
  color: var(--coral);
  border: 1px solid var(--coral);
}

/* Class-specific Tag Tints */
.event-card[data-label="AMBIENT"] .event-label { color: var(--sky-deep); }
.event-card[data-label="SHOUTING"] .event-label { color: var(--sun-deep); }
.event-card[data-label="CRYING"] .event-label { color: var(--berry); }
.event-card[data-label="IMPACT"] .event-label { color: var(--coral); }
.event-card[data-label="ALARM_SIREN"] .event-label { color: var(--leaf-deep); }
.event-card[data-label="EXPLOSION"] .event-label { color: var(--sun-deep); }

/* Skylearn Help Bubble / Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--ink);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: var(--radius-lg);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.2);
  display: none;
  z-index: 1000;
}

.toast.show {
  display: block;
  animation: slide-up 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast.error {
  background: var(--coral-soft);
  color: #991B1B;
  border: 2px solid var(--coral);
}

.toast.success {
  background: var(--leaf-soft);
  color: var(--leaf-deep);
  border: 2px solid var(--leaf);
}

@keyframes slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Footer */
.footer {
  margin-top: auto;
  border-top: 2px solid var(--outline);
  background: var(--surface-elevated);
  padding: 1.5rem;
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.95rem;
}
