/* Admin CSS variables & Reset */
:root {
  --color-bg: #090e1a;
  --color-surface: #12192a;
  --color-surface-glow: #1d263b;
  --color-border: rgba(255, 255, 255, 0.08);
  --color-primary: #3b82f6;
  --color-primary-glow: rgba(59, 130, 246, 0.35);
  --color-accent: #06b6d4;
  --color-accent-glow: rgba(6, 182, 212, 0.35);
  --color-success: #10b981;
  --color-danger: #ef4444;
  --color-text: #f8fafc;
  --color-text-muted: #94a3b8;
  
  --font-main: 'Outfit', sans-serif;
  --shadow-glow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
}

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

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-main);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  padding: 40px 20px;
}

/* Ambient glow bubbles */
.ambient-glow {
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  filter: blur(140px);
  opacity: 0.15;
  pointer-events: none;
  z-index: 0;
}
.ambient-glow.bg-blue {
  background-color: var(--color-primary);
  top: -100px;
  right: -50px;
}
.ambient-glow.bg-cyan {
  background-color: var(--color-accent);
  bottom: -100px;
  left: -50px;
}

/* Wrapper Layout */
.admin-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 30px;
  transition: filter 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.admin-wrapper.blurred {
  filter: blur(12px);
  pointer-events: none;
}

/* Auth Overlay Glassmorphism Modal */
.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(4, 8, 16, 0.8);
  backdrop-filter: blur(16px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

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

.auth-card {
  width: 100%;
  max-width: 420px;
  background: rgba(18, 25, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 40px rgba(59, 130, 246, 0.1);
  border-radius: 28px;
  padding: 40px 30px;
  text-align: center;
  transition: transform 0.4s ease;
}

.auth-card h2 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 10px;
  letter-spacing: -0.5px;
}

.auth-card p {
  color: var(--color-text-muted);
  font-size: 13px;
  margin-bottom: 30px;
  line-height: 1.6;
}

.auth-icon-wrapper {
  width: 72px;
  height: 72px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px auto;
  color: var(--color-primary);
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.2);
}

.auth-icon-wrapper i {
  width: 32px;
  height: 32px;
}

.auth-error-msg {
  color: var(--color-danger);
  font-size: 12px;
  font-weight: 600;
  margin-top: -10px;
  margin-bottom: 20px;
  min-height: 18px;
}

/* Card shaking validation keyframe */
@keyframes card-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-10px); }
  40%, 80% { transform: translateX(10px); }
}

.shake {
  animation: card-shake 0.4s ease-in-out;
  border-color: rgba(239, 68, 68, 0.4) !important;
  box-shadow: 0 0 30px rgba(239, 68, 68, 0.2) !important;
}

/* Header */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  padding: 24px;
  background: rgba(18, 25, 42, 0.6);
  backdrop-filter: blur(12px);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  box-shadow: var(--shadow-glow);
}

.header-logo-section {
  display: flex;
  align-items: center;
  gap: 16px;
}

.admin-logo {
  width: 52px;
  height: 52px;
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.3);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-accent);
}

.admin-logo i {
  width: 26px;
  height: 26px;
}

.header-logo-section h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.header-logo-section h1 span {
  color: var(--color-accent);
  font-weight: 400;
}

.header-logo-section p {
  color: var(--color-text-muted);
  font-size: 13px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.db-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 30px;
  font-size: 13px;
  color: var(--color-success);
  font-weight: 600;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--color-success);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

/* Statistics Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.stat-card {
  padding: 24px;
  background: rgba(18, 25, 42, 0.6);
  backdrop-filter: blur(12px);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  box-shadow: var(--shadow-glow);
  display: flex;
  align-items: center;
  gap: 20px;
  transition: transform 0.3s ease, border-color 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.15);
}

.stat-icon-wrapper {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon-wrapper i {
  width: 28px;
  height: 28px;
}

.stat-icon-wrapper.blue {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: var(--color-primary);
}

.stat-icon-wrapper.cyan {
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.3);
  color: var(--color-accent);
}

.stat-icon-wrapper.green {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--color-success);
}

.stat-details {
  display: flex;
  flex-direction: column;
}

.stat-label {
  color: var(--color-text-muted);
  font-size: 13px;
  font-weight: 500;
}

.stat-details h2 {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1px;
}

/* Two Column Grid */
.admin-main-grid {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 30px;
}

@media (max-width: 1024px) {
  .admin-main-grid {
    grid-template-columns: 1fr;
  }
}

/* Base Cards styling */
.admin-card {
  padding: 30px;
  background: rgba(18, 25, 42, 0.6);
  backdrop-filter: blur(12px);
  border: 1px solid var(--color-border);
  border-radius: 24px;
  box-shadow: var(--shadow-glow);
  display: flex;
  flex-direction: column;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.card-icon {
  color: var(--color-accent);
  width: 22px;
  height: 22px;
}

.card-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.card-subtitle {
  color: var(--color-text-muted);
  font-size: 13px;
  margin-bottom: 24px;
}

/* Forms */
.admin-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.input-group label i {
  width: 15px;
  height: 15px;
}

.input-group input {
  width: 100%;
  padding: 12px 16px;
  background: rgba(9, 14, 26, 0.5);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  color: #fff;
  font-family: var(--font-main);
  font-size: 14px;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  text-align: inherit;
}

.input-group input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 12px 0 var(--color-accent-glow);
}

.input-with-action {
  position: relative;
  display: flex;
}

.input-with-action input {
  padding-right: 50px;
}

.action-btn {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 34px;
  height: 34px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.action-btn:hover {
  background: var(--color-surface-glow);
  border-color: var(--color-accent);
}

.action-btn i {
  width: 16px;
  height: 16px;
}

.input-hint {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 12px;
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.4);
}

.btn-primary:hover {
  background: #2563eb;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px 0 rgba(59, 130, 246, 0.5);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-logout-danger {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--color-danger);
}

.btn-logout-danger:hover {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.btn-block {
  width: 100%;
  padding: 14px;
}

.btn-small-danger {
  padding: 6px 12px;
  font-size: 11px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--color-danger);
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-small-danger:hover {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
}

/* Tables styling */
.table-container {
  overflow-x: auto;
  margin-top: 10px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.admin-table th {
  padding: 12px 16px;
  border-bottom: 2px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.admin-table td {
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
  color: var(--color-text);
}

.admin-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.01);
}

.admin-table .loading-row {
  text-align: center;
  padding: 40px;
  color: var(--color-text-muted);
  font-style: italic;
}

.text-small th,
.text-small td {
  font-size: 13px;
  padding: 12px 14px;
}

/* Special statuses & elements */
.badge-id {
  font-family: monospace;
  font-size: 13px;
  color: var(--color-accent);
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.2);
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 600;
}

.badge-waybill {
  font-family: monospace;
  font-size: 12px;
  color: var(--color-primary);
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 600;
}

.badge-activity {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-activity.delivered {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: var(--color-success);
}

.text-bold {
  font-weight: 700;
}

.text-secondary-label {
  font-size: 11px;
  color: var(--color-text-muted);
  display: block;
  margin-top: 2px;
}

.gps-badge {
  font-family: monospace;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--color-text-muted);
}

.media-link {
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.media-link:hover {
  text-decoration: underline;
}

.recent-uploads-section {
  margin-top: 10px;
}

/* Text alignment helpers */
.text-center {
  text-align: center;
}

/* Responsive tweaking */
@media (max-width: 768px) {
  body {
    padding: 20px 10px;
  }
  
  .admin-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .header-actions {
    width: 100%;
    justify-content: space-between;
  }
}
