/* Modern CSS Variables for Light and Dark Mode */
:root {
  /* Light theme colors */
  --bg: #f8fafc;
  --text-color: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --primary-color: #3b82f6;
  --primary-dark: #2563eb;
  --primary-rgb: 59, 130, 246;
  --card-bg: #ffffff;
  --secondary-bg: #f1f5f9;
  --hover-bg: #e2e8f0;
  --input-bg: #ffffff;
  --success-color: #10b981;
  --danger-color: #ef4444;
  --warning-color: #f59e0b;
  
  /* Mobile-specific variables */
  --mobile-nav-height: 60px;
  --mobile-padding: 12px;
  --vh: 1vh;
}

[data-theme="dark"] {
  /* Dark theme colors */
  --bg: #0f172a;
  --text-color: #f1f5f9;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --primary-color: #60a5fa;
  --primary-dark: #3b82f6;
  --primary-rgb: 96, 165, 250;
  --card-bg: #1e293b;
  --secondary-bg: #334155;
  --hover-bg: #475569;
  --input-bg: #334155;
  --success-color: #34d399;
  --danger-color: #f87171;
  --warning-color: #fbbf24;
}

* {
  box-sizing: border-box;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-color);
  transition: background-color 0.3s ease, color 0.3s ease;
}

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100vh;
}

aside {
  background: var(--card-bg);
  border-right: 1px solid var(--border-color);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding: 12px 0;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.logo:hover {
  background: var(--hover-bg);
  transform: translateY(-1px);
}

.whistle-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.whistle-icon svg {
  width: 20px;
  height: 20px;
  color: white;
}

.whistle-icon:hover {
  transform: rotate(15deg) scale(1.05);
}

.logo h1 {
  font-family: 'Orbitron', 'Inter', sans-serif;
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.5px;
}

.nav-btn {
  background: none;
  border: 0;
  text-align: left;
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  transition: all 0.2s ease;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.nav-btn:hover {
  background: var(--hover-bg);
  color: var(--text-color);
}

.nav-btn.active {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
  font-weight: 600;
}

.spacer {
  flex: 1;
}

main {
  padding: 32px;
  overflow-y: auto;
  background: var(--bg);
  position: relative;
}

/* Profile Picture in Top Right */
.profile-picture {
  position: absolute;
  top: 24px;
  right: 32px;
  z-index: 100;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid var(--card-bg);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.avatar:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(var(--primary-rgb), 0.3);
}

.profile-dropdown {
  position: absolute;
  top: 50px;
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 8px 25px rgba(0,0,0,0.15);
  min-width: 150px;
  overflow: hidden;
  z-index: 1000;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  color: var(--text-color);
  font-size: 14px;
}

.dropdown-item:hover {
  background: var(--hover-bg);
}

.dropdown-item svg {
  color: var(--text-muted);
}

.screen {
  display: block;
}

.screen.hidden {
  display: none;
}

h2 {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 24px 0;
  color: var(--text-color);
}

h3 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 16px 0;
  color: var(--text-color);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  transition: all 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.muted {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 8px;
}

.section {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
}

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

.btn {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(var(--primary-rgb), 0.4);
}

.btn.secondary {
  background: transparent;
  color: var(--primary-color);
  border: 2px solid var(--primary-color);
}

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

.btn.btn-small {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
}

.name-edit-container {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1;
}

.name-edit-container input {
  flex: 1;
  margin: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}

th, td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

td input[type="checkbox"] {
  margin: 0;
  width: auto;
  padding: 0;
  cursor: pointer;
  transform: scale(1.2);
  accent-color: var(--primary-color);
}

th {
  background: var(--secondary-bg);
  font-weight: 600;
  color: var(--text-color);
}

.filters {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filters select,
.filters input {
  padding: 8px 12px;
  border: 2px solid var(--border-color);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text-color);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

label {
  font-weight: 500;
  color: var(--text-color);
  margin-bottom: 6px;
  display: block;
}

input, textarea, select {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text-color);
  font-size: 16px;
  transition: border-color 0.2s ease;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary-color);
}

.hidden {
  display: none;
}

/* Dark Mode Toggle */
.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
}

.setting-item .profile-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.toggle-container {
  position: relative;
}

.toggle-input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-label {
  display: block;
  width: 50px;
  height: 24px;
  background: var(--border-color);
  border-radius: 12px;
  cursor: pointer;
  position: relative;
  transition: background-color 0.3s ease;
}

.toggle-slider {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s ease;
}

.toggle-input:checked + .toggle-label {
  background: var(--primary-color);
}

.toggle-input:checked + .toggle-label .toggle-slider {
  transform: translateX(26px);
}

/* Receipt Photo Styles */
.photo-upload {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.photo-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
}

#receiptInput {
  display: none;
}

.receipt-preview {
  position: relative;
  display: inline-block;
  width: fit-content;
}

.receipt-preview img {
  max-width: 200px;
  max-height: 150px;
  border-radius: 8px;
  border: 2px solid var(--border-color);
}

.btn-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--danger-color);
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.receipt-thumbnail {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.receipt-thumbnail:hover {
  transform: scale(1.1);
}

.receipt-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: pointer;
}

.receipt-modal img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
}

.close-modal {
  position: absolute;
  top: 20px;
  right: 20px;
  background: var(--danger-color);
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.right {
  text-align: right;
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.modal.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-content {
  background: var(--card-bg);
  border-radius: 12px;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  transform: scale(1);
  transition: transform 0.3s ease;
}

.modal.hidden .modal-content {
  transform: scale(0.95);
}

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

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.btn-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.btn-close:hover {
  color: var(--text-color);
  background: var(--hover-bg);
}

.modal-body {
  padding: 24px;
}

.modal-info {
  margin: 0 0 20px 0;
  color: var(--text-muted);
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.modal-actions .btn {
  flex: 1;
}

/* Toast Notification */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--success-color);
  color: white;
  padding: 16px 20px;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  z-index: 1001;
  transform: translateX(400px);
  transition: transform 0.3s ease;
}

.toast.show {
  transform: translateX(0);
}

.toast.error {
  background: var(--danger-color);
}

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

/* Mobile Responsive */
@media (max-width: 768px) {
  /* Use mobile-friendly viewport units */
  html {
    height: calc(var(--vh, 1vh) * 100);
  }
  
  body.mobile-device {
    font-size: 16px; /* Prevent zoom on iOS */
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
  }
  
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--mobile-nav-height) 1fr;
    height: calc(var(--vh, 1vh) * 100);
  }
  
  /* Mobile Navigation */
  aside {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding: var(--mobile-padding);
    height: var(--mobile-nav-height);
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--card-bg);
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
  }
  
  aside::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
  }
  
  .logo {
    display: none; /* Hide logo on mobile to save space */
  }
  
  .nav-btn {
    white-space: nowrap;
    margin-right: 8px;
    margin-bottom: 0;
    padding: 8px 12px;
    font-size: 14px;
    min-width: auto;
    flex-shrink: 0;
    border-radius: 20px;
    position: relative;
  }
  
  .nav-btn.active {
    background: var(--primary-color);
    color: white;
    font-weight: 500;
  }
  
  .nav-btn.active::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 6px;
    background: var(--primary-color);
    border-radius: 50%;
  }
  
  .spacer {
    display: none; /* Remove spacer on mobile */
  }
  
  /* Mobile Main Content */
  main {
    padding: 16px 12px;
    overflow-x: hidden;
  }
  
  /* Mobile Profile */
  .profile-picture {
    top: 12px;
    right: 12px;
    z-index: 101;
  }
  
  .avatar {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }
  
  /* Mobile Cards */
  .cards {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  
  .card {
    padding: 16px 12px;
  }
  
  /* Mobile Forms */
  .grid-2 {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .filters {
    flex-direction: column;
    gap: 12px;
  }
  
  .filters select,
  .filters input {
    width: 100%;
  }
  
  /* Mobile Tables */
  table {
    font-size: 14px;
    min-width: 100%;
  }
  
  table th,
  table td {
    padding: 8px 4px;
    white-space: nowrap;
  }
  
  /* Hide less important columns on mobile */
  table th:nth-child(3),
  table td:nth-child(3),
  table th:nth-child(4),
  table td:nth-child(4) {
    display: none;
  }
  
  /* Mobile Buttons */
  .btn {
    padding: 12px 16px;
    font-size: 14px;
  }
  
  .btn-small {
    padding: 8px 12px;
    font-size: 13px;
  }
  
  /* Mobile Sections */
  .section {
    margin-bottom: 24px;
  }
  
  .section h3 {
    font-size: 18px;
    margin-bottom: 16px;
  }
  
  /* Mobile Screen Headers */
  h2 {
    font-size: 24px;
    margin-bottom: 20px;
  }
  
  /* Mobile Flex Containers */
  .flex {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }
  
  .flex button {
    order: -1; /* Put buttons at top on mobile */
  }
  
  /* Mobile Modal Adjustments */
  .modal-content {
    width: 95%;
    margin: 20px auto;
  }
  
  .modal-body {
    padding: 20px;
  }
  
  .modal-header {
    padding: 20px 20px 16px 20px;
  }
  
  .modal-actions {
    flex-direction: column;
  }
  
  /* Mobile Toast */
  .toast {
    right: 10px;
    left: 10px;
    top: 10px;
    transform: translateY(-100px);
  }
  
  .toast.show {
    transform: translateY(0);
  }
  
  /* Mobile Settings */
  .setting-item {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  
  .name-edit-container {
    flex-direction: column;
    gap: 8px;
  }
  
  .toggle-container {
    align-self: flex-start;
  }
  
  /* Mobile Dashboard Specific */
  #upcomingTable th:nth-child(3),
  #upcomingTable td:nth-child(3) {
    display: table-cell; /* Show location on dashboard */
  }
  
  #upcomingTable th:nth-child(4),
  #upcomingTable td:nth-child(4) {
    display: table-cell; /* Show pay on dashboard */
  }
  
  /* Mobile Games Table - Show essential columns */
  #gamesTable th:nth-child(3),
  #gamesTable td:nth-child(3) {
    display: none; /* Hide league */
  }
  
  #gamesTable th:nth-child(4),
  #gamesTable td:nth-child(4) {
    display: none; /* Hide teams */
  }
  
  /* Mobile Mileage/Expense Tables */
  #mileageTable th:nth-child(3),
  #mileageTable td:nth-child(3),
  #expensesTable th:nth-child(4),
  #expensesTable td:nth-child(4),
  #expensesTable th:nth-child(5),
  #expensesTable td:nth-child(5) {
    display: none;
  }
  
  /* Mobile Form Improvements */
  input, select, textarea {
    font-size: 16px; /* Prevent zoom on iOS */
    padding: 12px;
  }
  
  label {
    font-weight: 500;
    margin-bottom: 6px;
  }
  
  /* Mobile Photo Upload */
  .photo-upload {
    text-align: center;
  }
  
  .photo-btn {
    width: 100%;
    padding: 16px;
  }
  
  /* Mobile Install Button */
  .install-btn {
    bottom: 80px !important; /* Account for mobile browser UI */
    right: 16px !important;
    left: 16px !important;
    width: auto !important;
  }
  
  /* Mobile Table Scroll Indicator */
  .table-container {
    overflow-x: auto;
    position: relative;
  }
  
  .table-container::after {
    content: '← Scroll to see more →';
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
  }
  
  /* Better mobile touch targets */
  button, .nav-btn, input[type="checkbox"] {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Mobile-specific spacing */
  .screen {
    padding-bottom: 60px; /* Extra space at bottom for better scrolling */
  }
  
  /* Mobile checkbox styling */
  input[type="checkbox"] {
    transform: scale(1.2);
    margin: 0 8px;
  }
  
  /* Improve mobile readability */
  .muted {
    font-size: 13px;
  }
  
  /* Mobile-friendly sync status */
  .sync-status {
    bottom: 20px;
    left: 12px;
    right: 12px;
    text-align: center;
    padding: 8px 12px;
    font-size: 13px;
  }
}
