:root {
  --admin-primary: #ef1733;
  --admin-dark: #20171c;
  --admin-bg: #f4f5f8;
  --admin-muted: #78808c;
}

* {
  box-sizing: border-box;
}

body {
  color: #29252a;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}

a,
a:hover {
  text-decoration: none;
}

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

.btn-primary:hover,
.btn-primary:focus {
  border-color: #cd1028;
  background: #cd1028;
}

.admin-body {
  min-height: 100vh;
  background: var(--admin-bg);
}

.admin-topbar {
  position: fixed;
  z-index: 1050;
  top: 0;
  right: 0;
  left: 0;
  height: 72px;
  padding: 0 24px;
  background: var(--admin-dark);
}

.admin-topbar .navbar-brand img {
  width: 70px;
  height: 48px;
  margin-right: 12px;
  border-radius: 4px;
  object-fit: contain;
  background: #fff;
}

.admin-topbar .navbar-brand span {
  font-size: 17px;
  font-weight: 600;
}

.admin-layout {
  display: flex;
  padding-top: 72px;
}

.admin-sidebar {
  position: fixed;
  top: 72px;
  bottom: 0;
  left: 0;
  width: 235px;
  padding: 24px 14px;
  background: #fff;
  border-right: 1px solid #e7e7ea;
}

.admin-sidebar a {
  display: flex;
  align-items: center;
  padding: 13px 16px;
  margin-bottom: 7px;
  color: #57515a;
  border-radius: 8px;
  font-weight: 600;
}

.admin-sidebar a i {
  width: 28px;
  font-size: 19px;
}

.admin-sidebar a:hover,
.admin-sidebar a.active {
  color: #fff;
  background: linear-gradient(135deg, var(--admin-primary), #ff4962);
}

.admin-content {
  width: calc(100% - 235px);
  min-height: calc(100vh - 72px);
  margin-left: 235px;
  padding: 32px;
}

.admin-page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 26px;
}

.admin-page-heading small {
  color: var(--admin-primary);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: .8px;
}

.admin-page-heading h1 {
  margin: 3px 0 0;
  font-size: 28px;
  font-weight: 700;
}

.stat-card,
.admin-card {
  overflow: hidden;
  border: 1px solid #ececf0;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 4px 18px rgba(28, 21, 25, .045);
}

.stat-card {
  display: flex;
  align-items: center;
  min-height: 116px;
  padding: 22px;
}

.stat-icon {
  display: flex;
  flex: 0 0 54px;
  height: 54px;
  align-items: center;
  justify-content: center;
  margin-right: 15px;
  border-radius: 12px;
  font-size: 25px;
}

.stat-icon.purple { color: #7449d7; background: #eee8ff; }
.stat-icon.blue { color: #2584d8; background: #e6f3ff; }
.stat-icon.orange { color: #df7a13; background: #fff0df; }
.stat-icon.green { color: #21965a; background: #e4f9ed; }

.stat-card small,
.stat-card strong {
  display: block;
}

.stat-card small {
  color: var(--admin-muted);
  font-size: 12px;
}

.stat-card strong {
  margin-top: 4px;
  font-size: 25px;
}

.admin-card-header {
  display: flex;
  min-height: 65px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #ededf1;
}

.admin-card-header h2,
.form-section-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.admin-table th {
  padding: 13px 16px;
  color: #77717a;
  border-top: 0;
  border-bottom: 1px solid #eee !important;
  background: #fafafa;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .45px;
}

.admin-table td {
  padding: 14px 16px;
  vertical-align: middle;
  border-top: 1px solid #f0f0f2;
}

.status-badge {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: capitalize;
}

.status-pending { color: #b36c00; background: #fff1d6; }
.status-confirmed { color: #1768aa; background: #e2f1ff; }
.status-shipped { color: #6547bf; background: #eee9ff; }
.status-delivered { color: #13713f; background: #ddf7e9; }
.status-cancelled { color: #af2635; background: #ffe1e5; }

.low-stock-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 20px;
  color: #29252a;
  border-bottom: 1px solid #eee;
}

.low-stock-list a:last-child {
  border-bottom: 0;
}

.low-stock-list strong,
.low-stock-list small {
  display: block;
}

.low-stock-list small {
  margin-top: 3px;
  color: var(--admin-muted);
}

.admin-search {
  display: flex;
}

.admin-search .form-control {
  width: 280px;
}

.admin-search .btn {
  margin-left: 6px;
}

.admin-product {
  display: flex;
  min-width: 260px;
  align-items: center;
}

.admin-product img {
  width: 50px;
  height: 58px;
  margin-right: 12px;
  border-radius: 5px;
  object-fit: cover;
}

.admin-product strong,
.admin-product small {
  display: block;
}

.admin-product small {
  margin-top: 3px;
  color: var(--admin-muted);
}

.form-section-title {
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid #eee;
}

.form-control {
  min-height: 44px;
  border-color: #dddde2;
  border-radius: 5px;
}

textarea.form-control {
  min-height: auto;
}

.image-preview {
  display: flex;
  height: 280px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  overflow: hidden;
  color: #9a939b;
  border: 2px dashed #ddd;
  border-radius: 8px;
  background: #fafafa;
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preview i {
  margin-bottom: 8px;
  font-size: 50px;
}

.site-image-card {
  height: 100%;
  overflow: hidden;
  border: 1px solid #e5e5e9;
  border-radius: 9px;
  background: #fff;
}

.site-image-preview {
  height: 190px;
  overflow: hidden;
  background: #f2f2f4;
}

.site-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.site-image-card .custom-file-label {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.admin-security-note {
  color: #625962;
  background:
    radial-gradient(circle at 100% 0%, rgba(241, 15, 35, .09), transparent 38%),
    #fff;
}

.admin-security-icon {
  display: flex;
  width: 58px;
  height: 58px;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  color: #fff;
  border-radius: 14px;
  background: linear-gradient(135deg, #f10f23, #ff365d);
  font-size: 27px;
}

.admin-security-note h2 {
  margin-bottom: 16px;
  color: #2e262c;
  font-size: 21px;
}

.admin-security-note ul {
  padding-left: 19px;
  margin-bottom: 18px;
}

.admin-security-note li {
  margin-bottom: 9px;
  line-height: 1.55;
}

.admin-security-note p {
  padding-top: 15px;
  border-top: 1px solid #ece6e9;
  font-size: 13px;
  line-height: 1.65;
}

.order-item-row {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
}

.order-item-row img {
  width: 58px;
  height: 68px;
  border-radius: 5px;
  object-fit: cover;
}

.order-item-row strong,
.order-item-row small {
  display: block;
}

.order-item-row small {
  margin-top: 4px;
  color: var(--admin-muted);
}

.order-totals {
  max-width: 390px;
  padding: 20px;
  margin-left: auto;
}

.order-totals > div {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
}

.order-totals .grand-total {
  margin-top: 8px;
  padding-top: 14px;
  border-top: 1px solid #ddd;
  font-size: 18px;
}

.admin-login-body {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 25px;
  background:
    linear-gradient(rgba(23, 13, 19, .82), rgba(23, 13, 19, .82)),
    url('/img/banner-2.jpeg') center/cover;
}

.admin-login-card {
  width: 100%;
  max-width: 430px;
  padding: 38px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}

.login-logo {
  display: block;
  text-align: center;
}

.login-logo img {
  width: 135px;
  height: 80px;
  object-fit: contain;
}

.admin-login-card h1 {
  margin: 20px 0 8px;
  text-align: center;
  font-size: 27px;
  font-weight: 700;
}

.admin-login-card > p {
  margin-bottom: 25px;
  color: var(--admin-muted);
  text-align: center;
}

.password-field {
  position: relative;
}

.password-field .form-control {
  padding-right: 48px;
}

.password-field button {
  position: absolute;
  top: 0;
  right: 0;
  width: 44px;
  height: 44px;
  border: 0;
  color: #777;
  background: transparent;
}

.back-store {
  display: block;
  margin-top: 22px;
  color: #555;
  text-align: center;
}

.ck.ck-editor { width: 100%; }
.ck.ck-toolbar { border-color: #cfd6df; border-radius: 7px 7px 0 0; background: #f7f8fa; }
.ck.ck-editor__main > .ck-editor__editable { border-color: #cfd6df; border-radius: 0 0 7px 7px; }
.ck-editor__editable_inline { min-height: 360px; max-height: 680px; overflow-y: auto; color: #17263a; font-size: 15px; line-height: 1.7; }
.advanced-editor-shell { position: relative; border-radius: 7px; background: #fff; }
.advanced-editor-actions { padding: 7px 9px; display: flex; justify-content: flex-end; gap: 7px; border: 1px solid #cfd6df; border-bottom: 0; border-radius: 7px 7px 0 0; background: #eef2f7; }
.advanced-editor-action { min-height: 32px; padding: 5px 10px; border: 1px solid #c6ced9; border-radius: 5px; color: #26364a; background: #fff; font-size: 13px; font-weight: 700; }
.advanced-editor-action:hover, .advanced-editor-action:focus { color: var(--admin-blue); border-color: #91add0; }
.advanced-editor-shell .ck.ck-toolbar { border-radius: 0; }
.advanced-editor-source { width: 100%; min-height: 420px !important; max-height: 680px; padding: 18px; overflow: auto; resize: vertical; border: 1px solid #cfd6df; border-radius: 0 0 7px 7px; color: #e5edf8; background: #111827; font: 14px/1.65 Consolas, Monaco, monospace; white-space: pre-wrap; tab-size: 2; }
.advanced-editor-shell.is-fullscreen { position: fixed; z-index: 3000; inset: 0; padding: 12px; display: flex; flex-direction: column; border-radius: 0; background: #eef2f7; }
.advanced-editor-shell.is-fullscreen .advanced-editor-actions { flex: 0 0 auto; }
.advanced-editor-shell.is-fullscreen .ck.ck-editor { min-height: 0; flex: 1 1 auto; display: flex; flex-direction: column; }
.advanced-editor-shell.is-fullscreen .ck.ck-editor__main { min-height: 0; flex: 1 1 auto; display: flex; }
.advanced-editor-shell.is-fullscreen .ck-editor__editable_inline { width: 100%; min-height: 100%; max-height: none; }
.advanced-editor-shell.is-fullscreen .advanced-editor-source { min-height: 0 !important; max-height: none; flex: 1 1 auto; resize: none; }
.editor-fullscreen-open { overflow: hidden; }

/* Shared admin layout: keep wide data inside its own scroll region. */
.admin-brand-group,
.admin-heading-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.admin-topbar { flex-wrap: nowrap; gap: 12px; }
.admin-topbar .navbar-brand { margin-right: 0; min-width: 0; }
.admin-topbar .navbar-brand img { flex-shrink: 0; }
.admin-topbar-actions { gap: 12px; min-width: 0; flex-shrink: 0; }
.admin-topbar-actions form { margin: 0; }
.admin-greeting { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-menu-toggle,
.admin-menu-close {
  display: none;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  align-items: center;
  justify-content: center;
  padding: 10px;
  border: 1px solid #ffffff50;
  border-radius: 6px;
  color: #fff;
  background: transparent;
  cursor: pointer;
}
.admin-menu-toggle { flex-direction: column; gap: 5px; }
.admin-menu-toggle span { width: 20px; height: 2px; background: currentColor; }
.admin-sidebar-heading,
.admin-sidebar-backdrop { display: none; }
.admin-sidebar { overflow-y: auto; overscroll-behavior: contain; }
.admin-sidebar a { min-height: 44px; }
.admin-sidebar a i { flex-shrink: 0; }
.admin-content,
.admin-content .row > *,
.admin-card,
.form-group { min-width: 0; }
.admin-content { overflow-wrap: anywhere; }
.admin-page-heading { flex-wrap: wrap; gap: 16px; }
.admin-page-heading > * { min-width: 0; max-width: 100%; }
.admin-page-heading > div:first-child { flex: 1 1 200px; }
.admin-page-heading > .btn { flex-shrink: 0; white-space: normal; }
.admin-heading-actions { flex-wrap: wrap; }
.admin-heading-actions .btn { margin: 0 !important; }
.admin-page-heading form { max-width: 100%; min-width: 0; }
.admin-page-heading form .form-control { min-width: 0; }
.admin-card-header { flex-wrap: wrap; gap: 12px; }
.admin-card-header > * { min-width: 0; max-width: 100%; }
.admin-card-header h2 { line-height: 1.35; }
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}
.admin-stat-cell { min-width: 0; }
.admin-stats-grid .stat-card { height: 100%; padding: 18px; }
.stat-card > div:last-child { min-width: 0; }
.stat-card strong { font-size: 23px; line-height: 1.25; }
.stat-card small { line-height: 1.4; }
.admin-search { flex-wrap: wrap; gap: 8px; max-width: 100%; min-width: 0; }
.admin-search .form-control { width: auto; flex: 1 1 180px; min-width: 0; }
.admin-search select.form-control { flex: 1 1 140px; }
.admin-search .form-control,
.admin-search .btn { margin: 0 !important; }
.admin-search .btn { flex-shrink: 0; min-width: 44px; }
.admin-content .table-responsive { max-width: 100%; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.admin-table { min-width: 620px; }
.admin-table th { white-space: nowrap; }
.admin-table td { min-width: 85px; max-width: 320px; }
.admin-product,
.entity-cell { display: flex; align-items: center; min-width: 220px; max-width: 320px; }
.admin-product img,
.entity-cell img { flex: 0 0 50px; width: 50px; height: 58px; margin-right: 12px; border-radius: 5px; object-fit: cover; }
.admin-product span,
.entity-cell span { min-width: 0; }
.entity-cell strong,
.entity-cell small { display: block; }
.entity-cell small { margin-top: 3px; color: var(--admin-muted); }
.low-stock-list a { gap: 12px; }
.low-stock-list a > span { min-width: 0; }
.low-stock-list b { flex-shrink: 0; }
.admin-card.form-section { padding: 24px; }
.form-title { margin: 0 0 22px; padding-bottom: 14px; border-bottom: 1px solid #eee; font-size: 18px; font-weight: 700; }
.admin-content .custom-file { max-width: 100%; }
.admin-content .custom-file-label { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding-right: 85px; }
.site-image-card .d-flex { flex-wrap: wrap; gap: 6px; }
.site-image-card .badge { align-self: flex-start; white-space: normal; }
.admin-card > .d-flex > .badge { align-self: flex-start; margin-bottom: 12px; }
.order-item-row { flex-wrap: wrap; }
.order-item-row img { flex-shrink: 0; }
.order-item-row .flex-grow-1 { min-width: 0; flex-basis: 180px; }
.order-totals > div { gap: 16px; }
.order-totals strong { text-align: right; }
.advanced-editor-shell,
.ck.ck-editor { max-width: 100%; min-width: 0; }
.ck.ck-toolbar > .ck-toolbar__items { min-width: 0; flex-wrap: wrap !important; }
.ck-editor__editable_inline { overflow-x: auto; overflow-wrap: anywhere; }
.advanced-editor-actions { flex-wrap: wrap; }
.advanced-editor-action { white-space: normal; }
.advanced-editor-action:hover,
.advanced-editor-action:focus { color: var(--admin-primary); }
.admin-content .btn { white-space: normal; }
.admin-content .text-nowrap .btn { white-space: nowrap; }
.admin-body button:focus-visible,
.admin-body a:focus-visible,
.admin-body .table-responsive:focus-visible { outline: 3px solid #2684ff; outline-offset: 3px; }

@media (min-width: 1600px) {
  .admin-stats-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .admin-stats-grid .stat-card { flex-direction: column; align-items: flex-start; gap: 12px; }
}

@media (min-width: 992px) and (max-width: 1199.98px) {
  .admin-content { padding: 24px; }
  .admin-stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 991.98px) {
  .admin-topbar { height: 64px; padding: 0 16px; }
  .admin-topbar .navbar-brand img { width: 54px; height: 42px; margin-right: 9px; }
  .admin-layout { display: block; padding-top: 64px; }
  .admin-content { width: 100%; min-height: calc(100vh - 64px); margin-left: 0; padding: 24px; }
  .admin-stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  /* Keep navigation usable if JavaScript is unavailable. */
  .admin-sidebar { position: static; width: 100%; padding: 12px; border-right: 0; border-bottom: 1px solid #e7e7ea; }
  .admin-sidebar nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .admin-sidebar a { margin: 0; }
  .admin-nav-ready .admin-menu-toggle { display: inline-flex; }
  .admin-nav-ready .admin-sidebar {
    position: fixed;
    z-index: 1040;
    top: 64px;
    bottom: 0;
    left: 0;
    width: min(290px, calc(100vw - 48px));
    padding: 16px 12px max(20px, env(safe-area-inset-bottom));
    border-right: 1px solid #e7e7ea;
    transform: translateX(-100%);
    visibility: hidden;
  }
  .admin-nav-ready .admin-sidebar nav { display: block; }
  .admin-nav-ready .admin-sidebar a { margin-bottom: 6px; }
  .admin-nav-ready .admin-sidebar-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 4px 12px; }
  .admin-menu-close { display: inline-flex; border-color: #dddde2; color: #57515a; font-size: 28px; line-height: 1; }
  .admin-menu-open { overflow: hidden; }
  .admin-menu-open .admin-sidebar { transform: translateX(0); visibility: visible; transition: transform .2s ease; }
  .admin-menu-open .admin-sidebar-backdrop { display: block; position: fixed; z-index: 1035; inset: 64px 0 0; background: rgba(20, 15, 20, .5); }
  .admin-search { flex: 1 1 100%; width: 100%; }
  .admin-content .btn-sm { min-height: 40px; min-width: 40px; padding: 9px 10px; }
  .admin-topbar .btn { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
  .form-control,
  .custom-file-label,
  .ck-editor__editable_inline { font-size: 16px; }
}

@media (max-width: 767.98px) {
  .admin-stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .admin-content { padding: 20px 16px; }
  .admin-page-heading { margin-bottom: 20px; }
  .admin-page-heading h1 { font-size: 25px; }
  .admin-stats-grid .stat-card { padding: 16px; }
  .stat-icon { flex-basis: 44px; height: 44px; margin-right: 10px; font-size: 22px; }
  .admin-page-heading > form { flex: 1 1 100%; width: 100%; }
  .admin-page-heading > form .btn { flex-shrink: 0; }
  .admin-search select.form-control { flex: 1 1 100%; }
  .admin-search input.form-control { flex: 1 1 140px; }
  .order-item-row { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 12px; }
  .order-item-row > span { grid-column: 1 / -1; }
  .order-item-row > strong { grid-column: 1 / -1; }
  .order-item-row .flex-grow-1 { width: auto; }
}

@media (max-width: 575.98px) {
  .admin-topbar { padding: 0 10px; gap: 8px; }
  .admin-brand-group,
  .admin-topbar-actions { gap: 8px; }
  .admin-topbar .navbar-brand img { width: 46px; height: 38px; margin-right: 8px; }
  .admin-topbar .navbar-brand span { font-size: 14px; }
  .admin-store-link { width: 40px; padding: 8px; }
  .admin-store-link span { display: none; }
  .admin-content { padding: 18px 12px max(24px, env(safe-area-inset-bottom)); }
  .admin-content .row { margin-right: -6px; margin-left: -6px; }
  .admin-content .row > * { padding-right: 6px; padding-left: 6px; }
  .admin-page-heading { align-items: flex-start; gap: 12px; }
  .admin-page-heading > div:first-child { flex-basis: 100%; }
  .admin-page-heading h1 { font-size: 24px; line-height: 1.25; }
  .admin-heading-actions { width: 100%; align-items: stretch; }
  .admin-heading-actions .btn { flex: 1 1 120px; padding: 10px; }
  .admin-page-heading > .btn { min-height: 42px; }
  .admin-stats-grid .stat-card { flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px; min-height: 138px; }
  .stat-icon { flex: 0 0 40px; width: 40px; height: 40px; margin-right: 0; }
  .stat-card strong { font-size: 22px; }
  .admin-card-header { padding: 16px; gap: 10px; }
  .admin-card.p-4,
  .admin-card.form-section { padding: 18px 16px !important; }
  .admin-table th,
  .admin-table td { padding: 12px; }
  .image-preview { height: 240px; }
  .form-section-title,
  .form-title { font-size: 17px; }
  .admin-content form > .text-right .btn { width: 100%; padding-left: 16px !important; padding-right: 16px !important; }
  .order-item-row,
  .order-totals { padding: 16px; }
  .ck-editor__editable_inline { min-height: 260px; max-height: 60vh; }
  .advanced-editor-actions { justify-content: stretch; }
  .advanced-editor-action { flex: 1 1 90px; min-height: 40px; }
  .advanced-editor-action i { display: none; }
  .advanced-editor-shell.is-fullscreen { padding: 0; }
  .admin-login-body { padding: 18px 12px; min-height: 100vh; min-height: 100dvh; }
  .admin-login-card { padding: 28px 22px; }
}

@media (max-width: 399.98px) {
  .admin-topbar .navbar-brand span { display: none; }
  .admin-topbar .navbar-brand img { margin-right: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .admin-nav-ready .admin-sidebar { transition: none; }
}
