/* ============= Theme (tweak here) ============= */
:root{
  --bg: #101214;
  --card: #15181b;
  --card-2: #1b2024;
  --text: #e9eef2;
  --muted: #a9b4bf;
  --border: #2a2f36;
  --accent: #ff8a00;     /* primary orange */
  --accent-2: #ffb74d;   /* light orange for secondary lines */
  --ok: #27ae60;
  --warn: #f39c12;
  --err: #e74c3c;
  --shadow: rgba(0,0,0,.35);
}

/* ============= GitHub Pages Light Theme Compatibility ============= */
/* Override dark theme for GitHub Pages landing page elements */
.hero, .feature-card, .cta-section, .doc-link, .markdown-content {
  --text: #2c3e50;
  --muted: #666;
  --border: #e1e5e9;
  color: var(--text);
}

/* Override body background for GitHub Pages - detect based on presence of GitHub Pages specific elements */
body:has(.hero) {
  background: #ffffff !important;
  color: #2c3e50 !important;
}

/* Fallback for browsers that don't support :has() */
.main-nav ~ .container {
  background: #ffffff;
  color: #2c3e50;
}

/* Ensure text in GitHub Pages elements is readable */
.feature-card h3, 
.feature-card p,
.doc-link .doc-title,
.doc-link p,
.cta-section h2,
.cta-section p,
.cta-section ol,
.cta-section ol li,
.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content p,
.markdown-content li {
  color: #2c3e50 !important;
}

/* Ensure GitHub Pages footer is readable */
footer {
  color: #666 !important;
}

footer a {
  color: #0066cc !important;
}

/* Fix navigation for GitHub Pages */
.main-nav {
  background: #2a2f36;
  padding: 1rem 2rem;
  border-bottom: 1px solid #3a3f46;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.main-nav .nav-brand {
  display: flex;
  align-items: center;
  color: #ff8a00;
  font-size: 1.5rem;
  font-weight: bold;
}

.main-nav .nav-links {
  display: flex;
  gap: 2rem;
}

.main-nav .nav-links a {
  color: #e9eef2;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.main-nav .nav-links a:hover,
.main-nav .nav-links a.nav-active {
  background: #ff8a00;
  color: #1a1d21;
}

.nav-logo {
  width: 24px;
  height: 24px;
  margin-right: 8px;
}

.nav-title {
  font-weight: bold;
}

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

html,body{ height:100%; margin:0; padding:0; background:var(--bg); color:var(--text); font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji"; }

/* Navigation */
.navbar {
  background: #2a2f36;
  padding: 1rem 2rem;
  border-bottom: 1px solid #3a3f46;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-brand h1 {
  color: #ff8a00;
  font-size: 1.5rem;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 2rem;
}

.nav-links a {
  color: #e9eef2;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.nav-links a:hover,
.nav-links a.active,
.nav-links a.nav-active {
  background: #ff8a00;
  color: #1a1d21;
}

.nav-brand {
  display: flex;
  align-items: center;
  color: #ff8a00;
  font-size: 1.5rem;
  font-weight: bold;
}

/* Container */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem; /* Reduced padding to give more space */
}

/* GitHub Pages specific container styling */
.container .hero,
.container .feature-grid,
.container .cta-section,
.container .docs-grid {
  background: transparent;
}

/* Ensure readability for GitHub Pages content */
body .container {
  background: transparent;
}

/* Fix any potential issues with inherited dark styling */
.container section {
  color: inherit;
}

.container section h2,
.container section h3 {
  color: inherit;
}

/* Top section */
.top-section {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
  padding: 1.5rem 0;
}

.upload-section {
  min-width: 300px;
}

.stats-section {
  flex: 1;
}

/* Main layout */
.main-layout {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 2rem;
  min-height: 70vh; /* Ensures minimum height for the entire layout */
}

.map-section {
  min-width: 0; /* Allows map to shrink */
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.data-section {
  min-width: 400px;
  min-height: 600px; /* Ensures proper height for data section */
}

/* Tab system */
.tab-container {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 600px; /* Ensures proper height for tabs */
}

.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem; /* Increased spacing */
  background: var(--card-2);
  border-radius: 8px 8px 0 0;
}

.tab-btn {
  flex: 1;
  padding: 1rem 1.5rem; /* Increased padding */
  background: transparent;
  color: var(--muted);
  border: none;
  border-bottom: 3px solid transparent; /* Thicker border */
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
  font-size: 0.95rem;
}

.tab-btn:hover {
  color: var(--text);
  background: var(--card-3);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--card);
}

.tab-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem; /* Added padding inside content */
  background: var(--card);
  border-radius: 0 0 8px 8px;
  min-height: 500px; /* Ensures content area height */
}

.tab-pane {
  display: none;
  flex: 1;
  flex-direction: column;
}

.tab-pane.active {
  display: flex;
}

/* Pagination controls */
.pagination-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.nav-btn {
  padding: 0.5rem 1rem;
  background: var(--card-2);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
  min-width: 80px;
}

.nav-btn:hover:not(:disabled) {
  background: var(--accent);
  color: var(--card);
}

.nav-btn:disabled {
  background: var(--card);
  color: var(--muted);
  border-color: var(--border);
  cursor: not-allowed;
}

.page-info {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

/* Responsive layout */
@media (max-width: 1200px) {
  .main-layout {
    grid-template-columns: 1fr;
    min-height: auto; /* Allow flexible height on smaller screens */
  }
  
  .data-section {
    min-width: auto;
    min-height: 500px; /* Adjusted for smaller screens */
  }
  
  #map {
    height: 450px; /* Slightly smaller on medium screens */
    min-height: 450px;
  }
}

@media (max-width: 768px) {
  .top-section {
    grid-template-columns: 1fr;
    padding: 1rem 0;
  }
  
  .container {
    padding: 1rem;
  }
  
  .main-layout {
    gap: 1.5rem;
  }
}

.row{ display:grid; grid-template-columns: 1fr; gap:16px; }
@media(min-width: 900px){ .row{ grid-template-columns: 1fr 1fr; } }

h1,h2,h3{ margin: 0 0 12px; font-weight: 700; }
h2{ font-size: 1.25rem; }
a{ color: var(--accent); text-decoration: none; }
a:hover{ text-decoration: underline; }

/* Dashboard grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}

/* Cards */
.card {
  background: #2a2f36;
  border-radius: 8px;
  padding: 1.5rem;
  border: 1px solid #3a3f46;
}

.card h2 {
  color: #ff8a00;
  margin-bottom: 1rem;
  font-size: 1.25rem;
}

.view-all {
  display: inline-block;
  margin-top: 1rem;
  color: #ff8a00;
  text-decoration: none;
  font-size: 0.9rem;
}

.view-all:hover {
  text-decoration: underline;
}

/* Trip cards */
.trip-card {
  background: #2a2f36;
  border: 1px solid #3a3f46;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  cursor: pointer;
  transition: border-color 0.2s;
}

.trip-card:hover {
  border-color: #ff8a00;
}

.trip-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.trip-header h3 {
  color: #e9eef2;
  font-size: 1.1rem;
}

.trip-duration {
  color: #ff8a00;
  font-weight: 500;
}

.trip-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 1rem;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat .label {
  font-size: 0.8rem;
  color: #9ca3af;
  text-transform: uppercase;
}

.stat .value {
  font-weight: 500;
  color: #e9eef2;
}

/* Fuel cards */
.fuel-card {
  background: #2a2f36;
  border: 1px solid #3a3f46;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

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

.fuel-header h3 {
  color: #e9eef2;
  font-size: 1.1rem;
}

.fuel-actions {
  display: flex;
  gap: 0.5rem;
}

.fuel-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
}

.fuel-amount,
.fuel-cost,
.fuel-price,
.fuel-station,
.fuel-address,
.ocr-error {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.fuel-details .label {
  font-size: 0.8rem;
  color: #9ca3af;
  text-transform: uppercase;
}

.fuel-details .value {
  font-weight: 500;
  color: #e9eef2;
}

.error-text {
  color: #ef4444 !important;
  font-size: 0.9rem;
}

/* Statistics */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
}

.stat-item {
  text-align: center;
  padding: 1rem;
  background: #1a1d21;
  border-radius: 6px;
  border: 1px solid #3a3f46;
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  color: #9ca3af;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 600;
  color: #ff8a00;
}

/* Trip details */
.trip-details-container {
  background: #2a2f36;
  border: 1px solid #3a3f46;
  border-radius: 8px;
  padding: 1.5rem;
  margin-top: 2rem;
}

.trip-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
}

.detail-section h4 {
  color: #ff8a00;
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.detail-stats {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.detail-stat {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem;
  background: #1a1d21;
  border-radius: 4px;
}

.detail-stat .label {
  color: #9ca3af;
}

.detail-stat .value {
  font-weight: 500;
  color: #e9eef2;
}

/* Loading states */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 2rem;
  color: #9ca3af;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #3a3f46;
  border-top: 2px solid #ff8a00;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.button-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 1px solid #ffffff40;
  border-top: 1px solid #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 0.5rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading {
  text-align: center;
  padding: 2rem;
  color: #9ca3af;
}

/* Error states */
.error-message {
  background: #ef444420;
  border: 1px solid #ef4444;
  color: #ef4444;
  padding: 1rem;
  border-radius: 6px;
  text-align: center;
}

.no-data {
  text-align: center;
  color: #9ca3af;
  padding: 2rem;
  font-style: italic;
}

/* Upload status */
.upload-status {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-weight: 500;
  display: none;
}

.upload-status.info {
  background: #3b82f620;
  border: 1px solid #3b82f6;
  color: #3b82f6;
}

.upload-status.success {
  background: #10b98120;
  border: 1px solid #10b981;
  color: #10b981;
}

.upload-status.error {
  background: #ef444420;
  border: 1px solid #ef4444;
  color: #ef4444;
}

/* Buttons */
button {
  background: #ff8a00;
  color: #1a1d21;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

button:hover:not(:disabled) {
  background: #e67700;
}

button:disabled {
  background: #6b7280;
  cursor: not-allowed;
}

.retry-btn {
  background: #3b82f6;
  font-size: 0.8rem;
  padding: 0.4rem 0.8rem;
}

.retry-btn:hover:not(:disabled) {
  background: #2563eb;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
}

#page-info {
  color: #9ca3af;
  font-size: 0.9rem;
}

/* Form elements */
input[type="file"] {
  background: #2a2f36;
  border: 1px solid #3a3f46;
  border-radius: 6px;
  padding: 0.75rem;
  color: #e9eef2;
  width: 100%;
  margin-bottom: 1rem;
}

input[type="file"]:focus {
  outline: none;
  border-color: #ff8a00;
}

/* Responsive design */
@media (max-width: 768px) {
  .navbar {
    flex-direction: column;
    gap: 1rem;
  }

  .nav-links {
    gap: 1rem;
  }

  .container {
    padding: 1rem;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .trip-stats,
  .fuel-details {
    grid-template-columns: 1fr;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .trip-detail-grid {
    grid-template-columns: 1fr;
  }

  .pagination {
    flex-direction: column;
    gap: 0.5rem;
  }
}

/* Map styles */
#map {
  height: 500px; /* Increased from 400px */
  min-height: 500px; /* Increased from 400px */
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  margin-bottom: 1rem;
}

/* Table styles */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

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

th {
  background: var(--card-2);
  font-weight: 600;
  color: var(--accent);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  color: var(--text);
}

tr:hover td {
  background: var(--card-2);
}

/* Status message styling */
#status {
  min-height: 60px;
  display: flex;
  align-items: center;
  padding: 1rem;
  color: var(--muted);
  font-style: italic;
}

/* Dashboard grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin: 1.5rem 0;
}

/* Statistics grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  background: var(--card-2);
  border-radius: 8px;
  text-align: center;
}

.stat-label {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent);
}

/* Recent items styling */
.trip-item, .fuel-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--card-2);
  border-radius: 6px;
  border: 1px solid transparent;
  transition: border-color 0.2s;
}

.trip-item:hover, .fuel-item:hover {
  border-color: var(--accent);
}

.trip-info, .fuel-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.trip-date, .fuel-date {
  font-size: 0.9rem;
  color: var(--muted);
}

.fuel-station {
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 500;
}

.trip-device {
  font-size: 0.8rem;
  color: var(--muted);
}

.trip-stats, .fuel-details {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.fuel-amount {
  color: var(--accent-2);
  font-weight: 500;
}

.fuel-price-per-l {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 400;
}

.fuel-cost {
  color: var(--accent);
  font-weight: 600;
}

.trip-duration {
  color: var(--accent);
  font-weight: 500;
}

/* Make trip and fuel items clickable */
.trip-item, .fuel-item {
  cursor: pointer;
}

.trip-item:hover, .fuel-item:hover {
  border-color: var(--accent);
  background: var(--card);
}

/* Loading and error states */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem;
  color: var(--muted);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top: 2px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.error-message {
  color: var(--err);
  text-align: center;
  padding: 1rem;
  background: var(--card-2);
  border-radius: 6px;
  border: 1px solid var(--err);
}

.no-data {
  color: var(--muted);
  text-align: center;
  padding: 2rem;
  font-style: italic;
}

/* Responsive map */
@media (max-width: 768px) {
  #map {
    height: 350px; /* Increased from 300px for mobile */
    min-height: 350px;
  }
  
  .tab-content {
    padding: 0.75rem;
    min-height: 400px; /* Adjusted for mobile */
  }
  
  .tab-btn {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
  }
  
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  th, td {
    padding: 0.5rem;
    font-size: 0.9rem;
  }
}
