/* ============================================================
   Backward Compatibility Layer
   Allows old pages to render with the new layout system
   ============================================================ */

/* ── Old Layout Mapping ──────────────────────────────────── */
.page-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-header {
  padding: 24px 32px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface);
}

.page-body {
  padding: 32px;
  flex: 1;
}

@media (max-width: 991.98px) {
  .page-wrapper {
    margin-left: 0;
  }
  .page-body {
    padding: 20px;
  }
  .page-header {
    padding: 20px;
  }
}

/* ── Grid System ─────────────────────────────────────────── */
.row {
  display: flex;
  flex-wrap: wrap;
  margin-left: -12px;
  margin-right: -12px;
}

.row > * {
  flex-shrink: 0;
  width: 100%;
  max-width: 100%;
  padding-left: 12px;
  padding-right: 12px;
}

.col { flex: 1 0 0%; }
.col-auto { flex: 0 0 auto; width: auto; }
.col-1 { flex: 0 0 auto; width: 8.33333333%; }
.col-2 { flex: 0 0 auto; width: 16.66666667%; }
.col-3 { flex: 0 0 auto; width: 25%; }
.col-4 { flex: 0 0 auto; width: 33.33333333%; }
.col-5 { flex: 0 0 auto; width: 41.66666667%; }
.col-6 { flex: 0 0 auto; width: 50%; }
.col-7 { flex: 0 0 auto; width: 58.33333333%; }
.col-8 { flex: 0 0 auto; width: 66.66666667%; }
.col-9 { flex: 0 0 auto; width: 75%; }
.col-10 { flex: 0 0 auto; width: 83.33333333%; }
.col-11 { flex: 0 0 auto; width: 91.66666667%; }
.col-12 { flex: 0 0 auto; width: 100%; }

@media (min-width: 576px) {
  .col-sm-3 { flex: 0 0 auto; width: 25%; }
  .col-sm-6 { flex: 0 0 auto; width: 50%; }
}

@media (min-width: 768px) {
  .col-md-3 { flex: 0 0 auto; width: 25%; }
  .col-md-4 { flex: 0 0 auto; width: 33.33333333%; }
  .col-md-5 { flex: 0 0 auto; width: 41.66666667%; }
  .col-md-6 { flex: 0 0 auto; width: 50%; }
  .col-md-8 { flex: 0 0 auto; width: 66.66666667%; }
}

@media (min-width: 992px) {
  .col-lg { flex: 1 0 0%; }
  .col-lg-3 { flex: 0 0 auto; width: 25%; }
  .col-lg-4 { flex: 0 0 auto; width: 33.33333333%; }
  .col-lg-5 { flex: 0 0 auto; width: 41.66666667%; }
  .col-lg-6 { flex: 0 0 auto; width: 50%; }
  .col-lg-7 { flex: 0 0 auto; width: 58.33333333%; }
  .col-lg-8 { flex: 0 0 auto; width: 66.66666667%; }
  .col-lg-auto { flex: 0 0 auto; width: auto; }
}

@media (min-width: 1200px) {
  .col-xl-4 { flex: 0 0 auto; width: 33.33333333%; }
}

/* Gutters */
.g-0 { --gx: 0; --gy: 0; }
.g-1 { --gx: 4px; --gy: 4px; }
.g-2 { --gx: 8px; --gy: 8px; }
.g-3 { --gx: 16px; --gy: 16px; }
.g-4 { --gx: 24px; --gy: 24px; }

.g-0, .g-1, .g-2, .g-3, .g-4 {
  margin-left: calc(var(--gx) * -1);
  margin-right: calc(var(--gx) * -1);
}

.g-0 > *, .g-1 > *, .g-2 > *, .g-3 > *, .g-4 > * {
  padding-left: var(--gx);
  padding-right: var(--gx);
  padding-bottom: var(--gy);
}

/* ── Display ─────────────────────────────────────────────── */
.d-flex { display: flex !important; }
.d-inline { display: inline !important; }
.d-inline-flex { display: inline-flex !important; }
.d-none { display: none !important; }
.d-block { display: block !important; }

@media (min-width: 768px) {
  .d-md-none { display: none !important; }
  .d-md-inline-flex { display: inline-flex !important; }
  .d-md-block { display: block !important; }
}

@media (min-width: 992px) {
  .d-lg-none { display: none !important; }
  .d-lg-block { display: block !important; }
}

@media print {
  .d-print-none { display: none !important; }
}

/* ── Flexbox ─────────────────────────────────────────────── */
.justify-content-between { justify-content: space-between !important; }
.justify-content-center { justify-content: center !important; }
.justify-content-end { justify-content: flex-end !important; }
.align-items-center { align-items: center !important; }
.align-items-start { align-items: flex-start !important; }
.align-items-end { align-items: flex-end !important; }
.flex-column { flex-direction: column !important; }
.flex-row-reverse { flex-direction: row-reverse !important; }
.flex-fill { flex: 1 1 auto !important; }
.flex-shrink-0 { flex-shrink: 0 !important; }
.flex-wrap { flex-wrap: wrap !important; }
.flex-nowrap { flex-wrap: nowrap !important; }

/* ── Spacing ─────────────────────────────────────────────── */
.m-0 { margin: 0 !important; }
.m-1 { margin: 4px !important; }
.m-2 { margin: 8px !important; }
.m-3 { margin: 16px !important; }
.m-4 { margin: 24px !important; }
.m-5 { margin: 48px !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 4px !important; }
.mb-2 { margin-bottom: 8px !important; }
.mb-3 { margin-bottom: 16px !important; }
.mb-4 { margin-bottom: 24px !important; }
.mb-5 { margin-bottom: 48px !important; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 4px !important; }
.mt-2 { margin-top: 8px !important; }
.mt-3 { margin-top: 16px !important; }
.mt-4 { margin-top: 24px !important; }
.mt-5 { margin-top: 48px !important; }
.mt-auto { margin-top: auto !important; }

.me-0 { margin-right: 0 !important; }
.me-1 { margin-right: 4px !important; }
.me-2 { margin-right: 8px !important; }
.me-3 { margin-right: 16px !important; }

.ms-0 { margin-left: 0 !important; }
.ms-1 { margin-left: 4px !important; }
.ms-2 { margin-left: 8px !important; }
.ms-3 { margin-left: 16px !important; }
.ms-auto { margin-left: auto !important; }

.mx-1 { margin-left: 4px !important; margin-right: 4px !important; }
.mx-2 { margin-left: 8px !important; margin-right: 8px !important; }
.mx-auto { margin-left: auto !important; margin-right: auto !important; }

.p-0 { padding: 0 !important; }
.p-1 { padding: 4px !important; }
.p-2 { padding: 8px !important; }
.p-3 { padding: 16px !important; }
.p-4 { padding: 24px !important; }

.px-0 { padding-left: 0 !important; padding-right: 0 !important; }
.px-2 { padding-left: 8px !important; padding-right: 8px !important; }
.px-3 { padding-left: 16px !important; padding-right: 16px !important; }
.px-4 { padding-left: 24px !important; padding-right: 24px !important; }

.py-0 { padding-top: 0 !important; padding-bottom: 0 !important; }
.py-1 { padding-top: 4px !important; padding-bottom: 4px !important; }
.py-2 { padding-top: 8px !important; padding-bottom: 8px !important; }
.py-3 { padding-top: 16px !important; padding-bottom: 16px !important; }
.py-4 { padding-top: 24px !important; padding-bottom: 24px !important; }
.py-5 { padding-top: 48px !important; padding-bottom: 48px !important; }

.pb-3 { padding-bottom: 16px !important; }
.ps-3 { padding-left: 16px !important; }

@media (min-width: 992px) {
  .ms-lg-2 { margin-left: 8px !important; }
  .mt-lg-0 { margin-top: 0 !important; }
  .pt-lg-3 { padding-top: 16px !important; }
}

/* ── Sizing ──────────────────────────────────────────────── */
.w-100 { width: 100% !important; }
.h-100 { height: 100% !important; }

/* ── Position ────────────────────────────────────────────── */
.position-relative { position: relative !important; }
.sticky-top { position: sticky; top: 0; z-index: 1020; }
.overflow-hidden { overflow: hidden !important; }

/* ── Text ────────────────────────────────────────────────── */
.text-center { text-align: center !important; }
.text-end { text-align: right !important; }
.text-start { text-align: left !important; }
.text-white { color: #fff !important; }
.text-muted { color: var(--text-muted) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info { color: var(--primary) !important; }
.text-dark { color: var(--text-main) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-decoration-none { text-decoration: none !important; }
.text-uppercase { text-transform: uppercase !important; }
.text-capitalize { text-transform: capitalize !important; }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-nowrap { white-space: nowrap !important; }
.fw-bold { font-weight: 700 !important; }
.fw-semibold { font-weight: 600 !important; }
.fs-5 { font-size: 1.25rem !important; }
.small { font-size: 0.875em !important; }

/* ── Borders ─────────────────────────────────────────────── */
.border-0 { border: 0 !important; }
.border-bottom { border-bottom: 1px solid var(--border-color) !important; }
.rounded-3 { border-radius: var(--radius-md) !important; }

/* ── Lists ───────────────────────────────────────────────── */
.list-unstyled { padding-left: 0; list-style: none; }
.list-inline { padding-left: 0; list-style: none; }
.list-inline-item { display: inline-block; }
.list-inline-item:not(:last-child) { margin-right: 8px; }
.list-inline-dots > .list-inline-item:not(:last-child)::after {
  content: "\00b7"; margin-left: 8px; color: var(--text-muted);
}

/* ── Old VIP classes (minimal) ───────────────────────────── */
.vip-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.85rem; flex-shrink: 0;
}

.vip-welcome-banner {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
}

.vip-welcome-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.1rem; flex-shrink: 0;
}

.vip-welcome-title { font-size: 1.15rem; font-weight: 600; }
.vip-welcome-sub { font-size: 0.82rem; color: var(--text-muted); margin-top: 2px; }

.vip-revenue-card { border-left: 2px solid var(--primary); }
.vip-revenue-icon {
  width: 44px; height: 44px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; flex-shrink: 0;
}
.vip-revenue-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.07em; }
.vip-revenue-value { font-size: 1.4rem; font-weight: 700; line-height: 1.2; margin-top: 2px; }

.stat-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.stat-value { font-size: 1.35rem; font-weight: 700; line-height: 1.2; margin-top: 4px; }

.vip-job-card { transition: all 0.2s ease; }
.vip-job-card:hover { box-shadow: var(--shadow-md); }

/* ── Old Button Classes ──────────────────────────────────── */
.btn-vip {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  font-weight: 600;
}
.btn-vip:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-ghost-secondary {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-secondary);
}
.btn-ghost-secondary:hover {
  background: var(--bg-elevated);
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-outline-vip {
  background: transparent;
  border-color: var(--primary);
  color: var(--primary);
}
.btn-outline-vip:hover {
  background: var(--primary-light);
}

.btn-ghost-danger {
  background: transparent;
  border-color: rgba(239,68,68,0.25);
  color: var(--danger);
}
.btn-ghost-danger:hover {
  background: rgba(239,68,68,0.08);
}

.btn-ghost-gold {
  background: transparent;
  border-color: rgba(79,70,229,0.25);
  color: var(--primary);
}
.btn-ghost-gold:hover {
  background: rgba(79,70,229,0.08);
}

.btn-ghost-warning {
  background: transparent;
  border-color: rgba(245,158,11,0.25);
  color: var(--warning);
}
.btn-ghost-warning:hover {
  background: rgba(245,158,11,0.08);
}

.btn-info {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ── Old Badge Classes ───────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.35em 0.65em; font-size: 0.75em; font-weight: 500;
  line-height: 1; text-align: center; white-space: nowrap;
  border-radius: 6px; vertical-align: baseline;
}

.bg-success-lt { background: var(--success-bg, rgba(74,222,128,0.15)) !important; color: var(--success-text, #4ade80) !important; }
.bg-danger-lt  { background: var(--danger-bg, rgba(248,113,113,0.15)) !important; color: var(--danger-text, #f87171) !important; }
.bg-warning-lt { background: var(--warning-bg, rgba(251,191,36,0.15)) !important; color: var(--warning-text, #fbbf24) !important; }
.bg-info-lt    { background: var(--primary-light, rgba(96,165,250,0.15)) !important; color: var(--primary, #60a5fa) !important; }
.bg-primary-lt { background: var(--primary-light, rgba(96,165,250,0.15)) !important; color: var(--primary, #60a5fa) !important; }
.bg-secondary-lt { background: var(--bg-elevated, rgba(136,136,136,0.15)) !important; color: var(--text-secondary, #888) !important; }
.bg-gold-lt    { background: var(--primary-light, rgba(201,168,76,0.15)) !important; color: var(--primary, #c9a84c) !important; }
.bg-dark-lt    { background: rgba(255,255,255,0.08) !important; color: var(--text-secondary, #888) !important; }

.bg-success { background: var(--success) !important; }
.bg-danger { background: var(--danger) !important; }
.bg-warning { background: var(--warning) !important; }
.bg-info { background: var(--primary) !important; }
.bg-dark { background: var(--text-main) !important; }
.bg-transparent { background: transparent !important; }

.bg-warning.text-dark { color: #000 !important; }

/* ── Old Alert Classes ───────────────────────────────────── */
.alert {
  padding: 0.85rem 1.1rem; margin-bottom: 1rem;
  border: 1px solid transparent; border-radius: var(--radius-md);
  font-size: 0.9rem;
}
.alert-success { background: var(--success-bg); border-color: rgba(16,185,129,0.25); color: var(--success-text); }
.alert-danger { background: var(--danger-bg); border-color: rgba(239,68,68,0.25); color: var(--danger-text); }
.alert-warning { background: var(--warning-bg); border-color: rgba(245,158,11,0.25); color: var(--warning-text); }
.alert-link { font-weight: 600; text-decoration: underline; }

/* ── Form classes ────────────────────────────────────────── */
.form-control, .form-select {
  display: block; width: 100%;
  padding: 10px 14px; font-size: 0.95rem; line-height: 1.5;
  color: var(--text-main); background: var(--bg-surface);
  border: 1px solid var(--border-color); border-radius: var(--radius-md);
  appearance: none; transition: all 0.15s;
}
.form-control:focus, .form-select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}
.form-control::placeholder { color: var(--text-muted); }
.form-control-lg { padding: 12px 16px; font-size: 1.05rem; }
.form-control-sm, .form-select-sm { padding: 6px 10px; font-size: 0.875rem; }
.form-label {
  display: block; margin-bottom: 6px;
  font-size: 0.875rem; font-weight: 500; color: var(--text-main);
}
.form-check {
  display: flex; align-items: center; gap: 8px;
  min-height: 1.5rem; padding-left: 1.75rem; margin-bottom: 8px;
}
.form-check-input {
  width: 1.125rem; height: 1.125rem;
  background: var(--bg-surface); border: 1px solid var(--border-color);
  border-radius: 0.25rem; appearance: none; cursor: pointer;
  margin-left: -1.75rem; flex-shrink: 0;
}
.form-check-input:checked {
  background: var(--primary); border-color: var(--primary);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10l3 3l6-6'/%3e%3c/svg%3e");
  background-size: 75%; background-position: center; background-repeat: no-repeat;
}
.form-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

/* ── Input group ─────────────────────────────────────────── */
.input-group {
  display: flex; align-items: stretch; width: 100%;
}
.input-group > .form-control, .input-group > .form-select {
  position: relative; flex: 1 1 auto; width: 1%; min-width: 0;
}
.input-group > :not(:first-child) {
  border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px;
}
.input-group > :not(:last-child) {
  border-top-right-radius: 0; border-bottom-right-radius: 0;
}

/* ── List group ──────────────────────────────────────────── */
.list-group {
  display: flex; flex-direction: column; padding-left: 0; margin-bottom: 0;
  border-radius: var(--radius-md);
}
.list-group-item {
  position: relative; display: block; padding: 12px 16px;
  color: var(--text-main); background: transparent;
  border: none; border-bottom: 1px solid var(--border-color);
  text-decoration: none;
}
.list-group-item:last-child { border-bottom: none; }
.list-group-item-action { cursor: pointer; }
.list-group-item-action:hover { background: var(--bg-elevated); }
.list-group-flush > .list-group-item { border-width: 0 0 1px; border-radius: 0; }
.list-group-flush > .list-group-item:last-child { border-bottom-width: 0; }

/* ── Modal ───────────────────────────────────────────────── */
.modal {
  position: fixed; top: 0; left: 0; z-index: 1060;
  display: none; width: 100%; height: 100%; overflow-x: hidden; overflow-y: auto;
  outline: 0; background: rgba(0,0,0,0.5);
  align-items: center; justify-content: center;
}
.modal.show { display: flex; }
.modal-dialog {
  position: relative; width: auto; margin: 0.5rem;
  max-width: 560px; pointer-events: none;
}
.modal-dialog-scrollable { max-height: calc(100% - 1rem); display: flex; flex-direction: column; }
.modal-dialog-scrollable .modal-content { max-height: calc(100vh - 1rem); overflow: hidden; }
.modal-dialog-scrollable .modal-body { overflow-y: auto; }
.modal-content {
  position: relative; display: flex; flex-direction: column; width: 100%;
  background: var(--bg-surface); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); pointer-events: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--border-color);
}
.modal-title { font-size: 1.05rem; font-weight: 600; margin: 0; color: var(--text-main); }
.modal-body { padding: 24px; flex: 1 1 auto; }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 16px 24px; border-top: 1px solid var(--border-color);
}

/* ── Dropdown ────────────────────────────────────────────── */
.dropdown { position: relative; }
.dropdown-toggle { cursor: pointer; }
.dropdown-menu {
  position: absolute; z-index: 1000; display: none;
  min-width: 10rem; padding: 6px 0; margin: 0;
  font-size: 0.9rem; color: var(--text-main); text-align: left;
  list-style: none; background: var(--bg-surface);
  border: 1px solid var(--border-color); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}
.dropdown-menu.show { display: block; }
.dropdown-menu-end { right: 0; }
.dropdown-item {
  display: block; width: 100%; padding: 8px 16px;
  clear: both; font-weight: 400; color: var(--text-main);
  text-align: inherit; text-decoration: none; white-space: nowrap;
  background: transparent; border: 0; cursor: pointer;
}
.dropdown-item:hover { background: var(--bg-elevated); }
.dropdown-divider { height: 0; margin: 6px 0; border-top: 1px solid var(--border-color); }

/* ── Misc old classes ────────────────────────────────────── */
.collapse:not(.show) { display: none; }
.collapse.show { display: block; }
.fade { transition: opacity 0.15s linear; }
.fade:not(.show) { opacity: 0; }
.active { }
.disabled { pointer-events: none; opacity: 0.6; }
.visually-hidden {
  position: absolute !important; width: 1px !important; height: 1px !important;
  padding: 0 !important; margin: -1px !important; overflow: hidden !important;
  clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important;
}
.antialiased { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
.cursor-pointer { cursor: pointer; }
.float-end { float: right !important; }

/* ── Animations ──────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.animate-fade-in-up { animation: fadeInUp 0.35s ease both; }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Mobile Bottom Nav ───────────────────────────────────── */
.vip-bottom-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1040;
  background: var(--bg-surface); border-top: 1px solid var(--border-color);
  padding: 8px 0;
}
.vip-bottom-nav .nav-item {
  flex: 1; text-align: center; color: var(--text-muted); text-decoration: none;
  padding: 6px 0; font-size: 0.65rem; font-weight: 500;
  transition: color 0.2s; border: none; background: none;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.vip-bottom-nav .nav-item.active { color: var(--primary); }

@media (max-width: 991.98px) {
  .driver-page .vip-bottom-nav { display: flex; }
  .driver-page .content { padding-bottom: 70px; }
}
