/* Global Variables & Theme Setup */
:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: rgba(22, 30, 49, 0.65);
  --bg-card-hover: rgba(30, 41, 67, 0.8);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --primary: #10b981; /* Emerald Green */
  --primary-glow: rgba(16, 185, 129, 0.15);
  --primary-hover: #059669;
  
  --secondary: #3b82f6; /* Pitch Blue */
  --secondary-glow: rgba(59, 130, 246, 0.15);
  --secondary-hover: #2563eb;
  
  --accent-gold: #f59e0b; /* Program / Season Ticket yellow-orange */
  --accent-gold-glow: rgba(245, 158, 11, 0.15);
  
  --danger: #ef4444;
  --danger-hover: #dc2626;
  
  --sidebar-width: 280px;
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Reset and Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* Sidebar Navigation */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2.5rem;
}

.brand-icon {
  font-size: 2.5rem;
  color: var(--primary);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--text-primary);
  line-height: 1.1;
}

.brand-text p {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-grow: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  border-radius: 10px;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.nav-link:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.03);
}

.nav-link.active {
  color: var(--primary);
  background-color: var(--primary-glow);
  border-color: rgba(16, 185, 129, 0.2);
}

.nav-link .material-symbols-rounded {
  font-size: 1.35rem;
}

.sidebar-footer {
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.db-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem;
  background-color: rgba(16, 185, 129, 0.08);
  color: var(--primary);
  border-radius: 20px;
  width: max-content;
  font-weight: 600;
  font-size: 0.75rem;
}

.db-status-dot {
  width: 6px;
  height: 6px;
  background-color: var(--primary);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--primary);
}

/* Main Content Area */
.main-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0; /* Prevents flex children from breaking parent bounds */
  padding: 2rem 2.5rem;
}

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.header-title-wrapper h2 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
}

.header-title-wrapper p {
  font-size: 0.9rem;
  margin-top: 0.15rem;
}

/* General Layout Elements */
.text-muted {
  color: var(--text-secondary);
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

/* Cards & Containers */
.card {
  background-color: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.card:hover {
  border-color: var(--border-hover);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-family);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.65rem 1.25rem;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

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

.btn-primary {
  background-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.1);
  border-color: var(--border-hover);
}

.btn-danger {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  background-color: var(--danger);
  color: #fff;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}

.btn-text {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  transition: color var(--transition-fast);
}

.btn-text:hover {
  color: var(--primary-hover);
}

.btn-with-icon .material-symbols-rounded {
  font-size: 1.15rem;
}

.btn-icon-only {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Views Logic */
.app-view {
  display: none;
  animation: fadeIn var(--transition-normal);
}

.app-view.active {
  display: block;
}

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

/* --- VIEW: DASHBOARD --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background-color: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-normal), border-color var(--transition-fast), box-shadow var(--transition-normal);
}

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

.stat-icon-wrapper {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon-wrapper .material-symbols-rounded {
  font-size: 1.75rem;
}

.stat-icon-wrapper.revenue {
  background-color: var(--secondary-glow);
  color: var(--secondary);
}

.stat-icon-wrapper.attendance {
  background-color: var(--primary-glow);
  color: var(--primary);
}

.stat-icon-wrapper.tickets {
  background-color: var(--accent-gold-glow);
  color: var(--accent-gold);
}

.stat-icon-wrapper.season {
  background-color: rgba(167, 139, 250, 0.15); /* Purple accent */
  color: #a78bfa;
}

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

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

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0.15rem 0;
}

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

/* Charts Grid */
.charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (max-width: 1024px) {
  .charts-row {
    grid-template-columns: 1fr;
  }
}

.chart-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

.chart-card-header {
  margin-bottom: 1.5rem;
}

.chart-card-header h4 {
  font-size: 1.1rem;
  font-weight: 600;
}

.chart-card-header p {
  font-size: 0.8rem;
}

.chart-container {
  position: relative;
  flex-grow: 1;
  min-height: 250px;
}

/* Overview Tables Grid */
.overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 768px) {
  .overview-grid {
    grid-template-columns: 1fr;
  }
}

.overview-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
}

.overview-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.overview-card-header h4 {
  font-size: 1.1rem;
  font-weight: 600;
}

/* Tables and Responsive Wrappers */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: 8px;
}

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

.table th, .table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.table th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background-color: rgba(255, 255, 255, 0.02);
}

.table tr:last-child td {
  border-bottom: none;
}

.table tbody tr {
  transition: background-color var(--transition-fast);
}

.table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

/* --- VIEW: MATCHES --- */
.view-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.search-box {
  display: flex;
  align-items: center;
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0 1rem;
  width: 320px;
  max-width: 100%;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-box input {
  background: none;
  border: none;
  padding: 0.65rem 0.5rem;
  color: var(--text-primary);
  width: 100%;
  font-family: var(--font-family);
  font-size: 0.9rem;
}

.search-box input:focus {
  outline: none;
}

.search-box .material-symbols-rounded {
  color: var(--text-secondary);
  font-size: 1.25rem;
}

.table-card {
  padding: 0;
  overflow: hidden;
}

/* Match list specific styles */
.opponent-cell {
  display: flex;
  flex-direction: column;
}

.opponent-name {
  font-weight: 600;
  color: var(--text-primary);
}

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

.badge-result {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.8rem;
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
  min-width: 45px;
}

.badge-result.win {
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--primary);
  border-color: rgba(16, 185, 129, 0.3);
}

.badge-result.loss {
  background-color: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

.action-buttons {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* --- VIEW: SEASON TICKETS --- */
.season-tickets-layout {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 900px) {
  .season-tickets-layout {
    grid-template-columns: 1fr;
  }
}

.form-card h3, .list-card h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

.form-card p, .list-card p {
  font-size: 0.8rem;
  margin-bottom: 1.5rem;
}

/* --- FORMS & INPUTS --- */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.form-row {
  display: flex;
  gap: 1rem;
}

.form-row.two-cols > .form-group {
  flex: 1;
}

.form-row.three-cols > .form-group {
  flex: 1;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="time"],
select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.9rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.readonly-input {
  background-color: rgba(255, 255, 255, 0.02) !important;
  color: var(--text-secondary);
  cursor: not-allowed;
  border-style: dashed;
}

.input-prefix-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-prefix-wrapper input {
  padding-right: 2.5rem;
}

.input-suffix {
  position: absolute;
  right: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.form-actions {
  margin-top: 1.5rem;
}

.btn-full {
  width: 100%;
}

/* Form Sections */
.form-section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--secondary);
  margin: 1.5rem 0 0.75rem 0;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid rgba(59, 130, 246, 0.2);
}

.form-section-title:first-of-type {
  margin-top: 0;
}

.calc-preview {
  padding: 0.5rem 0.75rem;
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
}

/* Total Banner inside Modal */
.total-banner {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(59, 130, 246, 0.1));
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 10px;
  padding: 1rem;
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.total-banner-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.total-banner-values {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.25rem;
  font-weight: 700;
}

.total-banner-values .separator {
  color: var(--text-muted);
  font-weight: 300;
}

/* --- VIEW: SETTINGS LAYOUT --- */
.settings-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 900px) {
  .settings-layout {
    grid-template-columns: 1fr;
  }
}

.backup-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.backup-actions {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.backup-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 12px;
}

@media (max-width: 600px) {
  .backup-item {
    flex-direction: column;
    align-items: flex-start;
  }
  .backup-item .btn {
    width: 100%;
  }
}

.backup-info h5 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.backup-info p {
  font-size: 0.8rem;
}

.backup-button-group {
  display: flex;
  gap: 0.5rem;
}

/* --- MODAL DIALOG --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(5, 7, 12, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  width: 650px;
  max-width: 95%;
  max-height: 90vh;
  background-color: #121824;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform var(--transition-normal);
}

.modal-overlay.active .modal-container {
  transform: scale(1);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.modal-close:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex-grow: 1;
}

.modal-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background-color: rgba(255, 255, 255, 0.01);
}

/* --- TOAST NOTIFICATIONS --- */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background-color: #1e293b;
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  padding: 0.75rem 1.25rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  z-index: 1000;
  transform: translateY(100px);
  opacity: 0;
  transition: transform var(--transition-normal), opacity var(--transition-normal);
  pointer-events: none;
}

.toast.active {
  transform: translateY(0);
  opacity: 1;
}

.toast-icon {
  color: var(--primary);
  font-size: 1.25rem;
}

.toast-message {
  font-size: 0.85rem;
  font-weight: 600;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}
