/* =====================================================
   ShipTrack — Global Stylesheet
   ===================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f1f5f9;
  color: #1e293b;
  line-height: 1.5;
}

a { color: inherit; }

/* ── Loading Overlay ── */
#loading-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.85);
  display: none; align-items: center; justify-content: center;
  z-index: 9999;
}
.spinner {
  width: 40px; height: 40px;
  border: 4px solid #e2e8f0;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Alert Box ── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
}
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; }
.alert-info    { background: #dbeafe; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* ── Sidebar ── */
.sidebar {
  width: 260px; min-height: 100vh;
  background: #0f172a; color: #cbd5e1;
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0;
  z-index: 100; overflow-y: auto;
}
.sidebar-header {
  padding: 20px 24px;
  border-bottom: 1px solid #1e293b;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: white;
  font-size: 18px; font-weight: 700;
}
.sidebar-nav { flex: 1; padding: 10px 0; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 24px;
  color: #94a3b8; text-decoration: none;
  font-size: 14px; transition: all 0.15s;
}
.sidebar-link:hover  { background: #1e293b; color: #f1f5f9; }
.sidebar-link.active { background: #1d4ed8; color: white; }
.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid #1e293b;
}
.sidebar-user { font-size: 13px; font-weight: 600; color: #f1f5f9; margin-bottom: 8px; }
.btn-logout {
  width: 100%; padding: 8px;
  background: transparent; border: 1px solid #374151;
  color: #94a3b8; border-radius: 6px; cursor: pointer;
  font-size: 13px; transition: all 0.15s;
}
.btn-logout:hover { background: #374151; color: white; }

/* ── Admin Layout ── */
.admin-layout { display: flex; min-height: 100vh; }
.admin-main { margin-left: 260px; flex: 1; }
.topbar {
  background: white; border-bottom: 1px solid #e2e8f0;
  padding: 0 24px; height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
  gap: 12px;
}
.topbar-title { font-size: 17px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.content { padding: 24px; }

/* ── Cards ── */
.card {
  background: white; border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid #f1f5f9;
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

/* ── Stat Cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: white; border-radius: 12px; padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.stat-icon { font-size: 24px; margin-bottom: 8px; }
.stat-value { font-size: 30px; font-weight: 700; color: #1e293b; }
.stat-label { font-size: 13px; color: #64748b; margin-top: 4px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px;
  font-size: 14px; font-weight: 500;
  cursor: pointer; border: none;
  transition: all 0.15s; text-decoration: none;
  white-space: nowrap;
}
.btn-primary   { background: #2563eb; color: white; }
.btn-primary:hover { background: #1d4ed8; }
.btn-success   { background: #16a34a; color: white; }
.btn-success:hover { background: #15803d; }
.btn-outline   { background: white; border: 1px solid #e2e8f0; color: #374151; }
.btn-outline:hover { background: #f8fafc; }
.btn-danger    { background: #dc2626; color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost     { background: transparent; color: #64748b; border: 1px solid transparent; }
.btn-ghost:hover { background: #f1f5f9; color: #1e293b; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-icon { padding: 6px 8px; border-radius: 6px; font-size: 16px; }

/* ── Forms ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
@media (max-width: 640px) {
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
}
.form-group { margin-bottom: 0; }
.form-label {
  display: block; font-size: 13px; font-weight: 500;
  color: #374151; margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid #e2e8f0; border-radius: 8px;
  font-size: 14px; color: #1e293b; background: white;
  transition: border 0.15s; font-family: inherit;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-textarea { resize: vertical; min-height: 90px; }
.form-section { border: 1px solid #e2e8f0; border-radius: 12px; padding: 20px; margin-bottom: 20px; }
.form-section-title { font-size: 14px; font-weight: 600; margin-bottom: 16px; color: #374151; }

/* ── Table ── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; padding: 10px 14px;
  font-size: 11px; font-weight: 700; color: #64748b;
  text-transform: uppercase; letter-spacing: 0.06em;
  background: #f8fafc; border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}
tbody td {
  padding: 12px 14px; font-size: 14px;
  border-bottom: 1px solid #f1f5f9; color: #374151;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }
.td-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ── Search bar ── */
.search-wrapper { position: relative; flex: 1; max-width: 320px; }
.search-wrapper .search-icon {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%); color: #94a3b8; pointer-events: none;
  width: 16px; height: 16px; display: block;
}
.search-wrapper input { padding-left: 34px; }
.filters-bar {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap; margin-bottom: 16px;
}

/* ── Badge / Status ── */
.badge {
  display: inline-block;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}

/* ── Detail grid ── */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.detail-item label { font-size: 11px; font-weight: 600; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.06em; }
.detail-item p { font-size: 14px; font-weight: 600; color: #1e293b; margin-top: 3px; }

/* ── Timeline ── */
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
  content: ''; position: absolute; left: 8px; top: 4px; bottom: 4px;
  width: 2px; background: #e2e8f0;
}
.tl-item { position: relative; padding-bottom: 20px; }
.tl-dot {
  position: absolute; left: -24px; top: 3px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #2563eb; border: 2px solid white;
  box-shadow: 0 0 0 2px #2563eb;
}
.tl-dot.pending { background: #e2e8f0; box-shadow: 0 0 0 2px #cbd5e1; }
.tl-date { font-size: 12px; color: #94a3b8; }
.tl-title { font-size: 14px; font-weight: 600; }
.tl-desc { font-size: 13px; color: #64748b; margin-top: 2px; }

/* ── Public Pages ── */
.pub-header {
  background: white; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 0 40px; height: 64px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.pub-logo {
  font-size: 20px; font-weight: 700; color: #1e293b;
  text-decoration: none; display: flex; align-items: center; gap: 8px;
}
.pub-nav a {
  color: #64748b; text-decoration: none;
  font-size: 14px; margin-left: 24px; font-weight: 500;
}
.pub-nav a:hover { color: #2563eb; }
.hero {
  background: linear-gradient(135deg, #0f172a 0%, #1e40af 100%);
  color: white; padding: 72px 40px; text-align: center;
}
.hero h1 { font-size: 44px; font-weight: 800; margin-bottom: 12px; }
.hero p { font-size: 18px; opacity: 0.8; margin-bottom: 36px; }
.track-box {
  background: white; border-radius: 16px; padding: 32px;
  max-width: 640px; margin: 0 auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.track-input-row { display: flex; gap: 10px; }
.track-input-row input {
  flex: 1; padding: 13px 16px;
  border: 2px solid #e2e8f0; border-radius: 10px;
  font-size: 15px; color: #1e293b; font-family: inherit;
}
.track-input-row input:focus { outline: none; border-color: #2563eb; }
.track-input-row button {
  padding: 13px 28px; background: #2563eb; color: white;
  border: none; border-radius: 10px;
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.track-input-row button:hover { background: #1d4ed8; }
.pub-section { max-width: 960px; margin: 0 auto; padding: 48px 24px; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-top: 32px; }
.feature-card {
  background: white; border-radius: 12px; padding: 24px;
  text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.feature-icon { font-size: 36px; margin-bottom: 12px; }
.feature-title { font-weight: 600; margin-bottom: 6px; }
.feature-desc { font-size: 13px; color: #64748b; }
.pub-footer {
  background: #0f172a; color: #94a3b8;
  padding: 60px 0 0;
  font-size: 13px;
  margin-top: 0;
}
.footer-grid {
  max-width: 1100px; margin: 0 auto;
  padding: 0 24px 40px;
  display: grid; grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 40px;
}
.footer-brand .footer-logo {
  font-size: 22px; font-weight: 700; color: #fff;
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
}
.footer-brand p { line-height: 1.6; max-width: 280px; color: #94a3b8; }
.footer-col h4 { color: #e2e8f0; font-size: 14px; font-weight: 600; margin-bottom: 14px; letter-spacing: 0.5px; }
.footer-col ul { list-style: none; padding: 0; margin: 0; }
.footer-col ul li { margin-bottom: 10px; }
.footer-col ul li a { color: #94a3b8; text-decoration: none; transition: color 0.2s; }
.footer-col ul li a:hover { color: #60a5fa; }
.footer-col .contact-item { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 10px; color: #94a3b8; }
.footer-col .contact-item span:first-child { font-size: 16px; flex-shrink: 0; }
.footer-bottom {
  border-top: 1px solid #1e293b;
  padding: 18px 24px; text-align: center; color: #475569; font-size: 12px;
}
.footer-bottom a { color: #60a5fa; text-decoration: none; }
@media (max-width: 768px) {
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 28px; }
  .footer-brand { grid-column: span 2; }
}

/* ── Track Result ── */
.track-result { max-width: 800px; margin: 0 auto; }
.track-header {
  background: white; border-radius: 12px; padding: 24px;
  margin-bottom: 20px; box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.track-number { font-size: 22px; font-weight: 700; color: #1e293b; }

/* ── Responsive ── */
/* 1366px laptops: tighten sidebar + table so invoice# fits on one line */
@media (max-width: 1400px) {
  .sidebar { width: 220px; }
  .admin-main { margin-left: 220px; }
  .content { padding: 16px 20px; }
  tbody td { font-size: 13px; padding: 10px 10px; }
  thead th { padding: 8px 10px; }
  .topbar { padding: 0 20px; }
}

/* Tablet */
@media (max-width: 992px) {
  .sidebar { width: 220px; }
  .admin-main { margin-left: 220px; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Mobile */
@media (max-width: 768px) {
  /* Sidebar Mobile */
  .sidebar { 
    width: 280px;
    transform: translateX(-100%); 
    transition: transform 0.3s ease;
    box-shadow: none;
  }
  .sidebar.open { 
    transform: translateX(0); 
    box-shadow: 4px 0 20px rgba(0,0,0,0.3);
  }
  .admin-main { margin-left: 0; }
  
  /* Mobile Overlay */
  .mobile-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
  }
  .mobile-overlay.show { display: block; }
  
  /* Mobile Menu Button */
  .mobile-menu-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    background: #f1f5f9;
    border: none;
    border-radius: 8px;
    font-size: 22px;
    cursor: pointer;
    margin-right: 12px;
    flex-shrink: 0;
  }
  .mobile-menu-btn:hover { background: #e2e8f0; }
  
  /* Topbar Mobile */
  .topbar { 
    padding: 0 12px; 
    gap: 8px;
    height: 56px;
  }
  .topbar-title { 
    font-size: 14px; 
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
  }
  .topbar-actions { 
    gap: 4px;
    flex-shrink: 0;
  }
  .topbar-actions .btn { 
    padding: 6px 10px; 
    font-size: 12px; 
  }
  .topbar-actions .btn-sm { padding: 5px 8px; }
  
  /* Content Mobile */
  .content { padding: 12px; }
  
  /* Cards Mobile */
  .card-body { padding: 16px; }
  .card-header { 
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }
  
  /* Tables Mobile */
  .table-wrapper { 
    margin: 0 -16px;
    border-radius: 0;
  }
  tbody td { padding: 10px 12px; font-size: 13px; }
  thead th { padding: 8px 12px; font-size: 10px; }
  
  /* Forms Mobile */
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; gap: 12px; }
  .form-section { padding: 16px; margin-bottom: 16px; }
  .form-input, .form-select, .form-textarea { padding: 10px 12px; font-size: 16px; }
  
  /* Detail Grid Mobile */
  .detail-grid { grid-template-columns: 1fr; gap: 12px; }
  
  /* Stats Mobile */
  .stats-grid { 
    grid-template-columns: 1fr 1fr; 
    gap: 10px;
  }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 24px; }
  .stat-label { font-size: 11px; }
  
  /* Buttons Mobile */
  .btn { padding: 10px 14px; }
  .btn-sm { padding: 8px 12px; }
  
  /* Filters Mobile */
  .filters-bar { 
    flex-direction: column; 
    align-items: stretch;
    gap: 10px;
  }
  .filters-bar .search-wrapper { 
    max-width: 100%; 
    width: 100%;
  }
  .filters-bar .btn { width: 100%; justify-content: center; }
  
  /* Public Header Mobile */
  .pub-header { padding: 0 16px; height: 56px; }
  .pub-logo { font-size: 16px; }
  .pub-nav { display: none; }
  .pub-nav-mobile { display: block; }
  
  /* Hero Mobile */
  .hero { padding: 32px 16px; }
  .hero h1 { font-size: 24px; }
  .hero p { font-size: 14px; margin-bottom: 24px; }
  .track-box { padding: 20px; border-radius: 12px; }
  .track-input-row { flex-direction: column; }
  .track-input-row input { padding: 12px 14px; }
  .track-input-row button { padding: 12px 20px; }
  
  /* Features Mobile */
  .features { grid-template-columns: 1fr; gap: 12px; }
  .feature-card { padding: 20px; }
  
  /* Footer Mobile */
  .footer-grid { 
    grid-template-columns: 1fr; 
    gap: 24px;
    padding: 0 16px 32px;
  }
  .footer-brand { grid-column: 1; }
  .pub-footer { padding-top: 40px; }
  
  /* Timeline Mobile */
  .timeline { padding-left: 24px; }
  
  /* Action Buttons in Tables */
  .td-actions { 
    flex-wrap: wrap; 
    gap: 4px;
  }
  .td-actions .btn { padding: 5px 8px; font-size: 12px; }
  
  /* Section Title Mobile */
  .section-title { font-size: 18px; }
}

/* Small Mobile */
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card { 
    display: flex; 
    align-items: center; 
    gap: 12px;
    padding: 12px 16px;
  }
  .stat-icon { margin-bottom: 0; font-size: 20px; }
  .stat-value { font-size: 20px; }
  
  .topbar-title { font-size: 13px; }
  
  .card-header { 
    flex-direction: column; 
    align-items: flex-start;
  }
  
  tbody td { padding: 8px 10px; font-size: 12px; }
  thead th { padding: 6px 10px; }
  
  .detail-grid { gap: 10px; }
  .detail-item p { font-size: 13px; }
}

/* Hide on mobile, show on desktop */
.mobile-menu-btn { display: none; }
.mobile-only { display: none; }
@media (max-width: 768px) {
  .mobile-only { display: block; }
  .desktop-only { display: none !important; }
}

/* ── Misc ── */
.text-muted { color: #64748b; font-size: 13px; }
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.empty-state { text-align: center; padding: 48px 24px; color: #94a3b8; }
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.section-title { font-size: 22px; font-weight: 700; margin-bottom: 20px; }
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: #64748b; text-decoration: none; font-size: 14px; margin-bottom: 16px;
}
.back-link:hover { color: #1e293b; }
.info-label { font-size: 12px; color: #94a3b8; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 3px; }
.info-value { font-size: 14px; font-weight: 500; color: #1e293b; }
