:root {
    --a-ink: #1F0640;
    --a-ink2: #12022A;
    --a-accent: #A9791E;
    --a-sky: #3D1D73;
    --a-line: #E9E1CC;
    --a-soft: #FBF6EC;
    --a-danger: #d61f4b;
    --a-green: #0f9d58;
    --a-radius: 10px;
    --a-font: "Cairo", Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: var(--a-font); background: var(--a-soft); color: #1e2431; }
a { text-decoration: none; color: inherit; }

/* ===== Buttons ===== */
.btn {
    display: inline-block; padding: 10px 18px; border-radius: 8px; border: 1px solid var(--a-line);
    background: #fff; color: var(--a-ink); font-family: inherit; font-weight: 600; font-size: 14px;
    cursor: pointer; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--a-soft); }
.btn-primary { background: var(--a-ink); color: #fff; border-color: var(--a-ink); }
.btn-primary:hover { background: var(--a-ink2); }
.btn-danger { background: #fff; color: var(--a-danger); border-color: #f3c2ce; }
.btn-danger:hover { background: var(--a-danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { display: block; width: 100%; text-align: center; }

/* ===== Layout ===== */
.admin-body { display: flex; min-height: 100vh; background: var(--a-soft); }
.admin-sidebar {
    width: 250px; background: #fff; color: var(--a-ink); display: flex; flex-direction: column;
    position: sticky; top: 0; min-height: 100vh; flex-shrink: 0;
    border-inline-end: 1px solid var(--a-line);
}
.admin-brand { padding: 22px 20px; border-bottom: 1px solid var(--a-line); display: flex; align-items: center; gap: 10px; }
.admin-brand .mark {
    width: 34px; height: 34px; border-radius: 6px; background: var(--a-ink); color: var(--a-accent);
    display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12px; flex-shrink: 0;
}
.admin-brand span { font-size: 15px; font-weight: 800; display: block; color: var(--a-ink); }
.admin-brand small { color: #8a8272; font-size: 11px; }
.admin-nav { display: flex; flex-direction: column; padding: 10px 0; flex: 1; }
.admin-nav a {
    padding: 11px 20px; color: #4a4438; font-weight: 600; font-size: 14px;
    border-inline-end: 3px solid transparent; transition: background .15s, color .15s;
}
.admin-nav a:hover { background: var(--a-soft); color: var(--a-ink); }
.admin-nav a.active { background: var(--a-soft); border-inline-end-color: var(--a-accent); color: var(--a-ink); font-weight: 700; }
.admin-logout { padding: 16px 20px; border-top: 1px solid var(--a-line); }
.admin-logout button {
    width: 100%; background: transparent; color: var(--a-danger); border: 1px solid var(--a-line);
    padding: 10px; border-radius: 8px; cursor: pointer; font-family: inherit; font-weight: 600;
}
.admin-logout button:hover { background: #fdecea; border-color: #f3c2ce; }

.admin-main { flex: 1; padding: 24px 32px; min-width: 0; }
.admin-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--a-line); }
.admin-topbar h1 { margin: 0; font-size: 22px; font-weight: 800; color: var(--a-ink); }
.admin-user { color: #8a8272; font-weight: 600; font-size: 13.5px; }

/* ===== Alerts ===== */
.alert { padding: 14px 18px; border-radius: var(--a-radius); margin-bottom: 20px; font-weight: 600; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-warn { background: #fef3c7; color: #92400e; }
.alert-row { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 4px; }
.alert-row .alert { margin-bottom: 0; text-decoration: none; transition: filter .15s; }
.alert-row .alert:hover { filter: brightness(.96); }

/* ===== Charts ===== */
.chart-row { display: grid; grid-template-columns: 2fr 1fr; gap: 22px; margin-bottom: 22px; }
.chart-card { margin-bottom: 0; }
@media (max-width: 900px) { .chart-row { grid-template-columns: 1fr; } }

/* ===== Cards ===== */
.card { background: #fff; border: 1px solid var(--a-line); border-radius: var(--a-radius); padding: 22px; margin-bottom: 22px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.card-head h2 { margin: 0; font-size: 18px; color: var(--a-ink); }
.form-card { max-width: 680px; }

/* ===== Stats ===== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { position: relative; background: #fff; border: 1px solid var(--a-line); border-top: 3px solid var(--a-accent); border-radius: var(--a-radius); padding: 20px; }
.stat-card.highlight { border-color: var(--a-accent); }
.stat-card.revenue { background: var(--a-ink); border-color: var(--a-ink); color: #fff; }
.stat-num { font-size: 30px; font-weight: 800; color: var(--a-ink); }
.stat-card.revenue .stat-num { color: #fff; }
.stat-num small { font-size: 14px; font-weight: 600; }
.stat-label { color: #8a8272; font-size: 14px; margin-top: 4px; }
.stat-card.revenue .stat-label { color: rgba(255,255,255,.7); }

/* ===== Tables ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--a-line);
    border-radius: 8px;
    overflow: hidden;
}
.data-table th, .data-table td {
    padding: 12px;
    text-align: right;
    border-bottom: 1px solid var(--a-line);
    border-inline-end: 1px solid var(--a-line);
    font-size: 14px;
    vertical-align: middle;
}
.data-table th:last-child, .data-table td:last-child {
    border-inline-end: none;
}
.data-table tr:last-child td {
    border-bottom: none;
}
.data-table th { color: #64748b; font-weight: 700; font-size: 13px; background: var(--a-soft); }
.data-table tfoot td { border-top: 2px solid var(--a-ink); border-bottom: none; }
.data-table .muted { color: #94a3b8; }
.thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid var(--a-line); }
.actions-cell { white-space: nowrap; }
.inline-form { display: inline-block; }
.sale { color: var(--a-danger); font-weight: 700; }
.empty { text-align: center; color: #94a3b8; padding: 30px; }

/* ===== Badges ===== */
.badge { display: inline-block; padding: 4px 12px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.status-0 { background: #fef3c7; color: #92400e; } /* Pending */
.status-1 { background: #ffedd5; color: #9a3412; } /* AwaitingPayment */
.status-2 { background: #dcfce7; color: #166534; } /* Confirmed */
.status-3 { background: #fee2e2; color: #991b1b; } /* Cancelled */
.status-4 { background: #e0e7ff; color: #3730a3; } /* Preparing */
.status-5 { background: #cffafe; color: #155e75; } /* OutForDelivery */
.status-6 { background: #bbf7d0; color: #14532d; } /* Delivered */

.delivery-actions { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--a-line, #eee); }
.delivery-actions h3 { margin: 0 0 10px; font-size: 15px; }

/* ===== Filters ===== */
.filter-bar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.filter-bar input, .filter-bar select {
    padding: 9px 12px; border: 1px solid var(--a-line); border-radius: 8px; font-family: inherit; font-size: 14px;
}
.filter-bar input { flex: 1; min-width: 180px; }

/* ===== Forms ===== */
.field { margin-bottom: 16px; }
.field > label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 14px; }
.field input[type=text], .field input[type=email], .field input[type=password],
.field input[type=number], .field input[type=file], .field textarea, .field select {
    width: 100%; padding: 10px 12px; border: 1px solid var(--a-line); border-radius: 8px;
    font-family: inherit; font-size: 14px;
}
.field.checkbox label { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.field.checkbox input { width: auto; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-error { color: var(--a-danger); font-size: 13px; }
.validation-summary { color: var(--a-danger); margin-bottom: 12px; }
.validation-summary ul { margin: 0; padding-right: 18px; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }
.preview { max-width: 140px; border-radius: 8px; border: 1px solid var(--a-line); margin-bottom: 8px; display: block; }

/* ===== Order details ===== */
.order-detail-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 22px; align-items: start; }
.detail-list { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; }
.detail-list dt { color: #64748b; font-weight: 600; }
.detail-list dd { margin: 0; }
.receipt-box { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--a-line); }
.receipt-img { max-width: 100%; border-radius: 8px; border: 1px solid var(--a-line); margin-top: 8px; }
.order-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.back-link { display: inline-block; margin-top: 16px; color: var(--a-sky); font-weight: 600; }

/* ===== Receipts grid ===== */
.receipt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.receipt-card { border: 1px solid var(--a-line); border-radius: var(--a-radius); overflow: hidden; display: flex; flex-direction: column; }
.receipt-card-head { display: flex; justify-content: space-between; padding: 12px 14px; background: var(--a-soft); font-weight: 700; }
.receipt-card-body { padding: 14px; flex: 1; }
.receipt-card-body .receipt-img { max-height: 220px; object-fit: contain; }
.receipt-card-actions { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--a-line); flex-wrap: wrap; }

/* ===== Login ===== */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--a-ink); }
.login-card { background: #fff; padding: 36px; border: 1px solid var(--a-line); border-radius: 8px; width: 100%; max-width: 380px; }
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand span { font-size: 26px; font-weight: 800; color: var(--a-ink); display: block; }
.login-brand small { color: #64748b; }

@media (max-width: 900px) {
    .admin-body { flex-direction: column; }
    .admin-sidebar { width: 100%; height: auto; position: static; }
    .admin-nav { flex-direction: row; flex-wrap: wrap; }
    .order-detail-grid { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
}

/* ===== Pagination (admin list pages) ===== */
.admin-pager {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 12px; margin-top: 18px; padding-top: 16px;
    border-top: 1px solid var(--a-line);
}
.admin-pager__info { margin: 0; color: #64748b; font-size: 14px; }
.admin-pagination { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.admin-page {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 38px; height: 38px; padding: 0 10px;
    border: 1px solid var(--a-line); border-radius: 8px; background: #fff;
    color: var(--a-ink); font-weight: 700; text-decoration: none;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.admin-page:hover { border-color: var(--a-sky); color: var(--a-sky); }
.admin-page.is-active { background: var(--a-ink); border-color: var(--a-ink); color: #fff; }
.admin-page.is-disabled { opacity: .4; pointer-events: none; }
.admin-page.page-nav { font-size: 18px; }
.admin-page-gap { padding: 0 4px; color: #94a3b8; }

/* Product list data-quality warnings (missing price / description) */
.row-warning--price { background: #fdecea; }
.row-warning--desc { background: #fff8e1; }
.warn-badge {
    display: inline-block; margin-inline-start: 6px; font-size: 11px; font-weight: 700;
    color: #92400e; background: #ffedd5; border-radius: 20px; padding: 2px 8px;
}

/* ===== Modal (shared: category/product edit) ===== */
.admin-modal-overlay {
    position: fixed; inset: 0; background: rgba(18, 2, 42, 0.55);
    display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 24px;
}
.admin-modal-overlay[hidden] {
    display: none;
}
.admin-modal {
    background: #fff; border-radius: 10px; width: 100%; max-width: 720px; max-height: 90vh;
    overflow-y: auto; position: relative; padding: 28px;
}
.admin-modal-close {
    position: absolute; top: 14px; left: 14px; width: 32px; height: 32px; border-radius: 6px;
    border: 1px solid var(--a-line); background: #fff; cursor: pointer; font-size: 14px; color: var(--a-ink);
}
.admin-modal-close:hover { background: var(--a-soft); }
.admin-modal-context {
    font-size: 13px; font-weight: 700; color: var(--a-accent); margin-bottom: 12px;
    padding-bottom: 12px; border-bottom: 1px solid var(--a-line);
}
.admin-modal-context:empty { display: none; }
.modal-form .form-actions { position: sticky; bottom: -28px; background: #fff; padding: 14px 0 0; margin-top: 10px; }

/* ===== Grid / table view toggle ===== */
.view-toggle { display: inline-flex; border: 1px solid var(--a-line); border-radius: 8px; overflow: hidden; }
.view-toggle button {
    border: 0; background: #fff; padding: 8px 14px; cursor: pointer; font-size: 13px; color: var(--a-ink);
}
.view-toggle button.is-active { background: var(--a-ink); color: #fff; }

/* ===== Icon grid (catalogs / products) ===== */
.icon-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; margin-top: 4px;
}
.icon-grid[hidden] {
    display: none;
}
.icon-card {
    position: relative; border: 1px solid var(--a-line); border-radius: 10px; padding: 16px 10px 12px;
    text-align: center; background: #fff; transition: border-color .15s;
}
.icon-card:hover { border-color: var(--a-accent); }
.icon-card .icon-card-thumb {
    width: 72px; height: 72px; margin: 0 auto 10px; display: flex; align-items: center; justify-content: center;
}
.icon-card .icon-card-thumb img { width: 100%; height: 100%; object-fit: contain; }
.icon-card .icon-card-thumb svg { width: 56px; height: 56px; color: var(--a-accent); }
.icon-card .icon-card-name { font-size: 13px; font-weight: 700; color: var(--a-ink); word-break: break-word; }
.icon-card .icon-card-featured {
    position: absolute; top: 8px; inset-inline-end: 8px; font-size: 14px; opacity: .35;
}
.icon-card.is-featured .icon-card-featured { opacity: 1; }
.icon-card-actions {
    position: absolute; inset: 0; background: rgba(31, 6, 64, 0.82); border-radius: 10px;
    display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px;
    padding: 12px; opacity: 0; pointer-events: none; transition: opacity .15s;
}
.icon-card:hover .icon-card-actions,
.icon-card:focus-within .icon-card-actions { opacity: 1; pointer-events: auto; }
.icon-card-actions button, .icon-card-actions a {
    width: 38px; height: 38px; border-radius: 50%; border: 1px solid rgba(255,255,255,.5);
    background: rgba(255,255,255,.12); color: #fff; display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 16px; text-decoration: none;
}
.icon-card-actions button:hover, .icon-card-actions a:hover { background: var(--a-accent); border-color: var(--a-accent); color: var(--a-ink); }
.icon-card-actions button.is-on { background: var(--a-accent); border-color: var(--a-accent); color: var(--a-ink); }
.icon-card-actions .btn-danger-icon:hover { background: var(--a-danger); border-color: var(--a-danger); color: #fff; }

.admin-breadcrumb {
    font-size: 18px; font-weight: 700; color: var(--a-ink); margin-bottom: 18px;
    display: flex; align-items: center; gap: 10px; padding-bottom: 14px; border-bottom: 1px solid var(--a-line);
}
.admin-breadcrumb a { color: var(--a-accent); font-weight: 700; }
.admin-breadcrumb a:hover { text-decoration: underline; }
.admin-breadcrumb .sep { color: #8a8272; font-weight: 400; }
.admin-breadcrumb-back {
    display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700;
    color: #fff; background: var(--a-ink); border: 1px solid var(--a-ink); border-radius: 8px; padding: 8px 14px;
    text-decoration: none; margin-inline-end: 6px;
}
.admin-breadcrumb-back:hover { background: var(--a-ink2); border-color: var(--a-ink2); }

/* ===== Product technical specs (dynamic rows) ===== */
.specs-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.specs-row select, .specs-row input {
    flex: 1; width: 100%; padding: 10px 12px; border: 1px solid var(--a-line); border-radius: 8px;
    font-family: inherit; font-size: 14px; background: #fff; color: inherit;
}
.specs-row select:focus, .specs-row input:focus {
    outline: none; border-color: var(--a-accent);
}
.btn-remove-spec {
    width: 32px; height: 32px; border-radius: 6px; border: 1px solid var(--a-line);
    background: #fff; color: var(--a-danger); cursor: pointer; flex-shrink: 0;
}
.btn-remove-spec:hover { background: #fdecea; border-color: var(--a-danger); }
.specs-reorder { display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }
.btn-reorder-spec {
    width: 24px; height: 15px; border-radius: 4px; border: 1px solid var(--a-line);
    background: #fff; color: var(--a-ink); cursor: pointer; font-size: 9px; line-height: 1; padding: 0;
}
.btn-reorder-spec:hover { background: var(--a-soft); border-color: var(--a-accent); }

/* ===== Product image gallery (unlimited images) ===== */
.img-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; margin-bottom: 10px; }
.img-slot { border: 1px solid var(--a-line); border-radius: 8px; padding: 8px; text-align: center; background: var(--a-soft); }
.img-slot .preview { width: 100%; height: 100px; object-fit: contain; background: #fff; border-radius: 6px; border: 1px solid var(--a-line); }
.img-radio { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--a-ink); margin: 6px 0 0; }
.img-del { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--a-danger); margin: 4px 0 0; }
