/* ===================
   ADMIN PANEL STYLES
   =================== */

body.admin-body {
  background: var(--gray-100);
  font-family: 'Inter', sans-serif;
}

/* LOGIN */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0d2b0e 0%, #1a4a1d 60%, #245228 100%);
  position: relative; overflow: hidden;
}
.login-screen::before {
  content: ''; position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Ccircle cx='30' cy='30' r='4'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.login-card {
  background: var(--white); border-radius: var(--radius-xl);
  padding: 50px 44px; width: 100%; max-width: 420px;
  box-shadow: var(--shadow-2xl); position: relative; z-index: 1;
  text-align: center;
}
.login-logo { height: 64px; margin: 0 auto 8px; }
.login-card h2 { font-size: 1.3rem; font-weight: 800; color: var(--gray-900); margin-bottom: 6px; }
.login-card p { font-size: 0.88rem; color: var(--gray-500); margin-bottom: 32px; }
.login-input-wrap { position: relative; margin-bottom: 16px; }
.login-input-wrap input {
  width: 100%; padding: 14px 48px 14px 16px;
  border: 2px solid var(--gray-200); border-radius: var(--radius-md);
  font-size: 1rem; color: var(--gray-800); transition: border-color 0.2s;
}
.login-input-wrap input:focus { border-color: var(--green-500); }
.login-btn {
  width: 100%; padding: 14px;
  background: linear-gradient(135deg, var(--green-700), var(--green-500));
  color: #fff; font-weight: 700; font-size: 1rem;
  border-radius: var(--radius-md); transition: all 0.2s;
  box-shadow: 0 4px 14px rgba(45,106,48,0.4);
}
.login-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(45,106,48,0.5); }
.login-error { color: #e53e3e; font-size: 0.82rem; margin-bottom: 10px; display: none; }
.login-error.show { display: block; }
.login-hint { font-size: 0.78rem; color: var(--gray-400); margin-top: 14px; }

/* ADMIN LAYOUT */
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--green-900); color: #fff;
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
  transition: transform 0.3s;
}
.sidebar-logo-wrap { padding: 24px 20px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-logo { height: 46px; filter: brightness(0) invert(1); }
.sidebar-label { font-size: 0.65rem; font-weight: 700; letter-spacing: 0.15em; text-transform: uppercase; color: rgba(255,255,255,0.4); padding: 20px 20px 8px; }
.sidebar-nav { flex: 1; padding: 4px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-md);
  font-size: 0.9rem; font-weight: 500; color: rgba(255,255,255,0.7);
  cursor: pointer; transition: all 0.2s;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.15); color: #fff; font-weight: 600; }
.nav-item .ni-icon { font-size: 1.1rem; width: 22px; text-align: center; flex-shrink: 0; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.1); }
.logout-btn { display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,0.6); font-size: 0.88rem; font-weight: 500; cursor: pointer; transition: color 0.2s; background: none; width: 100%; }
.logout-btn:hover { color: #fff; }

.admin-main { margin-left: 240px; flex: 1; min-height: 100vh; }
.admin-topbar {
  background: var(--white); border-bottom: 1px solid var(--gray-200);
  padding: 16px 32px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 40;
}
.topbar-title { font-size: 1.1rem; font-weight: 700; color: var(--gray-900); }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-date { font-size: 0.85rem; color: var(--gray-500); }
.topbar-badge { background: var(--green-100); color: var(--green-700); font-size: 0.78rem; font-weight: 700; padding: 4px 10px; border-radius: var(--radius-full); }
.refresh-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-full);
  background: var(--green-50); border: 1px solid var(--green-300);
  color: var(--green-700); font-weight: 600; font-size: 0.82rem;
  cursor: pointer; transition: all 0.2s;
}
.refresh-btn:hover { background: var(--green-100); transform: scale(1.03); }
.refresh-btn.spinning { animation: spin 0.6s linear; }
@keyframes spin { to { transform: rotate(360deg); } }
.action-btn.delete { background: #fef2f2; color: #b91c1c; border-color: #fca5a5; }
.action-btn.delete:hover { background: #fee2e2; }
.admin-content { padding: 32px; }

/* ADMIN TABS */
.admin-view { display: none; }
.admin-view.active { display: block; animation: fadeIn 0.3s ease; }

/* STATS CARDS */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 32px; }
.stat-card {
  background: var(--white); border-radius: var(--radius-lg);
  padding: 24px; box-shadow: var(--shadow-sm); border: 1px solid var(--gray-200);
  display: flex; flex-direction: column; gap: 8px;
}
.stat-card .s-label { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gray-500); }
.stat-card .s-value { font-size: 2rem; font-weight: 800; color: var(--gray-900); }
.stat-card .s-sub { font-size: 0.8rem; color: var(--gray-500); }
.stat-icon { font-size: 1.6rem; margin-bottom: 4px; }

/* CALENDAR */
.calendar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.cal-nav-btn {
  width: 36px; height: 36px; border-radius: var(--radius-full);
  background: var(--white); border: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 1rem; transition: all 0.2s;
}
.cal-nav-btn:hover { background: var(--green-50); border-color: var(--green-400); }
.cal-month-title { font-size: 1.1rem; font-weight: 700; color: var(--gray-900); }
.calendar-grid {
  background: var(--white); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm); border: 1px solid var(--gray-200); overflow: hidden;
}
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--gray-50); border-bottom: 1px solid var(--gray-200); }
.cal-weekday { padding: 12px; text-align: center; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gray-500); }
.cal-days { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-day {
  min-height: 110px; padding: 10px; border-right: 1px solid var(--gray-100); border-bottom: 1px solid var(--gray-100);
  position: relative; transition: background 0.15s;
}
.cal-day:hover { background: var(--gray-50); }
.cal-day.other-month { opacity: 0.35; }
.cal-day.today .day-num { background: var(--green-600); color: #fff; }
.day-num {
  width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 600; color: var(--gray-700); margin-bottom: 6px;
}
.cal-event {
  font-size: 0.7rem; font-weight: 600; padding: 3px 6px; border-radius: 4px;
  margin-bottom: 3px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: opacity 0.2s;
}
.cal-event:hover { opacity: 0.8; }
.cal-event.basic   { background: #d1fae5; color: #065f46; }
.cal-event.regular { background: #dbeafe; color: #1e40af; }
.cal-event.premium { background: #fef3c7; color: #92400e; }

/* BOOKINGS TABLE */
.table-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.table-search {
  padding: 10px 16px; border: 1px solid var(--gray-200); border-radius: var(--radius-md);
  font-size: 0.9rem; width: 280px; color: var(--gray-800); background: var(--white);
}
.table-filter { padding: 10px 14px; border: 1px solid var(--gray-200); border-radius: var(--radius-md); font-size: 0.85rem; background: var(--white); color: var(--gray-700); }
.bookings-table-wrap { background: var(--white); border-radius: var(--radius-xl); box-shadow: var(--shadow-sm); border: 1px solid var(--gray-200); overflow: hidden; }
.bookings-table { width: 100%; border-collapse: collapse; }
.bookings-table th { padding: 14px 18px; text-align: left; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gray-500); background: var(--gray-50); border-bottom: 1px solid var(--gray-200); }
.bookings-table td { padding: 14px 18px; font-size: 0.88rem; color: var(--gray-800); border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.bookings-table tr:last-child td { border-bottom: none; }
.bookings-table tr:hover td { background: var(--gray-50); }
.tier-badge { display: inline-block; padding: 3px 10px; border-radius: var(--radius-full); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.tier-badge.basic   { background: #d1fae5; color: #065f46; }
.tier-badge.regular { background: #dbeafe; color: #1e40af; }
.tier-badge.premium { background: #fef3c7; color: #92400e; }
.status-badge { display: inline-block; padding: 3px 10px; border-radius: var(--radius-full); font-size: 0.72rem; font-weight: 700; }
.status-badge.pending   { background: #fef3c7; color: #92400e; }
.status-badge.confirmed { background: #d1fae5; color: #065f46; }
.status-badge.completed { background: var(--gray-100); color: var(--gray-600); }
.status-badge.cancelled { background: #fee2e2; color: #991b1b; }
.action-btn { padding: 5px 12px; border-radius: var(--radius-full); font-size: 0.75rem; font-weight: 600; cursor: pointer; transition: all 0.15s; margin-right: 4px; border: 1px solid; }
.action-btn.complete { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.action-btn.complete:hover { background: #a7f3d0; }
.action-btn.cancel   { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.action-btn.cancel:hover   { background: #fecaca; }
.action-btn.confirm  { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.action-btn.confirm:hover  { background: #bfdbfe; }

/* EMPTY STATE */
.empty-state { text-align: center; padding: 60px 20px; color: var(--gray-500); }
.empty-state .empty-icon { font-size: 3rem; display: block; margin-bottom: 12px; opacity: 0.5; }
.empty-state h4 { font-size: 1rem; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }

/* MODAL */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px); z-index: 200;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-card {
  background: var(--white); border-radius: var(--radius-xl);
  padding: 36px; max-width: 440px; width: 90%;
  box-shadow: var(--shadow-2xl); transform: scale(0.95); transition: transform 0.3s;
}
.modal-overlay.open .modal-card { transform: scale(1); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.modal-title { font-size: 1.1rem; font-weight: 700; color: var(--gray-900); }
.modal-close { background: var(--gray-100); border: none; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 1.1rem; display: flex; align-items: center; justify-content: center; }
.modal-close:hover { background: var(--gray-200); }
.modal-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--gray-100); font-size: 0.9rem; }
.modal-row:last-of-type { border: none; }
.modal-row .ml { color: var(--gray-500); }
.modal-row .mr { font-weight: 600; color: var(--gray-900); }

/* ROUTE PLANNER */
.route-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 16px;
}
.route-start-wrap {
  background: var(--white); border-radius: var(--radius-lg);
  padding: 20px 24px; margin-bottom: 24px;
  border: 1px solid var(--gray-200); box-shadow: var(--shadow-sm);
}
.route-loading {
  text-align: center; padding: 60px 20px;
}
.route-spinner {
  width: 48px; height: 48px; border: 4px solid var(--gray-200);
  border-top-color: var(--green-600); border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.route-loading p { font-size: 0.9rem; color: var(--gray-500); }

.route-summary {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 28px;
}
.route-stat {
  background: var(--white); border-radius: var(--radius-lg);
  padding: 20px; text-align: center;
  border: 1px solid var(--gray-200); box-shadow: var(--shadow-sm);
}
.route-stat .rs-icon { font-size: 1.5rem; display: block; margin-bottom: 8px; }
.route-stat .rs-val { font-size: 1.6rem; font-weight: 800; color: var(--gray-900); display: block; }
.route-stat .rs-lbl { font-size: 0.78rem; color: var(--gray-500); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }

.route-maps-cta {
  text-align: center; margin-bottom: 32px;
  background: linear-gradient(135deg, var(--green-900), var(--green-700));
  border-radius: var(--radius-xl); padding: 36px 24px;
  box-shadow: var(--shadow-lg);
}
.route-maps-cta .btn-primary {
  background: linear-gradient(135deg, var(--gold-500), #e09400);
  color: #1a3a1a; font-weight: 800; display: inline-flex;
  box-shadow: 0 4px 20px rgba(245,166,35,0.4);
  text-decoration: none;
}
.route-maps-cta .btn-primary:hover {
  box-shadow: 0 8px 30px rgba(245,166,35,0.55); transform: translateY(-3px);
}

.route-stops-list { display: flex; flex-direction: column; gap: 12px; }
.route-stop-card {
  display: flex; align-items: center; gap: 16px;
  background: var(--white); border-radius: var(--radius-lg);
  padding: 18px 22px; border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm); transition: all 0.2s;
  position: relative;
}
.route-stop-card:hover { box-shadow: var(--shadow-md); transform: translateX(4px); }
.route-stop-card.start-card { border-color: var(--green-400); background: var(--green-50); }
.stop-number {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--green-600), var(--green-500));
  color: #fff; font-weight: 800; font-size: 0.95rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; box-shadow: 0 2px 8px rgba(45,106,48,0.3);
}
.stop-number.start-num { background: linear-gradient(135deg, var(--gold-500), #e09400); color: #1a3a1a; }
.stop-info { flex: 1; }
.stop-info .stop-name { font-weight: 700; font-size: 0.95rem; color: var(--gray-900); }
.stop-info .stop-addr { font-size: 0.85rem; color: var(--gray-500); margin-top: 2px; }
.stop-meta {
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
}
.stop-meta .tier-badge { font-size: 0.7rem; }
.stop-dist {
  font-size: 0.78rem; color: var(--gray-500); font-weight: 600;
  background: var(--gray-100); padding: 4px 10px; border-radius: var(--radius-full);
}

/* RESPONSIVE ADMIN */
@media (max-width: 1024px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px) {
  /* Hide sidebar branding and logout on mobile */
  .sidebar-logo-wrap, .sidebar-label, .sidebar-footer { display: none; }
  
  /* Convert sidebar to a fixed bottom nav */
  .admin-sidebar {
    transform: none;
    position: fixed;
    top: auto; bottom: 0; left: 0; right: 0;
    width: 100%; height: 60px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex; flex-direction: row; align-items: center; justify-content: center;
    padding: 0; z-index: 999;
  }
  
  .sidebar-nav {
    display: flex; flex-direction: row; width: 100%;
    justify-content: space-around; padding: 0; margin: 0;
  }
  
  .nav-item {
    flex-direction: column; padding: 8px 4px; gap: 4px;
    text-align: center; border-radius: 0; flex: 1; margin: 0;
  }
  .nav-item .ni-icon { width: auto; font-size: 1.2rem; }
  .nav-item .ni-label { font-size: 0.65rem; }
  
  /* Adjust main container to leave room for bottom nav */
  .admin-main { margin-left: 0; margin-bottom: 60px; min-height: calc(100vh - 60px); }
  
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .admin-content { padding: 16px; }
  .admin-topbar { padding: 16px; flex-wrap: wrap; gap: 12px; }
  
  /* Allow horizontal scrolling on large elements */
  .bookings-table-wrap { overflow-x: auto; }
  .calendar-grid { overflow-x: auto; }
  .cal-weekdays { min-width: 500px; }
  .cal-days { min-width: 500px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .route-summary { grid-template-columns: 1fr; }
  .table-search { width: 100%; }
}
