/*
 * Absher theme – Midnight Slate & Red (colors from the logo).
 * Loaded once by the layout, after Bootstrap. The --ab-* tokens feed Bootstrap's own
 * variables, so existing Bootstrap classes follow the theme; ab-* classes add the shapes.
 */
:root,
[data-bs-theme="light"] {
    --ab-primary: #2e3a5f;
    --ab-primary-light: #4f5d87;
    --ab-accent: #e2001a;
    --ab-ink: #1f2a44;
    --ab-bg: #f7f7fa;
    --ab-surface: #ffffff;
    --ab-soft: #eceef5;
    --ab-line: #c9cfe0;
    --ab-radius: 16px;
    --ab-shadow: 0 6px 20px rgba(31, 42, 68, .08);

    --bs-primary: var(--ab-primary);
    --bs-primary-rgb: 46, 58, 95;
    --bs-link-color: var(--ab-primary);
    --bs-link-color-rgb: 46, 58, 95;
    --bs-link-hover-color: var(--ab-primary-light);
    --bs-link-hover-color-rgb: 79, 93, 135;
    --bs-body-bg: var(--ab-bg);
    --bs-body-color: var(--ab-ink);
    --bs-border-color: var(--ab-line);
    --bs-secondary-bg: var(--ab-soft);
    --bs-tertiary-bg: var(--ab-soft);
    --bs-border-radius: .75rem;
    --bs-border-radius-lg: var(--ab-radius);
    --bs-focus-ring-color: rgba(46, 58, 95, .25);
}

[data-bs-theme="dark"] {
    --ab-primary: #4f5d87;
    --ab-primary-light: #8a9ac4;
    --ab-accent: #ff3b4f;
    --ab-ink: #e6e9f2;
    --ab-bg: #121829;
    --ab-surface: #1b2338;
    --ab-soft: #252f49;
    --ab-line: #34406a;
    --ab-shadow: 0 6px 20px rgba(0, 0, 0, .35);

    --bs-primary: var(--ab-primary);
    --bs-primary-rgb: 79, 93, 135;
    --bs-primary-text-emphasis: var(--ab-primary-light);
    --bs-link-color: var(--ab-primary-light);
    --bs-link-color-rgb: 138, 154, 196;
    --bs-link-hover-color: #b3bfdc;
    --bs-link-hover-color-rgb: 179, 191, 220;
    --bs-body-bg: var(--ab-bg);
    --bs-body-color: var(--ab-ink);
    --bs-border-color: var(--ab-line);
    --bs-secondary-bg: var(--ab-soft);
    --bs-tertiary-bg: var(--ab-soft);
    --bs-focus-ring-color: rgba(138, 154, 196, .3);
}

/* Components take their surface from the tokens (light white, dark navy) through their own variables,
   so colored utilities like .bg-primary and page-specific backgrounds still win */
.card {
    --bs-card-bg: var(--ab-surface);
}

.list-group {
    --bs-list-group-bg: var(--ab-surface);
}

.modal {
    --bs-modal-bg: var(--ab-surface);
}

.dropdown-menu {
    --bs-dropdown-bg: var(--ab-surface);
}

.offcanvas,
.offcanvas-lg,
.offcanvas-md,
.offcanvas-sm {
    --bs-offcanvas-bg: var(--ab-surface);
}

.toast {
    --bs-toast-bg: var(--ab-surface);
}

/* The bg-white / bg-light utilities are light-only; in dark mode they must use the surface color */
[data-bs-theme="dark"] .bg-white,
[data-bs-theme="dark"] .bg-light {
    background-color: var(--ab-surface) !important;
    color: var(--ab-ink);
}

[data-bs-theme="dark"] .text-muted,
[data-bs-theme="dark"] .text-secondary {
    color: rgba(230, 233, 242, .65) !important;
}

/* Bootstrap components */
.btn-primary {
    --bs-btn-bg: var(--ab-primary);
    --bs-btn-border-color: var(--ab-primary);
    --bs-btn-hover-bg: var(--ab-primary-light);
    --bs-btn-hover-border-color: var(--ab-primary-light);
    --bs-btn-active-bg: var(--ab-primary-light);
    --bs-btn-active-border-color: var(--ab-primary-light);
    --bs-btn-disabled-bg: var(--ab-primary);
    --bs-btn-disabled-border-color: var(--ab-primary);
}

.btn-outline-primary {
    --bs-btn-color: var(--ab-primary);
    --bs-btn-border-color: var(--ab-primary);
    --bs-btn-hover-bg: var(--ab-primary);
    --bs-btn-hover-border-color: var(--ab-primary);
    --bs-btn-active-bg: var(--ab-primary);
    --bs-btn-active-border-color: var(--ab-primary);
}

[data-bs-theme="dark"] .btn-outline-primary {
    --bs-btn-color: var(--ab-primary-light);
    --bs-btn-border-color: var(--ab-primary-light);
}

.form-control,
.form-select {
    border-color: var(--ab-line);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--ab-primary-light);
    box-shadow: 0 0 0 .2rem var(--bs-focus-ring-color);
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: var(--ab-soft);
    color: var(--ab-ink);
}

.card {
    border-radius: var(--ab-radius);
}

/* Shared classes */
.ab-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 600;
    color: var(--ab-ink);
}

[dir="rtl"] .ab-title {
    font-family: 'Cairo', sans-serif;
    font-weight: 700;
}

.ab-subtitle {
    font-size: .875rem;
    color: var(--ab-ink);
    opacity: .65;
}

.ab-divider {
    height: 1px;
    border: 0;
    margin: 1rem 0;
    background: linear-gradient(90deg, transparent, var(--ab-line), transparent);
    opacity: 1;
}

.ab-section-label {
    font-size: .7rem;
    letter-spacing: .15em;
    text-transform: uppercase;
    color: var(--ab-primary);
    margin-bottom: .5rem;
}

[data-bs-theme="dark"] .ab-section-label {
    color: var(--ab-primary-light);
}

[dir="rtl"] .ab-section-label {
    letter-spacing: 0;
}

.ab-panel {
    border: 0;
    border-radius: var(--ab-radius);
    background: var(--ab-surface);
    box-shadow: var(--ab-shadow);
}

.ab-btn {
    border: 0;
    border-radius: 999px;
    padding: .7rem 1.5rem;
    font-weight: 700;
    letter-spacing: .03em;
    color: #fff;
    background: linear-gradient(90deg, var(--ab-primary), var(--ab-primary-light));
}

.ab-btn:hover,
.ab-btn:focus,
.ab-btn:active {
    color: #fff;
    filter: brightness(1.08);
}

/* Dark mode: keep white text readable across the whole gradient (light end was 2.8:1) */
[data-bs-theme="dark"] .ab-btn {
    background: linear-gradient(90deg, #3e4a72, #4f5d87);
}

.ab-btn:disabled {
    color: #fff;
    opacity: .65;
}

.ab-input,
.ab-input:focus {
    background-color: var(--ab-soft);
    border-color: transparent;
    color: var(--ab-ink);
}

.ab-input:focus {
    border-color: var(--ab-line);
}

.ab-chip {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .3rem .8rem;
    border: 1px solid var(--ab-line);
    border-radius: 999px;
    font-size: .85rem;
}

.ab-price {
    color: var(--ab-primary);
    font-weight: 700;
}

[data-bs-theme="dark"] .ab-price {
    color: var(--ab-primary-light);
}

.ab-link {
    color: var(--ab-primary);
    text-decoration: none;
}

.ab-link:hover {
    color: var(--ab-primary-light);
}

[data-bs-theme="dark"] .ab-link {
    color: var(--ab-primary-light);
}

/* Bottom nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: color-mix(in srgb, var(--ab-surface) 95%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--ab-line);
    z-index: 1050;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: var(--ab-shadow);
}

.bottom-nav-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    max-width: 500px;
    margin: 0 auto;
    padding: 8px 0;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: color-mix(in srgb, var(--ab-ink) 70%, transparent);
    padding: 8px 16px;
    border-radius: 12px;
    transition: all 0.2s ease;
    min-width: 70px;
    position: relative;
}

/* Only for mouse devices: on phones a tapped item keeps :hover and looks like a second selection */
@media (hover: hover) {
    .bottom-nav-item:hover {
        color: var(--ab-primary);
        background: color-mix(in srgb, var(--ab-primary) 6%, transparent);
    }
}

/* Color alone is not enough here, the normal labels are almost as dark: add a pill, a bold label and a red bar */
.bottom-nav-item.active {
    color: var(--ab-primary);
    background: color-mix(in srgb, var(--ab-primary) 12%, transparent);
}

.bottom-nav-item.active::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 50%;
    width: 18px;
    height: 3px;
    border-radius: 3px;
    background: var(--ab-accent);
    transform: translateX(-50%);
}

.bottom-nav-item.active .bottom-nav-label {
    font-weight: 700;
}

.bottom-nav-item.active .bottom-nav-icon {
    transform: scale(1.1);
}

.bottom-nav-icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
    transition: transform 0.2s ease;
}

.bottom-nav-label {
    font-size: 0.7rem;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
}

.bottom-nav-badge {
    position: absolute;
    top: -6px;
    right: -10px;
    background: linear-gradient(135deg, var(--ab-accent), color-mix(in srgb, var(--ab-accent) 85%, black));
    color: white;
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px color-mix(in srgb, var(--ab-accent) 40%, transparent);
    animation: badgePulse 0.3s ease-out;
}

@keyframes badgePulse {
    0% {
        transform: scale(0.8);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

/* RTL Support */
[dir="rtl"] .bottom-nav-badge {
    right: auto;
    left: -10px;
}

/* Hide bottom nav on pages that shouldn't show it (like login) */
.hide-bottom-nav .bottom-nav {
    display: none;
}

/* Dark mode: the slate primary is too dark on the dark surface, use the light slate */
[data-bs-theme="dark"] .bottom-nav-item:hover,
[data-bs-theme="dark"] .bottom-nav-item.active {
    color: var(--ab-primary-light);
}

[data-bs-theme="dark"] .bottom-nav-item.active {
    background: color-mix(in srgb, var(--ab-primary-light) 18%, transparent);
}

/* Navbar */
.ab-navbar {
    background: var(--ab-surface);
    border-bottom: 1px solid var(--ab-line);
    box-shadow: 0 2px 10px rgba(31, 42, 68, .05);
}

.ab-navbar-title {
    color: var(--ab-ink);
}

/* Sidebar: a floating sheet with grouped items. The hide offset is a variable so RTL only flips its sign
   and Bootstrap's .showing / .show rules still win over it. */
.offcanvas.ab-sheet {
    --bs-offcanvas-width: min(340px, calc(100vw - 2.5rem));
    --bs-offcanvas-bg: var(--ab-bg);
    --ab-sheet-hide: calc(-100% - 1rem);
    top: calc(.75rem + env(safe-area-inset-top));
    bottom: calc(.75rem + env(safe-area-inset-bottom));
    inset-inline-start: .75rem;
    padding-block: 0;
    border: 0;
    border-radius: 24px;
    box-shadow: 0 24px 60px rgba(10, 14, 28, .35);
    transform: translateX(var(--ab-sheet-hide));
    z-index: 1052;
}

html[dir="rtl"] .ab-sheet {
    --ab-sheet-hide: calc(100% + 1rem);
}

.offcanvas.ab-sheet.showing,
.offcanvas.ab-sheet.show:not(.hiding) {
    transform: none;
}

/* Above the bottom nav (z-index 1050) so the sheet floats over the whole screen */
.offcanvas-backdrop {
    z-index: 1051;
}

.offcanvas-backdrop.show {
    backdrop-filter: blur(2px);
}

.ab-sheet-head {
    gap: .75rem;
    padding: 1.25rem 1rem .75rem;
}

.ab-sheet-user {
    display: flex;
    flex: 1;
    align-items: center;
    gap: .75rem;
    min-width: 0;
    color: var(--ab-ink);
    text-decoration: none;
}

.ab-sheet-user:hover {
    color: var(--ab-ink);
}

.ab-sheet-avatar {
    display: grid;
    flex: none;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--ab-primary);
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
}

.ab-sheet-user.active .ab-sheet-avatar {
    box-shadow: 0 0 0 2px var(--ab-bg), 0 0 0 4px var(--ab-accent);
}

.ab-sheet-user-text {
    display: grid;
    min-width: 0;
}

.ab-sheet-name {
    overflow: hidden;
    font-weight: 700;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.ab-sheet-sub {
    color: var(--bs-secondary-color);
    font-size: .78rem;
}

.ab-sheet-body {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    padding: 0 .75rem 1rem;
}

/* Groups keep their full height and the sheet scrolls; shrinking them would clip their last items */
.ab-sheet-body > * {
    flex-shrink: 0;
}

.ab-menu-group {
    overflow: hidden;
    border-radius: 18px;
    background: var(--ab-surface);
    box-shadow: 0 1px 3px rgba(31, 42, 68, .06);
}

.ab-menu-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: .75rem;
    width: 100%;
    padding: .6rem .875rem;
    border: 0;
    background: none;
    color: var(--ab-ink);
    font: inherit;
    text-align: start;
    text-decoration: none;
    transition: background-color .15s;
}

.ab-menu-item + .ab-menu-item::before {
    content: "";
    position: absolute;
    top: 0;
    inset-inline: 3.5rem .875rem;
    border-top: 1px solid var(--ab-line);
    opacity: .6;
}

.ab-menu-item:hover {
    background: var(--ab-soft);
    color: var(--ab-ink);
}

.ab-menu-item:focus-visible {
    outline: 2px solid var(--ab-accent);
    outline-offset: -2px;
}

.ab-menu-item.active {
    font-weight: 700;
}

.ab-menu-item.active::after {
    content: "";
    position: absolute;
    top: 22%;
    bottom: 22%;
    inset-inline-start: 0;
    width: 3px;
    border-radius: 3px;
    background: var(--ab-accent);
}

.ab-menu-icon {
    display: grid;
    flex: none;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: var(--ab-icon, var(--ab-primary));
    color: #fff;
}

.ab-menu-label {
    flex: 1;
    min-width: 0;
}

.ab-menu-chevron {
    flex: none;
    opacity: .35;
}

html[dir="rtl"] .ab-menu-chevron {
    transform: scaleX(-1);
}

.ab-menu-logout,
.ab-menu-logout:hover {
    color: var(--ab-accent);
    font-weight: 700;
}

/* One color per icon, like iOS Settings; white icons read on all of them in both modes */
.ab-ic-home { --ab-icon: var(--ab-primary); }
.ab-ic-cart { --ab-icon: var(--ab-accent); }
.ab-ic-orders { --ab-icon: #d9822b; }
.ab-ic-posts { --ab-icon: #3b82c4; }
.ab-ic-about { --ab-icon: #6b7aa8; }
.ab-ic-faq { --ab-icon: #8b5cf6; }
.ab-ic-privacy { --ab-icon: #16a34a; }
.ab-ic-contact { --ab-icon: #1fa855; }
.ab-ic-settings { --ab-icon: #64748b; }
.ab-ic-cache { --ab-icon: #0ea5a4; }
.ab-ic-logout { --ab-icon: var(--ab-accent); }

.ab-sheet-social {
    padding-top: .25rem;
}

/* Alerts: soft tinted backgrounds */
.alert {
    border: 0;
    border-radius: .75rem;
}

/* Bootstrap parts that hard-code its blue instead of using --bs-primary */
.form-check-input:checked {
    background-color: var(--ab-primary);
    border-color: var(--ab-primary);
}

.form-check-input:focus,
.form-range:focus::-webkit-slider-thumb {
    border-color: var(--ab-primary-light);
    box-shadow: 0 0 0 .2rem var(--bs-focus-ring-color);
}

.form-range::-webkit-slider-thumb,
.form-range::-moz-range-thumb {
    background-color: var(--ab-primary);
}

.progress,
.progress-stacked {
    --bs-progress-bar-bg: var(--ab-primary);
}

.nav-pills {
    --bs-nav-pills-link-active-bg: var(--ab-primary);
}

.dropdown-menu {
    --bs-dropdown-link-active-bg: var(--ab-primary);
}

.list-group {
    --bs-list-group-active-bg: var(--ab-primary);
    --bs-list-group-active-border-color: var(--ab-primary);
}

.pagination {
    --bs-pagination-active-bg: var(--ab-primary);
    --bs-pagination-active-border-color: var(--ab-primary);
    --bs-pagination-color: var(--ab-primary);
}

.spinner-border.text-primary,
.spinner-grow.text-primary {
    color: var(--ab-primary) !important;
}

/* Dark mode: the slate primary is too dark for text on the dark surface (about 2.3:1) */
[data-bs-theme="dark"] .text-primary,
[data-bs-theme="dark"] .link-primary {
    color: var(--ab-primary-light) !important;
}
