:root {
  --brand-orange: #e57c26;
  --brand-orange-soft: #fff1e4;
  --brand-ink: #0f172a;
  --brand-slate: #334155;
  --brand-bg: #f5f7fb;
  --brand-card: #ffffff;
  --brand-border: #dbe3ee;
}

body {
  background: radial-gradient(circle at top right, #fff7ee, transparent 45%),
    linear-gradient(180deg, #f7f9fc 0%, #eef3f9 100%);
  color: var(--brand-ink);
  font-family: "Manrope", "Segoe UI", "Helvetica Neue", sans-serif;
  overflow-x: hidden;
}

.navbar {
  background: linear-gradient(90deg, #0d1b2a 0%, #1b2b42 55%, #243b57 100%) !important;
  border-bottom: 2px solid rgba(229, 124, 38, 0.45);
}

.navbar .navbar-brand {
  font-weight: 800;
  letter-spacing: 0.2px;
}

.navbar .nav-link {
  color: rgba(255, 255, 255, 0.84) !important;
  font-weight: 600;
}

.navbar .nav-link:hover {
  color: #fff !important;
}

.container {
  max-width: 1240px;
}

.app-main {
  padding-top: 1rem;
  padding-left: 0.9rem;
  padding-right: 0.9rem;
}

.site-header {
  border: 1px solid var(--brand-border);
  background: linear-gradient(110deg, #fffdfb 0%, #f5f9ff 100%);
}

.site-header-nav {
  display: grid;
  grid-template-columns: 74px minmax(260px, max-content) 1fr auto auto auto auto;
  align-items: center;
  gap: 0.55rem;
  min-height: 54px;
  width: 100%;
}

.site-header-logo {
  width: 68px !important;
  min-width: 68px;
  max-width: 68px !important;
  height: 40px !important;
  max-height: 40px !important;
  height: auto;
  display: block;
  object-fit: contain;
  flex: 0 0 68px;
}

.site-header-brand-text {
  min-width: 0;
}

.site-header-ar {
  color: #e57c26;
  font-family: "Cairo", sans-serif !important;
  font-weight: 700;
  font-size: 0.86rem;
  line-height: 1.1;
  direction: rtl;
  unicode-bidi: plaintext;
  letter-spacing: 0;
  text-rendering: geometricPrecision;
  font-feature-settings: "liga" 1, "kern" 1;
}

.site-header-name {
  font-size: 1.06rem;
  font-weight: 800;
  margin: 0.12rem 0 0;
}

.site-header-actions {
  display: contents;
}

.site-header-action {
  display: inline-flex;
}

.site-header-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #fff1e4;
  border: 1px solid #f3c8a1;
  font-size: 14px;
  cursor: default;
}

h1,
h2,
h3,
h4,
h5 {
  font-weight: 800;
  color: #142235;
}

.card {
  border: 1px solid var(--brand-border);
  border-radius: 16px;
  box-shadow: 0 6px 22px rgba(15, 23, 42, 0.06);
  background-color: var(--brand-card);
}

.card .card-header {
  background: linear-gradient(180deg, #fff8f0 0%, #fff 100%);
  border-bottom: 1px solid var(--brand-border);
  border-radius: 16px 16px 0 0 !important;
  font-weight: 700;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.page-title {
  margin-bottom: 0.15rem;
}

.page-subtitle {
  color: #5a6d86;
  margin: 0;
}

.table-shell {
  border: 1px solid var(--brand-border);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
}

.table {
  margin-bottom: 0;
}

.card-body.p-0,
.table-shell,
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table thead th {
  background: #f2f6fc;
  color: #13233a;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.table td,
.table th {
  vertical-align: middle;
}

.table tbody tr:hover {
  background: #fafcff;
}

.btn {
  border-radius: 10px;
  font-weight: 700;
}

.btn-primary {
  background: linear-gradient(180deg, #f08f3f 0%, #e57c26 100%);
  border-color: #d86e17;
}

.btn-primary:hover,
.btn-primary:focus {
  background: linear-gradient(180deg, #ea8434 0%, #d96e16 100%);
  border-color: #c96413;
}

.btn-outline-primary {
  color: #c96413;
  border-color: #df9c66;
}

.btn-outline-primary:hover {
  background: #fdf1e7;
  border-color: #d97c2a;
  color: #a94f07;
}

.form-control,
.form-select,
textarea,
input[type="text"],
input[type="number"],
input[type="password"],
input[type="email"],
input[type="date"],
input[type="file"] {
  border: 1px solid #cad5e3;
  border-radius: 10px;
  min-height: 42px;
  box-shadow: none;
  background: #fff;
}

textarea.form-control {
  min-height: 84px;
}

.form-control:focus,
.form-select:focus {
  border-color: #e08a45;
  box-shadow: 0 0 0 0.2rem rgba(229, 124, 38, 0.14);
}

.form-label {
  font-weight: 700;
  color: #2a3e57;
}

.form-check-input {
  width: 1.05rem;
  height: 1.05rem;
  border-color: #b8c5d8;
}

.form-check-input:checked {
  background-color: var(--brand-orange);
  border-color: var(--brand-orange);
}

.alert {
  border-radius: 12px;
}

.errorlist {
  color: #dc3545;
  list-style: none;
  padding: 0;
  margin: 0.35rem 0 0;
  font-size: 0.84rem;
  font-weight: 700;
  display: block;
}

.errorlist li {
  margin-bottom: 0.15rem;
}

.is-invalid + .errorlist {
  margin-top: 0.25rem;
}

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(90deg, #f0f3f8 25%, #e2e8f0 50%, #f0f3f8 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite ease-in-out;
  border-radius: 4px;
  display: inline-block;
  min-height: 1em;
  width: 100%;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.list-group-item {
  border-color: #d9e3f0;
}

.list-group-item.active {
  background: linear-gradient(180deg, #ef8c3b 0%, #df7420 100%);
  border-color: #d96d16;
}

.portal-aside .list-group-item {
  border-radius: 10px !important;
  margin-bottom: 0.35rem;
}

.portal-layout {
  --bs-gutter-x: 1rem;
}

.portal-content {
  min-width: 0;
}

.portal-aside .card {
  position: sticky;
  top: 1rem;
}

.stat-card {
  height: 100%;
}

.stat-card .label {
  color: #51657f;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.4px;
  font-weight: 700;
}

.stat-card .value {
  font-size: 1.35rem;
  font-weight: 800;
  margin-top: 0.35rem;
}

.hint {
  background: var(--brand-orange-soft);
  border: 1px solid #f3c8a1;
  color: #8b4b12;
  border-radius: 12px;
  padding: 0.8rem 1rem;
}

.admin-kpi {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #fff 0%, #f8fbff 100%);
}

.admin-kpi::after {
  content: "";
  position: absolute;
  right: -18px;
  top: -18px;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(229, 124, 38, 0.22) 0%, rgba(229, 124, 38, 0) 70%);
}

.admin-kpi-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.45px;
  color: #586b83;
  font-weight: 700;
}

.admin-kpi-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
  color: #12253b;
  margin: 0.3rem 0 0.25rem;
}

.admin-kpi-sub {
  font-size: 0.82rem;
  color: #5f738d;
}

.admin-progress {
  height: 9px;
  background: #eef3fb;
  border-radius: 999px;
}

.admin-progress .progress-bar {
  background: linear-gradient(90deg, #e57c26 0%, #f2a152 100%);
}

.admin-cod-label {
  text-transform: uppercase;
  letter-spacing: 0.45px;
  font-weight: 700;
  color: #5b6f88;
  font-size: 0.78rem;
}

.admin-cod-value {
  font-size: 2.1rem;
  font-weight: 800;
  color: #14263f;
  margin: 0.2rem 0;
}

.admin-cod-footnote {
  color: #5f738d;
  font-size: 0.84rem;
}

.orders-select-col {
  width: 36px;
  text-align: center;
  vertical-align: middle !important;
}

.orders-select-col .form-check-input {
  margin-top: 0;
}

.admin-orders-compact {
  min-width: 980px;
}

.admin-orders-compact .cell-group {
  min-width: 170px;
}

.orders-scroll-shell {
  max-height: 68vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.orders-scroll-shell .table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  box-shadow: inset 0 -1px 0 var(--brand-border);
}

.modal-dialog {
  margin-top: 1rem;
  margin-bottom: 1rem;
}

@media (max-width: 767px) {
  .container {
    max-width: 100%;
  }

  .app-main {
    padding-top: 0.75rem;
    padding-left: 0.65rem;
    padding-right: 0.65rem;
  }

  .site-header-nav {
    grid-template-columns: 52px minmax(0, 1fr);
    grid-template-areas:
      "logo brand"
      "actions actions";
    gap: 0.45rem 0.65rem;
  }

  .site-header-name {
    font-size: 0.94rem;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.2;
  }

  .site-header-ar {
    font-size: 0.78rem;
  }

  .site-header-logo {
    width: 52px !important;
    min-width: 52px;
    max-width: 52px !important;
    height: 30px !important;
    max-height: 30px !important;
    flex-basis: 52px;
  }

  .site-header-nav > *:nth-child(1) {
    grid-area: logo;
  }

  .site-header-brand-text {
    grid-area: brand;
  }

  .site-header-actions {
    grid-area: actions;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.45rem;
    padding-top: 0.2rem;
  }

  .site-header-icon {
    width: 26px;
    height: 26px;
  }

  .portal-layout {
    --bs-gutter-x: 0.75rem;
    --bs-gutter-y: 0.75rem;
  }

  .portal-aside {
    margin-bottom: 0.5rem !important;
  }

  .portal-aside .card {
    position: static;
  }

  .portal-aside .card-body {
    padding: 0.85rem;
  }

  .portal-aside .small.text-uppercase {
    margin-bottom: 0.6rem !important;
  }

  .portal-aside .btn[data-bs-toggle="collapse"] {
    min-height: 40px;
    border-radius: 10px;
  }

  .portal-aside .list-group {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
  }

  .portal-aside .list-group-item {
    width: 100%;
    white-space: normal;
    margin-bottom: 0;
    padding: 0.7rem 0.95rem;
  }

  .page-head {
    gap: 0.45rem;
    margin-bottom: 0.85rem;
  }

  .page-title {
    font-size: 1.55rem;
    line-height: 1.1;
  }

  .page-subtitle {
    font-size: 0.92rem;
  }

  .card {
    border-radius: 14px;
  }

  .card .card-header,
  .card .card-body {
    padding-left: 0.9rem;
    padding-right: 0.9rem;
  }

  .card .card-body.p-0 {
    padding-left: 0;
    padding-right: 0;
  }

  .row.g-3,
  .row.g-2 {
    --bs-gutter-x: 0.75rem;
    --bs-gutter-y: 0.75rem;
  }

  .btn,
  .form-control,
  .form-select {
    min-height: 44px;
  }

  .d-flex.gap-2.flex-wrap > .btn,
  .mt-3.d-flex.gap-2 > .btn,
  .col-md-6.d-flex.gap-2.flex-wrap > .btn,
  .col-12.col-md-auto.d-flex.gap-2 > .btn {
    flex: 1 1 calc(50% - 0.5rem);
  }

  .admin-orders-compact {
    min-width: 860px;
  }

  .orders-scroll-shell {
    max-height: 60vh;
  }

  .admin-orders-compact th,
  .admin-orders-compact td {
    white-space: normal;
  }

  .admin-orders-compact .btn {
    min-height: 36px;
  }

  .table thead th {
    font-size: 11px;
  }

  .modal-dialog {
    margin: 0;
    min-height: 100vh;
    display: flex;
    align-items: end;
  }

  .modal-content {
    border-radius: 18px 18px 0 0;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }

  .modal-body {
    max-height: 72vh;
    overflow-y: auto;
  }
}

@media (max-width: 575px) {
  .site-header-icon {
    width: 30px;
    height: 30px;
    border-radius: 10px;
  }

  .card .card-header {
    font-size: 0.95rem;
  }

  .card .card-body {
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
  }

  .page-title {
    font-size: 1.4rem;
  }

  .page-subtitle {
    font-size: 0.88rem;
  }

  .hint {
    padding: 0.7rem 0.85rem;
  }

  .stat-card .value,
  .admin-kpi-value,
  .admin-cod-value {
    font-size: 1.55rem;
  }

  .d-flex.gap-2.flex-wrap > .btn,
  .mt-3.d-flex.gap-2 > .btn,
  .col-md-6.d-flex.gap-2.flex-wrap > .btn,
  .col-12.col-md-auto.d-flex.gap-2 > .btn {
    flex-basis: 100%;
  }
}

/* Status Badge Colors */
.fw-800 { font-weight: 800 !important; }
.fw-700 { font-weight: 700 !important; }
.fw-600 { font-weight: 600 !important; }
.fw-500 { font-weight: 500 !important; }

.text-orange { color: var(--brand-orange) !important; }
.bg-orange { background-color: var(--brand-orange) !important; }
.text-brand-ink { color: var(--brand-ink) !important; }
.text-slate { color: var(--brand-slate) !important; }

.badge-status-awaiting_pickup { background-color: #f59e0b !important; color: #fff; } /* Amber */
.badge-status-in_transit { background-color: #0ea5e9 !important; color: #fff; }      /* Blue */
.badge-status-out_for_delivery { background-color: #8b5cf6 !important; color: #fff; } /* Violet */
.badge-status-delivered { background-color: #10b981 !important; color: #fff; }        /* Green */
.badge-status-cancelled { background-color: #ef4444 !important; color: #fff; }        /* Red */
