/* ==========================================================================
   Regatta Master - Tablet/Mobile Design System & Styles (Zero External Dependencies)
   ========================================================================== */

:root {
  --bg-main: #0b1329;
  --bg-card: rgba(21, 32, 63, 0.85);
  --bg-card-border: rgba(255, 255, 255, 0.12);
  --bg-header: rgba(15, 23, 42, 0.95);
  --bg-input: #1e293b;
  --bg-hover: rgba(255, 255, 255, 0.06);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --primary: #0ea5e9;
  --primary-hover: #0284c7;
  --primary-glow: rgba(14, 165, 233, 0.3);

  --emerald: #10b981;
  --emerald-hover: #059669;

  --amber: #f59e0b;
  --rose: #f43f5e;
  --indigo: #6366f1;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);

  /* Clean System Fonts - Zero External Dependencies */
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, "DejaVu Sans Mono", monospace;
}

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

body {
  font-family: var(--font-sans);
  background: radial-gradient(circle at 50% 0%, #1e293b 0%, var(--bg-main) 75%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.4;
  overflow-x: hidden;
}

/* Fix Dropdown Option Visibility on All Operating Systems */
select option {
  background-color: #1e293b !important;
  color: #ffffff !important;
  padding: 8px 12px;
}

select option:checked {
  background-color: #0ea5e9 !important;
  color: #ffffff !important;
}

/* App Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-header);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--bg-card-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  font-size: 1.5rem;
  background: linear-gradient(135deg, #38bdf8, #0284c7);
  border-radius: var(--radius-md);
  padding: 2px 8px;
}

.brand-text h1 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffffff;
}

.brand-text h1 span { color: var(--primary); }

.brand-text .sub-title {
  display: block;
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.race-badge-selector {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 4px 8px;
  border-radius: var(--radius-md);
}

.label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.input-select-compact, .input-field-compact {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
}

.header-actions {
  display: flex;
  gap: 6px;
}

.btn-nav {
  text-decoration: none;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  transition: all 0.2s ease;
}

/* Page Containers */
.single-page-container {
  max-width: 1500px;
  width: 100%;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.container-stacked {
  max-width: 720px;
}

/* Vertically Stacked Layout for Quick Entry Deck */
.quick-entry-stacked-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.master-grid-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Card Styling */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-header h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.hint {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Quick Entry Deck */
.quick-entry-deck {
  border: 1px solid rgba(14, 165, 233, 0.35);
  background: linear-gradient(145deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.95));
}

.deck-body-vertical {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.entry-fields-compact {
  display: flex;
  gap: 10px;
}

.flex-1 { flex: 1; }

.field-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.field-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.input-field {
  background: var(--bg-input);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  outline: none;
}

.input-sm-box {
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font-mono);
  padding: 8px 10px;
  height: 42px;
}

.matched-competitor-box {
  background: rgba(15, 23, 42, 0.85);
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  padding: 8px 12px;
}

.preview-label {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text-dim);
}

.preview-detail {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  margin-top: 2px;
}

/* Touch Action Deck Grid (3x2) */
.action-buttons-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.act-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 6px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(30, 41, 59, 0.85);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  min-height: 68px;
}

.act-btn:hover { transform: translateY(-2px); }
.act-btn:active { transform: translateY(0); }

.act-icon { font-size: 1.3rem; margin-bottom: 2px; }
.act-title { font-family: var(--font-display); font-size: 0.95rem; font-weight: 700; }
.act-sub { font-size: 0.6rem; color: var(--text-muted); text-transform: uppercase; }

.btn-stage { border-color: rgba(56, 189, 248, 0.4); }
.btn-stage:hover { background: rgba(56, 189, 248, 0.25); border-color: var(--primary); }

.btn-finish { border-color: rgba(16, 185, 129, 0.4); }
.btn-finish:hover { background: rgba(16, 185, 129, 0.25); border-color: var(--emerald); }

.btn-present { border-color: rgba(99, 102, 241, 0.4); }
.btn-present:hover { background: rgba(99, 102, 241, 0.25); border-color: var(--indigo); }

.btn-start { border-color: rgba(14, 165, 233, 0.4); }
.btn-start:hover { background: rgba(14, 165, 233, 0.25); border-color: var(--primary); }

.btn-dnf { border-color: rgba(244, 63, 94, 0.4); }
.btn-dnf:hover { background: rgba(244, 63, 94, 0.25); border-color: var(--rose); }

.btn-dns { border-color: rgba(245, 158, 11, 0.4); }
.btn-dns:hover { background: rgba(245, 158, 11, 0.25); border-color: var(--amber); }

/* Staged Queue Panel */
.staged-entries-card {
  border: 1px solid rgba(56, 189, 248, 0.25);
  background: rgba(15, 23, 42, 0.7);
}

.staged-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 350px;
  overflow-y: auto;
}

.empty-staged {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 12px;
  text-align: center;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-md);
}

.staged-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-md);
  padding: 8px 12px;
}

.staged-info { display: flex; flex-direction: column; }
.staged-bowsail { font-family: var(--font-mono); font-weight: 700; font-size: 0.9rem; color: var(--primary); }
.staged-helm { font-size: 0.75rem; color: var(--text-muted); }

.btn-tap-finish {
  background: var(--emerald);
  color: white;
  border: none;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.btn-tap-finish:hover { background: var(--emerald-hover); }

/* View Controls & Tab Switcher */
.view-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.tab-switcher {
  display: flex;
  background: rgba(15, 23, 42, 0.6);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--bg-card-border);
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.tab-btn.active {
  background: var(--primary);
  color: #ffffff;
}

.grid-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-input);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  width: 240px;
}

.search-box input {
  background: transparent;
  border: none;
  color: var(--text-main);
  outline: none;
  font-size: 0.8rem;
  width: 100%;
}

/* General Buttons */
.btn {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 6px 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  user-select: none;
}

.btn-sm { padding: 4px 10px; font-size: 0.75rem; }
.btn-primary { background: var(--primary); color: #ffffff; }
.btn-emerald { background: var(--emerald); color: #ffffff; }
.btn-secondary { background: #334155; color: var(--text-main); }

.btn-danger-outline {
  background: transparent;
  border-color: rgba(244, 63, 94, 0.4);
  color: #fca5a5;
}
.btn-danger-outline:hover { background: rgba(244, 63, 94, 0.15); }

/* Table Styling */
.table-card { padding: 0; overflow: hidden; }
.table-wrapper { overflow-x: auto; max-height: 600px; }

.regatta-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.82rem;
}

.regatta-table th {
  background: rgba(15, 23, 42, 0.95);
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.65rem;
  letter-spacing: 0.5px;
  padding: 10px 8px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
  position: sticky;
  top: 0;
  z-index: 10;
}

.regatta-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
}

.regatta-table tbody tr:hover { background: var(--bg-hover); }

.regatta-table tr.highlight-flash {
  animation: flashGreen 1s ease;
}

@keyframes flashGreen {
  0% { background: rgba(16, 185, 129, 0.4); }
  100% { background: transparent; }
}

.col-sm { width: 50px; }
.col-bow { width: 65px; font-weight: 700; font-family: var(--font-mono); }
.col-sail { width: 85px; font-weight: 700; font-family: var(--font-mono); color: var(--primary); }
.col-time { width: 95px; font-family: var(--font-mono); }
.col-adjust { width: 45px; }
.col-division { width: 75px; font-weight: 700; text-align: center; color: var(--amber); }

.table-input {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 2px 4px;
  font-size: 0.78rem;
  width: 100%;
  font-family: var(--font-mono);
}

.table-input:focus { border-color: var(--primary); outline: none; }
.table-checkbox { width: 16px; height: 16px; accent-color: var(--emerald); cursor: pointer; }

.status-tag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
}

.status-finished { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.status-staged { background: rgba(56, 189, 248, 0.2); color: #38bdf8; }
.status-present { background: rgba(99, 102, 241, 0.2); color: #818cf8; }
.status-dns { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.status-dnf { background: rgba(244, 63, 94, 0.2); color: #f87171; }

.table-header-bar { padding: 12px 16px; border-bottom: 1px solid var(--bg-card-border); }
.table-header-bar h3 { font-family: var(--font-display); font-size: 1rem; }

.badge-staged-count {
  background: rgba(56, 189, 248, 0.25);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.4);
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 12px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-card {
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-lg);
  width: 480px;
  max-width: 90vw;
  padding: 20px;
}

.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-header h3 { font-family: var(--font-display); font-size: 1.1rem; }
.btn-close { background: transparent; border: none; color: var(--text-muted); font-size: 1.4rem; cursor: pointer; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.hidden { display: none !important; }
.text-center { text-align: center; }

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
}

.toast {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--primary);
  color: var(--text-main);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 500;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
