/* =========================================
   Cargo Boss — Design System
   ========================================= */

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

/* ── CSS Variables ── */
:root {
  --bg-primary:     #080b14;
  --bg-secondary:   #0d1222;
  --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-accent:  rgba(78, 158, 255, 0.35);

  --blue:           #4e9eff;
  --blue-dark:      #2d7dd6;
  --blue-glow:      rgba(78, 158, 255, 0.2);
  --amber:          #f5a623;
  --amber-dark:     #d4881a;
  --green:          #3ecf8e;
  --red:            #f65d5d;
  --purple:         #a78bfa;

  --text-primary:   #f0f4ff;
  --text-secondary: #8892b0;
  --text-muted:     #4a5568;

  --radius-sm:  6px;
  --radius-md:  12px;
  --radius-lg:  20px;
  --radius-xl:  28px;

  --shadow-sm:  0 2px 10px rgba(0,0,0,0.3);
  --shadow-md:  0 8px 30px rgba(0,0,0,0.4);
  --shadow-lg:  0 20px 60px rgba(0,0,0,0.5);
  --shadow-blue:0 0 40px rgba(78, 158, 255, 0.15);

  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { scroll-behavior: smooth; }

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

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--blue-dark); }

/* ── Background mesh ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 15% 10%, rgba(78, 158, 255, 0.07) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 85% 80%, rgba(167, 139, 250, 0.06) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ── Utility ── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  position: relative;
  z-index: 1;
}

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ── Typography ── */
h1, h2, h3, h4 { font-weight: 700; line-height: 1.2; }
h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
h3 { font-size: 1.2rem; }

.gradient-text {
  background: linear-gradient(135deg, #fff 0%, var(--blue) 60%, var(--purple) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: white;
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.btn:hover::after { opacity: 0.06; }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
  color: #fff;
  box-shadow: 0 4px 20px var(--blue-glow);
}
.btn-primary:hover {
  box-shadow: 0 6px 30px rgba(78, 158, 255, 0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
}
.btn-secondary:hover {
  border-color: var(--blue);
  background: var(--bg-card-hover);
}

.btn-danger {
  background: rgba(246, 93, 93, 0.12);
  color: var(--red);
  border: 1px solid rgba(246, 93, 93, 0.3);
}
.btn-danger:hover { background: rgba(246, 93, 93, 0.2); }

.btn-sm { padding: 7px 16px; font-size: 0.82rem; }
.btn-lg { padding: 16px 40px; font-size: 1.05rem; border-radius: var(--radius-lg); }
.btn-full { width: 100%; justify-content: center; }

/* ── Card ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: all var(--transition);
}
.card:hover { border-color: var(--border-accent); box-shadow: var(--shadow-blue); }

/* ── Form Elements ── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-label .required { color: var(--blue); margin-left: 2px; }

.form-control {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 11px 14px;
  transition: all var(--transition-fast);
  outline: none;
  width: 100%;
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:focus {
  border-color: var(--blue);
  background: rgba(78, 158, 255, 0.05);
  box-shadow: 0 0 0 3px rgba(78, 158, 255, 0.12);
}
.form-control.error {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(246, 93, 93, 0.12);
}
.form-error {
  font-size: 0.78rem;
  color: var(--red);
  display: none;
  align-items: center;
  gap: 4px;
}
.form-error.show { display: flex; }

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238892b0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

textarea.form-control { resize: vertical; min-height: 90px; }

/* ── Badge / Status ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-pending  { background: rgba(245, 166, 35, 0.15); color: var(--amber); }
.badge-transit  { background: rgba(78, 158, 255, 0.15); color: var(--blue); }
.badge-delivered{ background: rgba(62, 207, 142, 0.15); color: var(--green); }
.badge-cancelled{ background: rgba(246, 93, 93, 0.15);  color: var(--red); }

/* ── Divider ── */
.section-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 28px 0 20px;
}
.section-divider span {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--blue);
  white-space: nowrap;
}
.section-divider::before,
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Alert Messages ── */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.9rem;
}
.alert-success { background: rgba(62, 207, 142, 0.1); border: 1px solid rgba(62, 207, 142, 0.3); color: var(--green); }
.alert-error   { background: rgba(246, 93, 93, 0.1);  border: 1px solid rgba(246, 93, 93, 0.3);  color: var(--red); }

/* ── Spinner ── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
  font-size: 0.9rem;
}
.toast-icon { font-size: 1.2rem; flex-shrink: 0; }
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--blue); }
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Nav ── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(8, 11, 20, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
}
.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}
.logo-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 4px 14px var(--blue-glow);
}
.logo-text { font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em; }
.logo-text span { color: var(--blue); }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 36px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.97);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
  padding: 4px;
  transition: color var(--transition-fast);
}
.modal-close:hover { color: var(--text-primary); }

/* ── Stats Card ── */
.stat-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  margin-bottom: 6px;
}
.stat-number { font-size: 2.2rem; font-weight: 800; line-height: 1; }
.stat-label  { font-size: 0.8rem; color: var(--text-secondary); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }

/* ── Table ── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 14px 18px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
thead th:hover { color: var(--blue); }
thead th .sort-icon { margin-left: 4px; opacity: 0.5; }
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition-fast);
  cursor: pointer;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.03); }
tbody td {
  padding: 14px 18px;
  font-size: 0.9rem;
  color: var(--text-primary);
  vertical-align: middle;
}
tbody td .meta { font-size: 0.78rem; color: var(--text-secondary); margin-top: 2px; }

/* ── Status Select ── */
.status-select {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: inherit;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 28px 5px 10px;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%238892b0' d='M5 7L0 2h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color var(--transition-fast);
}
.status-select:focus { border-color: var(--blue); }

/* ── Search ── */
.search-bar {
  position: relative;
  max-width: 320px;
}
.search-bar .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.95rem;
}
.search-bar input {
  padding-left: 40px;
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state p { font-size: 0.95rem; color: var(--text-muted); margin-top: 8px; }

/* ── Auth Tabs ── */
.auth-tabs {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 24px;
}
.auth-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: calc(var(--radius-md) - 2px);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.auth-tab:hover { color: var(--text-primary); }
.auth-tab.active {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
}

/* ── Forgot password link ── */
.auth-forgot-link {
  color: var(--text-muted);
  font-size: 0.83rem;
  text-decoration: none;
  transition: color var(--transition-fast);
}
.auth-forgot-link:hover { color: var(--blue); }

/* ── Pending / success auth state ── */
.auth-pending-panel {
  text-align: center;
  padding: 12px 0 4px;
}
.auth-pending-icon { font-size: 2.5rem; margin-bottom: 16px; }
.auth-pending-panel h4 { font-size: 1.05rem; margin-bottom: 10px; }
.auth-pending-panel p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.65;
}

/* ── Reset Password page ── */
.rp-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.rp-card {
  width: 100%;
  max-width: 420px;
  padding: 48px 40px;
  text-align: center;
}
.rp-logo { display: flex; justify-content: center; margin-bottom: 28px; }
.rp-card h3 { font-size: 1.3rem; margin-bottom: 8px; }
.rp-card > p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin-bottom: 28px;
  line-height: 1.6;
}
.rp-spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: rp-spin 0.7s linear infinite;
  margin-bottom: 16px;
}
@keyframes rp-spin { to { transform: rotate(360deg); } }

/* ── Responsive ── */
@media (max-width: 768px) {
  .container { padding: 0 16px; }
  .modal { padding: 24px 20px; }
  .form-grid-2 { grid-template-columns: 1fr !important; }
  .form-grid-3 { grid-template-columns: 1fr !important; }
  .stats-grid  { grid-template-columns: repeat(2, 1fr) !important; }
  .btn-sm { padding: 11px 18px; font-size: 0.88rem; }
  .form-control { padding: 13px 14px; font-size: 1rem; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr !important; }
  .toast-container { left: 16px; right: 16px; bottom: 16px; }
  .toast { min-width: unset; }
}
