@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@300;400;500;600;700&display=swap');

:root {
  /* LMU Official Colors - Dark racing theme */
  --bg-primary: #0a0e1a;
  --bg-secondary: #12161f;
  --bg-elevated: #1a1f2e;
  --accent-primary: #00d9ff;
  --accent-secondary: #ff3366;
  --accent-gold: #ffd700;
  --text-primary: #ffffff;
  --text-secondary: #a0a8b8;
  --text-muted: #6b7280;
  --border: rgba(0, 217, 255, 0.15);
  --border-subtle: rgba(255, 255, 255, 0.05);
  --success: #00ff88;
  --warning: #ffaa00;
  --danger: #ff3366;
  --font-primary: 'Rajdhani', 'Orbitron', system-ui, -apple-system, sans-serif;
  --font-secondary: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-secondary);
  background: var(--bg-primary);
  color: var(--text-primary);
  background-image: 
    radial-gradient(ellipse at top, rgba(0, 217, 255, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(255, 51, 102, 0.05) 0%, transparent 50%);
  background-attachment: fixed;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================================================
   HEADER / TOP BAR
   ============================================================================ */

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 2rem;
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-elevated) 100%);
  border-bottom: 2px solid var(--border);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5), 0 0 60px rgba(0, 217, 255, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  color: var(--bg-primary);
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.05em;
  font-size: 1rem;
  font-family: var(--font-primary);
  box-shadow: 
    0 0 20px rgba(0, 217, 255, 0.5),
    0 4px 12px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  position: relative;
  overflow: hidden;
}

.brand-mark::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transform: rotate(45deg);
  animation: shine 3s infinite;
}

@keyframes shine {
  0%, 100% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
  50% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.brand-title {
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 1.1rem;
  font-family: var(--font-primary);
  background: linear-gradient(90deg, var(--accent-primary), var(--text-primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

#authContainer {
  font-size: 0.85rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

#userProfile {
  display: none;
  gap: 0.75rem;
  align-items: center;
  padding: 0.5rem 1rem;
  background: rgba(0, 217, 255, 0.1);
  border-radius: 8px;
  border: 1px solid var(--border);
}

#userName {
  color: var(--accent-primary);
  font-weight: 600;
  font-family: var(--font-primary);
}

.file-input {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  border: 2px solid var(--accent-primary);
  padding: 0.65rem 1.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  font-family: var(--font-primary);
  color: var(--accent-primary);
  cursor: pointer;
  background: linear-gradient(135deg, rgba(0, 217, 255, 0.1), rgba(0, 217, 255, 0.05));
  transition: all 0.3s ease;
  box-shadow: 0 0 20px rgba(0, 217, 255, 0.2);
}

.file-input:hover {
  background: linear-gradient(135deg, rgba(0, 217, 255, 0.2), rgba(0, 217, 255, 0.1));
  box-shadow: 0 0 30px rgba(0, 217, 255, 0.4);
  transform: translateY(-2px);
}

.file-input input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* ============================================================================
   LAYOUT
   ============================================================================ */

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 1.5rem;
  padding: 2rem;
  max-width: 1800px;
  margin: 0 auto;
  width: 100%;
}

@media (max-width: 1200px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

#globalSearch {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

#globalDriverSearch {
  width: 100%;
  background: var(--bg-elevated);
  border-radius: 12px;
  padding: 1rem 1.5rem;
  border: 2px solid var(--border);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: var(--font-primary);
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#globalDriverSearch:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 30px rgba(0, 217, 255, 0.3);
}

#globalDriverSearch::placeholder {
  color: var(--text-muted);
}

#searchResults {
  grid-column: 1 / -1;
  display: none;
  margin-bottom: 0;
}

/* ============================================================================
   PANELS
   ============================================================================ */

.panel {
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-elevated) 100%);
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 1.5rem;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(0, 217, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  position: relative;
  overflow: hidden;
}

.panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-primary), transparent);
  opacity: 0.5;
}

.panel h2 {
  margin: 0 0 1.25rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-secondary);
  font-weight: 600;
  font-family: var(--font-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel h2::before {
  content: '';
  width: 3px;
  height: 16px;
  background: var(--accent-primary);
  box-shadow: 0 0 10px var(--accent-primary);
}

/* ============================================================================
   TRACK OVERVIEW METRICS
   ============================================================================ */

.track-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  font-size: 0.85rem;
}

.metric {
  padding: 1rem;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-subtle);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.metric:hover {
  border-color: var(--border);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 217, 255, 0.2);
}

.metric-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-weight: 500;
  font-family: var(--font-primary);
}

.metric-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-primary);
}

.metric-highlight {
  color: var(--accent-primary);
  text-shadow: 0 0 10px rgba(0, 217, 255, 0.5);
}

.metric-warning {
  color: var(--danger);
}

.placeholder {
  grid-column: 1 / -1;
  padding: 2rem;
  border-radius: 12px;
  border: 2px dashed var(--border);
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
  font-family: var(--font-primary);
}

/* ============================================================================
   TABS
   ============================================================================ */

.tabs {
  display: inline-flex;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.35rem;
  border: 1px solid var(--border-subtle);
  margin-bottom: 1.25rem;
  gap: 0.25rem;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8rem;
  padding: 0.5rem 1.25rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 600;
  font-family: var(--font-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tab:hover {
  color: var(--accent-primary);
  background: rgba(0, 217, 255, 0.05);
}

.tab.active {
  background: linear-gradient(135deg, var(--accent-primary), rgba(0, 217, 255, 0.8));
  color: var(--bg-primary);
  box-shadow: 0 0 20px rgba(0, 217, 255, 0.4);
}

.tab-body {
  display: none;
}

.tab-body.active {
  display: flex;
  flex-direction: column;
}

/* ============================================================================
   TOOLBAR
   ============================================================================ */

.toolbar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.search,
.select {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  padding: 0.65rem 1rem;
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: var(--font-secondary);
  transition: all 0.3s ease;
}

.search:focus,
.select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 20px rgba(0, 217, 255, 0.2);
}

.search::placeholder {
  color: var(--text-muted);
}

/* ============================================================================
   TABLES
   ============================================================================ */

.table-wrapper {
  max-height: 65vh;
  overflow: auto;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-subtle);
}

.table-wrapper::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.table-wrapper::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}

.table-wrapper::-webkit-scrollbar-thumb {
  background: var(--accent-primary);
  border-radius: 4px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
  background: var(--accent-secondary);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead {
  position: sticky;
  top: 0;
  background: linear-gradient(135deg, var(--bg-elevated), var(--bg-secondary));
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  z-index: 10;
}

th,
td {
  padding: 0.85rem 1rem;
  text-align: left;
  white-space: nowrap;
}

th {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.75rem;
  color: var(--accent-primary);
  cursor: pointer;
  font-family: var(--font-primary);
  border-bottom: 2px solid var(--border);
  transition: all 0.3s ease;
}

th:hover {
  color: var(--text-primary);
  background: rgba(0, 217, 255, 0.05);
}

tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: all 0.2s ease;
}

tbody tr:nth-child(odd) {
  background: rgba(0, 0, 0, 0.2);
}

tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.1);
}

tbody tr:hover {
  background: rgba(0, 217, 255, 0.08);
  transform: translateX(4px);
  box-shadow: inset 4px 0 0 var(--accent-primary);
}

td {
  color: var(--text-secondary);
  font-family: var(--font-secondary);
}

/* ============================================================================
   STATUS PILLS
   ============================================================================ */

.status-pill {
  padding: 0.25rem 0.75rem;
  border-radius: 6px;
  font-size: 0.7rem;
  border: 1px solid;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  font-family: var(--font-primary);
  display: inline-block;
}

.status-finished {
  border-color: var(--success);
  color: var(--success);
  background: rgba(0, 255, 136, 0.1);
  box-shadow: 0 0 10px rgba(0, 255, 136, 0.2);
}

.status-dnf {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(255, 51, 102, 0.1);
  box-shadow: 0 0 10px rgba(255, 51, 102, 0.2);
}

/* ============================================================================
   CHAT LOG
   ============================================================================ */

.chat-log {
  max-height: 65vh;
  overflow: auto;
  padding: 0.5rem;
  font-size: 0.85rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
}

.chat-line {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  transition: all 0.2s ease;
}

.chat-line:hover {
  background: rgba(0, 217, 255, 0.05);
}

.chat-meta {
  color: var(--text-muted);
  font-size: 0.7rem;
  font-family: var(--font-primary);
  margin-bottom: 0.25rem;
}

.chat-message {
  color: var(--text-secondary);
}

/* ============================================================================
   FOOTER
   ============================================================================ */

.footer {
  padding: 1.5rem 2rem;
  font-size: 0.75rem;
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
  margin-top: auto;
}

.footer .hint {
  opacity: 0.7;
  font-style: italic;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
  .top-bar {
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }

  .layout {
    padding: 1rem;
    gap: 1rem;
  }

  .track-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

  .table-wrapper {
    max-height: 50vh;
  }
}
