/* ===================================================================
   PACKAGE TRACKER SPECIFIC STYLES — tracking/index.html
   =================================================================== */

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-body);
  color: var(--text-main);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.4s ease, color 0.4s ease;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* --- HEADER & CONTROLS --- */
.app-header {
  background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  padding: 20px 0;
  border-bottom: 1px solid rgba(240, 237, 229, 0.1);
  margin-bottom: 40px;
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background-color 0.4s ease, border-color 0.4s ease;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-group {
  display: flex;
  flex-direction: column;
}

.brand-group h1 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0;
  color: #F0EDE5 !important;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-group h1 .gradient-text {
  background: none;
  -webkit-text-fill-color: initial;
  color: inherit;
}

.brand-group .subtitle {
  color: #c4bfb0;
  font-size: 0.82rem;
  font-weight: 500;
  margin: 4px 0 0 0;
}

.brand-group .last-updated {
  color: #c4bfb0;
  opacity: 0.85;
  font-size: 0.72rem;
  margin-top: 4px;
  font-family: 'Inter', monospace;
}

/* --- HEADER BUTTONS SPECIFIC --- */
.app-header .btn {
  background: transparent;
  color: #F0EDE5 !important;
  border: 1px solid transparent;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.app-header .btn:hover {
  background-color: #49628d;
  color: #F0EDE5 !important;
  border-color: transparent;
}

.app-header .btn svg {
  fill: currentColor;
}

.app-header .theme-btn {
  background-color: rgba(240, 237, 229, 0.15);
  color: #F0EDE5;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.app-header .theme-btn:hover {
  background-color: rgba(240, 237, 229, 0.3);
  color: #F0EDE5;
  transform: scale(1.1) rotate(15deg);
}

/* --- SUMMARY --- */
.summary {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.summary-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 24px;
  text-align: center;
  min-width: 120px;
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
}

.summary-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-hover);
}

.summary-num {
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-family: 'Inter', monospace;
}

.summary-label {
  font-size: 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
  font-family: 'Inter', monospace;
}

/* --- BUTTONS --- */
.btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  box-shadow: var(--shadow);
}

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

/* --- PACKAGE GRID & CARDS --- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 20px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

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

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}

.card.delivered::before {
  background: var(--accent-green);
}

.card.in-transit::before {
  background: var(--accent-yellow);
}

.card.exception::before {
  background: var(--accent-red);
}

.card.pending::before {
  background: var(--text-muted);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.card-barcode {
  font-size: 0.88rem;
  font-weight: 600;
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace;
  letter-spacing: 0.5px;
}

.card-note {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  flex-shrink: 0;
  font-family: 'Inter', monospace;
}

.badge-green {
  background: rgba(5, 150, 105, 0.1);
  color: var(--accent-green);
  border: 1px solid rgba(5, 150, 105, 0.2);
}

.badge-yellow {
  background: rgba(217, 119, 6, 0.1);
  color: var(--accent-yellow);
  border: 1px solid rgba(217, 119, 6, 0.2);
}

.badge-red {
  background: rgba(220, 38, 38, 0.1);
  color: var(--accent-red);
  border: 1px solid rgba(220, 38, 38, 0.2);
}

.badge-muted {
  background: rgba(107, 114, 128, 0.1);
  color: var(--text-muted);
  border: 1px solid rgba(107, 114, 128, 0.2);
}

.status-current {
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.status-location {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.status-date {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-family: 'Inter', monospace;
}

/* --- PROGRESS BAR --- */
.progress-track {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 20px 0 12px;
  position: relative;
}

.progress-step {
  flex: 1;
  text-align: center;
  position: relative;
}

.progress-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  margin: 0 auto 6px;
  position: relative;
  z-index: 2;
  transition: all 0.3s ease;
}

.progress-dot.active {
  background: var(--primary);
  box-shadow: 0 0 6px rgba(37, 99, 235, 0.3);
}

.progress-dot.completed {
  background: var(--accent-green);
  box-shadow: 0 0 6px rgba(5, 150, 105, 0.3);
}

.progress-dot.exception {
  background: var(--accent-red);
  box-shadow: 0 0 6px rgba(220, 38, 38, 0.3);
}

.progress-label {
  font-size: 0.58rem;
  color: var(--text-muted);
  letter-spacing: 0.3px;
  font-weight: 500;
  font-family: 'Inter', monospace;
}

.progress-label.active {
  color: var(--primary);
  font-weight: 600;
}

.progress-label.completed {
  color: var(--accent-green);
}

.progress-line {
  position: absolute;
  top: 4px;
  left: 10%;
  right: 10%;
  height: 2px;
  background: var(--border);
  z-index: 1;
}

.progress-line-fill {
  height: 100%;
  background: var(--accent-green);
  transition: width 0.6s ease;
}

/* --- TIMELINE --- */
.timeline-toggle {
  font-size: 0.75rem;
  color: var(--primary);
  cursor: pointer;
  border: none;
  background: none;
  font-family: 'Inter', sans-serif;
  padding: 6px 0;
  margin-top: 8px;
  font-weight: 500;
}

.timeline-toggle:hover {
  color: var(--primary-hover);
}

.timeline {
  display: none;
  margin-top: 14px;
  padding-left: 16px;
  border-left: 1px solid var(--border);
  max-height: 240px;
  overflow-y: auto;
}

.timeline.open {
  display: block;
}

.timeline-item {
  position: relative;
  padding: 8px 0 8px 16px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -21px;
  top: 14px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  border: 1px solid var(--bg-card);
}

.timeline-item:first-child::before {
  background: var(--accent-green);
}

.timeline-item .tl-status {
  font-size: 0.8rem;
  font-weight: 600;
}

.timeline-item .tl-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-family: 'Inter', monospace;
}

/* --- EMPTY STATE --- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  max-width: 400px;
  margin: 0 auto;
}

.empty-state .emoji {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.empty-state h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Error state — centered in viewport */
.grid:has(.empty-state) {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 280px);
}

/* --- ADD PACKAGE FORM --- */
.add-form {
  max-width: 500px;
  margin: 0 auto 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.add-form-title {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.add-form-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.add-form-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.add-form-field label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: 'Inter', monospace;
  font-weight: 600;
}

.add-form-field input {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-main);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.add-form-field input:focus {
  border-color: var(--primary);
}

.btn-add {
  background: var(--primary);
  border: 1px solid var(--primary);
  color: #ffffff;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-add:hover {
  background: var(--primary-hover);
}

.btn-add:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- FOOTER --- */
.footer {
  text-align: center;
  margin-top: 40px;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--border);
}

.footer a {
  color: var(--text-secondary);
  text-decoration: none;
}

.footer a:hover {
  color: var(--primary);
}

/* --- AUTH GATE --- */
.auth-gate {
  position: fixed;
  inset: 0;
  background: rgba(9, 13, 22, 0.4);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.auth-gate.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.auth-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--shadow-hover);
  max-width: 320px;
  width: 90%;
  transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.auth-icon {
  margin-bottom: 16px;
  display: flex;
  justify-content: center;
}

.auth-svg {
  width: 44px;
  height: 44px;
  stroke: var(--primary);
}

.auth-box h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.auth-box .auth-subtitle {
  color: var(--text-secondary);
  font-size: 0.82rem;
  margin-bottom: 24px;
}

.auth-input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: 'Inter', monospace;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
  outline: none;
  text-align: center;
  letter-spacing: 4px;
  transition: all 0.3s ease;
  margin-bottom: 12px;
}

.auth-input:focus {
  border-color: var(--primary);
}

.auth-input::placeholder {
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 400;
}

.auth-error {
  color: var(--accent-red);
  font-size: 0.75rem;
  margin-bottom: 16px;
  min-height: 18px;
  font-weight: 500;
}

.auth-submit {
  width: 100%;
  background: var(--primary);
  border: none;
  color: #fff;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.auth-submit:hover {
  background: var(--primary-hover);
}

.auth-submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .controls {
    width: 100%;
    justify-content: flex-end;
    gap: 12px;
  }

  .btn span {
    display: none;
  }

  .btn {
    padding: 0;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .summary {
    gap: 8px;
  }

  .summary-item {
    min-width: 90px;
    padding: 10px 16px;
  }

  .summary-num {
    font-size: 20px;
  }

  .brand-group h1 {
    font-size: 1.15rem;
  }

  .add-form-row {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-add {
    width: 100%;
  }
}