/* ---------- GLOBAL RESET ---------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Segoe UI", Arial, sans-serif;
}

body {
  background: #f5f7fa;
  color: #333;
  line-height: 1.4;
  min-height: 100vh;
}

/* ---------- HEADER / TOPBAR ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #1e88e5;
  color: #fff;
  padding: 10px 20px;
}

.topbar .logo {
  display: flex;
  align-items: center;
  font-size: 20px;
  font-weight: bold;
}

.topbar .logo img {
  margin-right: 8px;
}

.topbar .actions button {
  margin-left: 10px;
  padding: 6px 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.topbar .actions button:hover {
  opacity: 0.9;
}

#btnSignOut {
  background: #e53935;
  color: white;
}

#btnExport {
  background: #43a047;
  color: white;
}

#btnAdminPage {
  background: #fbc02d;
  color: black;
}

/* ---------- FILTERS ---------- */
.filters {
  margin: 15px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filters label,
.filters input,
.filters button {
  font-size: 14px;
}

.dashboard-summary,
.dashboard-insights {
  margin: 15px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.summary-card,
.insight-card {
  padding: 16px;
  background: #ffffff;
  border: 1px solid #dbe6f7;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(13, 71, 161, 0.06);
}

.summary-label,
.insight-title {
  font-size: 0.95rem;
  color: #556b98;
  margin-bottom: 8px;
}

.summary-value,
.insight-value {
  font-size: 1.9rem;
  font-weight: 700;
  color: #0d47a1;
}

.insight-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.filters input[type="date"],
.filters input[type="text"] {
  padding: 5px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.filters button {
  padding: 6px 12px;
  background: #1e88e5;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.filters button:hover {
  background: #1565c0;
}

/* ---------- ADD ROW BUTTON ---------- */
.btn-green {
  margin: 10px 15px;
  padding: 8px 14px;
  background: #43a047;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
.btn-green:hover {
  background: #2e7d32;
}

/* ---------- TABLE ---------- */
.table-container {
  margin: 15px;
  overflow-x: auto;
  overflow-y: auto;
  border: 1px solid #ccc;
  max-height: 70vh;
  background: white;
  border-radius: 6px;
}

#tripTable {
  border-collapse: collapse;
  width: 100%;
  min-width: 800px;
}

#tripTable th,
#tripTable td {
  border: 1px solid #ddd;
  padding: 6px;
  text-align: center;
  min-width: 80px;
}

#tripTable thead th {
  position: sticky;
  top: 0;
  background: #0d47a1;
  color: white;
  z-index: 5;
}

/* Column resize handle */
#tripTable thead th div {
  background: transparent;
}
#tripTable thead th div:hover {
  background: rgba(0, 0, 0, 0.1);
}

/* Inputs inside table */
#tripTable input[type="date"],
#tripTable input[type="time"],
#tripTable input[type="number"],
#tripTable input[type="text"] {
  width: 100%;
  padding: 4px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

/* ---------- MODAL ---------- */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  animation: fadeIn 0.3s ease;
}
.modal.hidden {
  display: none;
}
@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}

.modal-content {
  background: white;
  padding: 20px;
  border-radius: 8px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.modal-content h3 {
  margin-bottom: 10px;
}

.modal-content button {
  margin: 5px;
  padding: 8px 14px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
}

#btnLocApply, #confirmYes {
  background: #1e88e5;
  color: white;
}
#btnLocCancel, #confirmNo {
  background: #e53935;
  color: white;
}

/* Scrollable location list */
#locationsOptions {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid #ccc;
  padding: 8px;
  border-radius: 4px;
  margin-bottom: 10px;
}

/* ---------- LOGIN PAGE ---------- */
.login-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: radial-gradient(circle at top left, rgba(59,130,246,0.22), transparent 22%),
              radial-gradient(circle at bottom right, rgba(16,185,129,0.18), transparent 20%),
              linear-gradient(135deg, #e0f2fe, #dbeafe);
  padding: 24px;
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 460px;
  background: rgba(255,255,255,0.96);
  padding: 38px 34px;
  border-radius: 28px;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.14);
  border: 1px solid rgba(59, 130, 246, 0.12);
  overflow: hidden;
}

.login-card::before {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  top: -70px;
  right: -60px;
  background: radial-gradient(circle, rgba(59,130,246,0.18), transparent 62%);
  border-radius: 50%;
  pointer-events: none;
}

.login-card::after {
  content: "";
  position: absolute;
  width: 140px;
  height: 140px;
  bottom: -55px;
  left: -55px;
  background: radial-gradient(circle, rgba(16,185,129,0.16), transparent 62%);
  border-radius: 50%;
  pointer-events: none;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}

.login-brand img {
  width: 72px;
  border-radius: 18px;
  background: #ffffff;
  padding: 8px;
  box-shadow: 0 12px 30px rgba(15,23,42,0.08);
}

.login-brand h1 {
  margin: 0;
  font-size: 26px;
  color: #0f172a;
}

.login-brand p {
  margin: 4px 0 0;
  color: #475569;
  font-size: 14px;
}

.login-form .form-title h2 {
  margin: 0 0 8px;
  font-size: 22px;
  color: #0f172a;
}

.login-form .form-title p {
  margin: 0 0 24px;
  color: #64748b;
  font-size: 14px;
}

.input-group {
  margin-bottom: 18px;
}

.input-group label {
  display: block;
  margin-bottom: 10px;
  color: #334155;
  font-size: 14px;
  font-weight: 700;
}

.input-group input {
  width: 100%;
  padding: 16px 18px;
  border: 1px solid #d1d9e6;
  border-radius: 14px;
  font-size: 15px;
  color: #0f172a;
  background: #f8fafc;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-group input:focus {
  outline: none;
  border-color: #0d47a1;
  box-shadow: 0 0 0 4px rgba(30, 64, 175, 0.08);
  background: #ffffff;
}

.password-field {
  position: relative;
}

.password-field input {
  width: 100%;
  padding-right: 56px;
}

.toggle-password {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: rgba(15, 23, 42, 0.04);
  width: 38px;
  height: 38px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 16px;
  color: #475569;
  display: grid;
  place-items: center;
}

.form-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #475569;
  font-size: 14px;
}

.checkbox-label input {
  width: 18px;
  height: 18px;
}

.form-row a {
  color: #1e88e5;
  text-decoration: none;
  font-size: 14px;
  white-space: nowrap;
}

.form-row a:hover {
  text-decoration: underline;
}

.login-error {
  display: none;
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
  padding: 14px 16px;
  border-radius: 14px;
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.6;
}

.login-error.visible {
  display: block;
}

.login-btn {
  width: 100%;
  padding: 16px 18px;
  background: linear-gradient(135deg, #0d47a1, #1e88e5);
  color: white;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 16px 30px rgba(30, 64, 175, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 20px 36px rgba(30, 64, 175, 0.22);
}

.login-footer {
  margin-top: 24px;
  text-align: center;
  color: #64748b;
  font-size: 14px;
}

.login-footer a {
  color: #0d47a1;
  text-decoration: none;
}

.login-footer a:hover {
  text-decoration: underline;
}

.login-meta {
  margin-top: 10px;
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
}

/* ---------- ADMIN PAGE ---------- */
.admin-container {
  margin: 20px;
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.admin-container h2 {
  margin-bottom: 15px;
  color: #1e88e5;
}

.admin-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin-bottom: 20px;
}

.admin-card {
  flex: 1 1 180px;
  min-width: 150px;
  padding: 18px;
  border-radius: 12px;
  background: linear-gradient(135deg, #0d47a1, #1976d2);
  color: white;
  box-shadow: 0 8px 20px rgba(13,71,161,0.12);
}

.admin-card .card-label {
  font-size: 0.9rem;
  opacity: 0.82;
  margin-bottom: 8px;
}

.admin-card .card-value {
  font-size: 2rem;
  font-weight: 700;
}

.admin-section {
  margin-bottom: 25px;
}

.admin-section h3 {
  margin-bottom: 10px;
  color: #333;
}

.admin-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.admin-row input,
.admin-row select {
  flex: 1;
  min-width: 180px;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
}

  .admin-row button.create,
  .admin-row button {
    padding: 10px 16px;
    background: #43a047;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
  }

  .admin-row button:hover,
  .admin-table button:hover {
    opacity: 0.95;
  }

  .admin-stats-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
  }

  .trip-stat {
    flex: 1;
    min-width: 180px;
    padding: 12px 14px;
    background: #e3f2fd;
    border-radius: 10px;
    color: #0d47a1;
    font-weight: 600;
  }

  #tripEditModal .modal-body {
    display: grid;
    gap: 12px;
  }

  #tripEditModal .modal-body label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 14px;
    color: #333;
  }

  #tripEditModal .modal-body input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
  }

  #tripEditModal .modal-actions {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
  }

  #tripEditModal .modal-actions button {
    padding: 10px 16px;
    border-radius: 6px;
  }

  #tripEditModal #cancelTripEdit {
    background: #e53935;
    color: white;
  }

  .admin-table button.editTrip {
    background: #1e88e5;
    color: white;
    margin-right: 6px;
  margin-top: 10px;
}

.admin-table th,
.admin-table td {
  border: 1px solid #ddd;
  padding: 10px;
  text-align: left;
  vertical-align: middle;
}

.admin-table th {
  background: #0d47a1;
  color: white;
}

.admin-table input[type="text"],
.admin-table input[type="password"] {
  width: 100%;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
}

.admin-table button {
  padding: 6px 10px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

.admin-table button.saveUser,
.admin-table button.saveLocation {
  background: #1e88e5;
  color: white;
  margin-right: 6px;
}

.admin-table button.deleteUser,
.admin-table button.deleteLocation,
.admin-table button.deleteTrip {
  background: #e53935;
  color: white;
}

@media (max-width: 900px) {
  .admin-row {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 768px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .filters {
    flex-direction: column;
  }

  .table-container {
    max-height: 60vh;
  }

  #tripTable {
    font-size: 12px;
    min-width: 600px;
  }

  .login-container {
    padding: 20px;
  }
}
