/* Car Rental Portal — Dispatch Design */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #e6f3ff;
  --success: #22c55e;
  --success-light: #dcfce7;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --purple: #7c3aed;
  --purple-light: #ede9fe;
  --text: #2d3748;
  --text-muted: #6b7280;
  --border: #e2e8f0;
  --bg: #ffffff;
  --bg-light: #f7fafc;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.12);
}

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

body {
  font-family: 'Poppins', sans-serif;
  background: #f8f9fa;
  color: var(--text);
  line-height: 1.6;
  font-size: 14px;
}

/* ── LOGIN ─────────────────────────────────────── */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: #ffffff;
  padding: 20px;
}

.login-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 50px;
  box-shadow: 0 2px 15px rgba(0,0,0,0.06);
  width: 100%;
  max-width: 440px;
  border: 1px solid #f1f5f9;
}

.login-header { text-align: center; margin-bottom: 40px; }
.login-logo { font-size: 28px; font-weight: 600; color: var(--primary); margin-bottom: 8px; letter-spacing: -0.5px; }
.login-subtitle { font-size: 15px; color: var(--text-muted); font-weight: 400; }

.form-group { margin-bottom: 24px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: #374151; margin-bottom: 7px; }

.form-input, .form-control {
  width: 100%;
  padding: 13px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  font-size: 14px;
  font-family: 'Poppins', sans-serif;
  background: #fff;
  transition: all 0.2s ease;
  color: var(--text);
}
.form-input:focus, .form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.login-btn {
  width: 100%;
  padding: 15px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  font-family: 'Poppins', sans-serif;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(37,99,235,0.2);
  margin-top: 6px;
}
.login-btn:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,0.25); }
.login-btn:active { transform: translateY(0); }

.error-message {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
  padding: 11px 14px;
  border-radius: 8px;
  margin-bottom: 18px;
  font-size: 13px;
}

/* ── HEADER ─────────────────────────────────────── */
.header {
  background: var(--primary-light);
  color: var(--text);
  padding: 0.8rem 0;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 100%;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo { font-size: 1.25rem; font-weight: 600; color: var(--primary); letter-spacing: -0.3px; }

.nav-menu { display: flex; gap: 0.25rem; align-items: center; }

.nav-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 400;
  font-size: 0.875rem;
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-link:hover { background: rgba(37,99,235,0.08); }
.nav-link.active { background: rgba(37,99,235,0.12); font-weight: 500; }

.user-info { display: flex; align-items: center; gap: 1rem; color: var(--primary); font-size: 0.875rem; font-weight: 500; }

/* ── MAIN LAYOUT ──────────────────────────────────── */
.main-content { padding: 1.5rem 0; min-height: calc(100vh - 60px); }
.container { max-width: 100%; padding: 0 24px; }

.page { display: none; }
.page.active { display: block; }

/* ── DASHBOARD LAYOUT ─────────────────────────────── */
.dashboard-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
  align-items: start;
}

/* ── FILTERS PANEL ────────────────────────────────── */
.filters-panel {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  position: sticky;
  top: 4.5rem;
}

.filters-title { font-size: 1rem; font-weight: 600; margin-bottom: 1.25rem; color: var(--text); }

.filter-group { margin-bottom: 1.25rem; }
.filter-label { display: block; margin-bottom: 0.5rem; font-weight: 500; color: var(--text-muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.4px; }

.status-filters { display: flex; flex-direction: column; gap: 0.35rem; }

.status-filter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s;
  font-size: 0.875rem;
  border: 1px solid transparent;
}
.status-filter:hover { background: var(--bg-light); }
.status-filter.active { background: #e8f0fe; border-color: #c7d7f9; }

.status-count {
  background: var(--primary);
  color: white;
  padding: 0.15rem 0.45rem;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 22px;
  text-align: center;
}

.reset-filters-link {
  display: block;
  margin-top: 1rem;
  padding: 0.45rem 0.7rem;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.2s;
}
.reset-filters-link:hover { background: #e9ecef; color: var(--text); }

/* ── STATUS BADGES ────────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 14px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

.status-active      { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.status-expiring    { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.status-overdue     { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }
.status-available   { background: var(--success-light); color: #15803d; border: 1px solid #bbf7d0; }
.status-onrent      { background: #ffe8cc; color: #c05621; border: 1px solid #ffcc99; }
.status-archived    { background: #f1f5f9; color: #64748b; border: 1px solid #e2e8f0; }
.status-pending     { background: #f1f5f9; color: #6c757d; border: 1px solid #dee2e6; }
.status-received-dep{ background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.status-delivered   { background: var(--success-light); color: #15803d; border: 1px solid #bbf7d0; }
.status-permission-yes { background: var(--success-light); color: #15803d; }
.status-permission-no  { background: var(--danger-light); color: #991b1b; }

/* ── ORDERS SECTION ───────────────────────────────── */
.orders-section {
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.orders-header {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.orders-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.add-order-btn {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;
  transition: all 0.2s;
  text-decoration: none;
  line-height: 1;
  flex-shrink: 0;
}
.add-order-btn:hover { background: var(--primary-hover); transform: scale(1.1); }

.search-area { display: flex; align-items: center; gap: 0.75rem; }

.orders-count-badge {
  background: linear-gradient(135deg, #60a5fa, #3b82f6);
  color: white;
  padding: 0.4rem 0.9rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
}

.search-box { position: relative; }
.search-input {
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  font-family: 'Poppins', sans-serif;
  width: 240px;
  transition: border-color 0.2s;
}
.search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }

/* ── EXCEL-STYLE TABLE ───────────────────────────── */
.orders-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.orders-table th {
  background: var(--bg-light);
  padding: 0.65rem 0.5rem;
  text-align: left;
  font-weight: 600;
  color: #4a5568;
  border-bottom: 2px solid var(--border);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  cursor: move;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
}

.orders-table th:hover { background: #f0f4f8; }
.orders-table th.dragging { opacity: 0.5; background: #dbeafe; }
.orders-table th.drag-over { background: #bfdbfe; border-left: 3px solid var(--primary); }

.orders-table td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  vertical-align: middle;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.orders-table tr:hover td { background: var(--bg-light); }
.orders-table tr:nth-child(even) td { background: #fafafa; }
.orders-table tr:nth-child(even):hover td { background: #f0f4f8; }

/* Editable cells */
.editable-cell { cursor: pointer; transition: background-color 0.2s; }
.editable-cell:hover { background: #e2e8f0 !important; }
.cell-input {
  width: 100%;
  border: 2px solid var(--primary);
  background: white;
  padding: 0.25rem 0.4rem;
  font-size: 0.82rem;
  font-family: 'Poppins', sans-serif;
  border-radius: 3px;
}
.cell-input:focus { outline: none; }

/* Drag indicator */
.drag-indicator {
  position: absolute;
  top: 50%; left: 4px;
  transform: translateY(-50%);
  font-size: 11px;
  color: #aaa;
  opacity: 0;
  transition: opacity 0.2s;
}
.orders-table th { position: relative; padding-left: 16px; }
.orders-table th:hover .drag-indicator { opacity: 1; }

/* Column resizer */
.column-resizer {
  position: absolute;
  top: 0; right: 0;
  width: 5px;
  height: 100%;
  cursor: col-resize;
  background: transparent;
  z-index: 15;
}
.column-resizer:hover { background: rgba(37,99,235,0.25); }

/* ── PAGINATION ──────────────────────────────────── */
.pagination {
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border);
}
.pagination-info { color: var(--text-muted); font-size: 0.875rem; }
.pagination-controls { display: flex; gap: 0.4rem; align-items: center; }
.pagination-btn {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: 'Poppins', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
}
.pagination-btn:hover { background: var(--bg-light); border-color: var(--primary); }
.pagination-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ── ADMIN SECTIONS ──────────────────────────────── */
.admin-container { max-width: 1200px; margin: 0 auto; }
.admin-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.admin-title { font-size: 1.4rem; font-weight: 600; color: var(--text); }

.users-table-container { background: white; border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }

.users-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.users-table th {
  background: var(--bg-light);
  padding: 0.85rem 1rem;
  text-align: left;
  font-weight: 600;
  color: #4a5568;
  border-bottom: 2px solid var(--border);
}
.users-table td { padding: 0.85rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.users-table tr:hover td { background: var(--bg-light); }

.permission-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  margin: 0.1rem;
  border-radius: 4px;
  font-size: 0.73rem;
  font-weight: 500;
}
.permission-badge.granted { background: var(--success-light); color: #15803d; }
.permission-badge.denied  { background: var(--danger-light);  color: #991b1b; }

.user-actions { display: flex; gap: 0.5rem; }

/* ── STATS ROW ───────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat-card { background: white; border-radius: 12px; box-shadow: var(--shadow); padding: 1.25rem; }
.stat-card-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.stat-card-title { font-size: 0.78rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.stat-card-value { font-size: 1.8rem; font-weight: 700; color: var(--text); line-height: 1.2; }
.stat-card-amount { font-size: 0.95rem; font-weight: 600; margin-top: 0.2rem; }

/* ── BUTTONS ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 7px;
  font-family: 'Poppins', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  font-size: 0.875rem;
  white-space: nowrap;
}
.btn-primary  { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 3px 10px rgba(37,99,235,0.3); }
.btn-secondary{ background: #e2e8f0; color: #4a5568; }
.btn-secondary:hover { background: #cbd5e0; }
.btn-success  { background: var(--success); color: white; }
.btn-success:hover { background: #16a34a; }
.btn-warning  { background: var(--warning); color: white; }
.btn-warning:hover { background: #d97706; }
.btn-danger   { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }

.btn-icon {
  background: none;
  border: none;
  padding: 0.4rem;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.82rem;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
}
.btn-icon:hover { background: var(--bg-light); color: var(--text); transform: scale(1.1); }
.btn-icon.edit-icon:hover   { background: #e0f2fe; color: #0284c7; }
.btn-icon.delete-icon:hover { background: var(--danger-light); color: var(--danger); }
.btn-icon.archive-icon:hover{ background: #f1f5f9; color: #475569; }

.action-buttons { display: flex; gap: 4px; align-items: center; }

/* Notes Button */
.btn-notes { background: none; border: none; padding: 0.4rem; border-radius: 4px; cursor: pointer; transition: all 0.2s; font-size: 14px; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; }
.btn-notes.has-notes { color: var(--primary); }
.btn-notes.no-notes  { color: #d1d5db; }
.btn-notes:hover { background: var(--bg-light); transform: scale(1.1); }

/* Pics indicator */
.pics-indicator {
  background: none; border: 1px solid transparent; padding: 0;
  border-radius: 50%; cursor: pointer; transition: all 0.2s;
  font-size: 13px; display: inline-flex; align-items: center;
  justify-content: center; width: 22px; height: 22px;
}
.pics-indicator.has-photos { color: var(--success); border-color: var(--success); background: var(--success-light); font-weight: bold; }
.pics-indicator.no-photos  { color: #d1d5db; border-color: #e5e7eb; }
.pics-indicator:hover { transform: scale(1.1); }

/* ── VIN CODE ────────────────────────────────────── */
.vin-code {
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-light);
  padding: 1px 5px;
  border-radius: 3px;
  display: inline-block;
}

/* ── DAYS INDICATOR ──────────────────────────────── */
.days-ok   { color: var(--success); }
.days-warn { color: var(--warning); }
.days-danger { color: var(--danger); font-weight: 600; }

/* ── MODAL ───────────────────────────────────────── */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0; top: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.45);
}

.modal-content {
  background: white;
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  padding: 0;
  border-radius: 12px;
  width: 90%;
  max-width: 560px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  z-index: 1001;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-light);
  border-radius: 12px 12px 0 0;
  flex-shrink: 0;
}
.modal-header h3 { margin: 0; color: var(--text); font-size: 1rem; font-weight: 600; }
.close { color: #9ca3af; font-size: 24px; font-weight: bold; cursor: pointer; line-height: 1; background: none; border: none; }
.close:hover { color: var(--text); }

.modal-body { padding: 1.5rem; overflow-y: auto; flex: 1; }

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-shrink: 0;
  background: var(--bg-light);
  border-radius: 0 0 12px 12px;
}

/* ── FORM GRID ───────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.form-group-modal { display: flex; flex-direction: column; margin-bottom: 0; }
.form-check { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.form-check input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; }
.form-check label { cursor: pointer; font-size: 0.875rem; }

/* ── FLASH / ALERTS ──────────────────────────────── */
.flash-messages { margin-bottom: 1rem; }
.flash-message { padding: 0.7rem 1rem; border-radius: 7px; margin-bottom: 0.5rem; font-weight: 500; font-size: 0.875rem; }
.flash-success { background: #c6f6d5; color: #22543d; border: 1px solid #9ae6b4; }
.flash-error   { background: #fed7d7; color: #742a2a; border: 1px solid #fc8181; }

/* ── LOADING & EMPTY ─────────────────────────────── */
.table-loading { text-align: center; padding: 3rem; color: var(--text-muted); }

.loading {
  display: inline-block;
  width: 22px; height: 22px;
  border: 3px solid #e2e8f0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { padding: 3rem; text-align: center; color: var(--text-muted); }
.empty-state i { font-size: 2.5rem; margin-bottom: 0.75rem; opacity: 0.4; display: block; }
.empty-state p { font-size: 0.9rem; }

/* ── NOTIFICATION ─────────────────────────────────── */
.notification {
  position: fixed;
  top: 20px; right: 20px;
  padding: 0.9rem 1.4rem;
  border-radius: 10px;
  color: white;
  font-weight: 500;
  font-size: 0.875rem;
  z-index: 9999;
  transform: translateX(400px);
  transition: transform 0.3s ease;
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
  max-width: 340px;
}
.notification.show { transform: translateX(0); }
.notification.success { background: var(--success); }
.notification.error   { background: var(--danger); }
.notification.info    { background: var(--primary); }

/* ── PHOTO GRID ──────────────────────────────────── */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; margin-top: 10px; }
.photo-thumb { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); cursor: pointer; transition: transform 0.15s; }
.photo-thumb:hover { transform: scale(1.05); }
.photo-lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.88); z-index: 9998; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.photo-lightbox img { max-width: 90vw; max-height: 90vh; border-radius: 8px; }

/* ── MISC ────────────────────────────────────────── */
.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: 0.8rem; }
.text-center { text-align: center; }
.fw-600      { font-weight: 600; }
hr.divider   { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

body.resizing { cursor: col-resize !important; user-select: none; }
body.resizing * { cursor: col-resize !important; }

@media (max-width: 900px) {
  .dashboard-layout { grid-template-columns: 1fr; }
  .filters-panel { position: static; }
}
