/* ═══════════════════════════════════════════════════
   CargoLens — Design System
   Inspired by Project44, Flexport, GoComet
   ═══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Brand */
  --navy: #0C447C;
  --ocean: #185FA5;
  --sky: #378ADD;
  --mist: #E6F1FB;
  --surface: #F1F5F9;
  --bg: #0B1120;
  --bg-card: rgba(255,255,255,0.04);
  --bg-card-hover: rgba(255,255,255,0.07);
  --border: rgba(255,255,255,0.08);
  --border-hover: rgba(55,138,221,0.3);
  --text: #E2E8F0;
  --text-dim: #64748B;
  --text-bright: #F8FAFC;

  /* Status */
  --green: #1D9E75;
  --green-bg: rgba(29,158,117,0.12);
  --amber: #BA7517;
  --amber-bg: rgba(186,117,23,0.12);
  --red: #A32D2D;
  --red-bg: rgba(163,45,45,0.12);

  /* Glass */
  --glass: rgba(255,255,255,0.03);
  --glass-border: rgba(255,255,255,0.06);
  --glass-blur: 20px;

  /* Sizing */
  --sidebar-w: 260px;
  --header-h: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { font-size: 14px; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ─── Background Gradient ─── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 10%, rgba(24,95,165,0.15), transparent),
    radial-gradient(ellipse 60% 40% at 80% 90%, rgba(12,68,124,0.1), transparent);
  pointer-events: none;
  z-index: 0;
}

a { color: var(--sky); text-decoration: none; }

/* ═══════ LOGIN PAGE ═══════ */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.login-card {
  width: 420px;
  padding: 48px 40px;
  background: rgba(255,255,255,0.04);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  animation: fadeUp 0.6s var(--ease);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.login-logo-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--ocean), var(--sky));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
  box-shadow: 0 4px 20px rgba(55,138,221,0.3);
}

.login-logo h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-bright);
  letter-spacing: -0.5px;
}

.login-logo span { color: var(--sky); }

.login-subtitle {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 28px;
  line-height: 1.5;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input, .form-group select {
  width: 100%;
  padding: 11px 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-bright);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
  outline: none;
}

.form-group input:focus, .form-group select:focus {
  border-color: var(--sky);
  box-shadow: 0 0 0 3px rgba(55,138,221,0.15);
}

.form-group input::placeholder { color: var(--text-dim); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s var(--ease);
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--ocean), var(--sky));
  color: #fff;
  box-shadow: 0 4px 16px rgba(55,138,221,0.25);
}

.btn-primary:hover {
  box-shadow: 0 6px 24px rgba(55,138,221,0.4);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover {
  border-color: var(--sky);
  color: var(--sky);
}

.btn-sm { padding: 7px 14px; font-size: 12px; }
.btn-danger { background: var(--red); color: #fff; }
.btn-success { background: var(--green); color: #fff; }

.login-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
}

.login-footer a { font-weight: 500; }

.login-error {
  background: var(--red-bg);
  border: 1px solid rgba(163,45,45,0.3);
  color: #FCA5A5;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

.login-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.login-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s var(--ease);
}

.login-tab.active {
  color: var(--sky);
  border-bottom-color: var(--sky);
}

/* ═══════ APP SHELL ═══════ */
.app-shell {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ─── Sidebar ─── */
.sidebar {
  width: var(--sidebar-w);
  background: rgba(255,255,255,0.02);
  backdrop-filter: blur(var(--glass-blur));
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform 0.3s var(--ease);
}

.sidebar-brand {
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--glass-border);
}

.sidebar-brand-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--ocean), var(--sky));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
}

.sidebar-brand h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-bright);
}

.sidebar-brand span { color: var(--sky); }

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-dim);
  padding: 16px 12px 8px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s var(--ease);
  margin-bottom: 2px;
}

.sidebar-link:hover {
  background: var(--bg-card-hover);
  color: var(--text);
}

.sidebar-link.active {
  background: rgba(55,138,221,0.1);
  color: var(--sky);
}

.sidebar-link .icon { font-size: 18px; width: 22px; text-align: center; }

.sidebar-link .badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.sidebar-user {
  padding: 16px 18px;
  border-top: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ocean), var(--sky));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: capitalize;
}

.sidebar-logout {
  cursor: pointer;
  color: var(--text-dim);
  font-size: 18px;
  transition: color 0.2s;
}
.sidebar-logout:hover { color: var(--red); }

/* ─── Main Content ─── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 28px 32px;
  min-height: 100vh;
}

/* ─── Header ─── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-bright);
  letter-spacing: -0.5px;
}

.page-header-sub {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ─── Stats Grid ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  transition: all 0.25s var(--ease);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--ocean), var(--sky));
  opacity: 0;
  transition: opacity 0.2s;
}

.stat-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.stat-card:hover::before { opacity: 1; }

.stat-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 14px;
}

.stat-icon.blue { background: rgba(55,138,221,0.12); color: var(--sky); }
.stat-icon.green { background: var(--green-bg); color: var(--green); }
.stat-icon.amber { background: var(--amber-bg); color: var(--amber); }
.stat-icon.red { background: var(--red-bg); color: var(--red); }

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-bright);
  letter-spacing: -1px;
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
  font-weight: 500;
}

.stat-change {
  font-size: 11px;
  margin-top: 8px;
  font-weight: 600;
}

.stat-change.up { color: var(--green); }
.stat-change.down { color: var(--red); }

/* ─── Cards / Panels ─── */
.panel {
  background: var(--bg-card);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
  overflow: hidden;
}

.panel-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-bright);
}

.panel-body { padding: 22px; }

/* ─── Tables ─── */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 14px 16px;
  font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  color: var(--text);
}

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

.data-table .mono {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: var(--sky);
}

/* ─── Badges ─── */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-status.on-time { background: var(--green-bg); color: var(--green); }
.badge-status.delayed { background: var(--amber-bg); color: var(--amber); }
.badge-status.critical { background: var(--red-bg); color: var(--red); }
.badge-status.pending { background: rgba(100,116,139,0.12); color: var(--text-dim); }
.badge-status.confirmed { background: rgba(55,138,221,0.12); color: var(--sky); }
.badge-status.in-transit { background: var(--green-bg); color: var(--green); }
.badge-status.arrived { background: rgba(55,138,221,0.12); color: var(--sky); }
.badge-status.cancelled { background: var(--red-bg); color: var(--red); }

.badge-role {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-role.admin { background: rgba(55,138,221,0.15); color: var(--sky); }
.badge-role.operator { background: var(--green-bg); color: var(--green); }
.badge-role.viewer { background: rgba(100,116,139,0.12); color: var(--text-dim); }

/* ─── Grid Layouts ─── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px; }

/* ─── Empty State ─── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}

.empty-state .icon { font-size: 48px; margin-bottom: 16px; opacity: 0.3; }
.empty-state h3 { font-size: 16px; color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: 13px; }

/* ─── Modal ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease);
}

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

.modal {
  width: 480px;
  max-height: 90vh;
  background: #111827;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-y: auto;
  transform: translateY(20px) scale(0.97);
  transition: transform 0.25s var(--ease);
}

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

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

.modal-header h3 { font-size: 16px; font-weight: 600; color: var(--text-bright); }

.modal-close {
  cursor: pointer;
  color: var(--text-dim);
  font-size: 20px;
  background: none;
  border: none;
}

.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ─── Spinner ─── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: var(--sky);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ─── Toast ─── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  animation: slideIn 0.3s var(--ease);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
.toast.info { background: var(--ocean); }

/* ─── Route Indicator ─── */
.route-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
}

.route-tag .arrow { color: var(--text-dim); }

/* ─── Animations ─── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Page transitions ─── */
.page { animation: fadeUp 0.35s var(--ease); }

/* ─── Responsive ─── */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 20px 16px; }
  .stats-grid { grid-template-columns: 1fr; }
  .login-card { width: 90%; padding: 32px 24px; }
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ═══════ HIDDEN UTILITY ═══════ */
.hidden { display: none !important; }
