﻿/* QSmart admin â€” Bootstrap 5.3 theme layer */
:root, [data-bs-theme="light"] {
    --qs-primary: #7f0025;
    --qs-primary-rgb: 127, 0, 37;
    --qs-primary-soft: #fbe6ec;
    --qs-sidebar-bg: #2b0a12;
    --qs-sidebar-fg: #f1dde2;
    --qs-sidebar-muted: #b48a95;
    --qs-sidebar-active: rgba(255, 255, 255, .1);
    --qs-bg: #f4f6f8;
    --qs-surface: #ffffff;
    --qs-border: #e5e7eb;
    --bs-primary: var(--qs-primary);
    --bs-primary-rgb: var(--qs-primary-rgb);
    --bs-link-color: var(--qs-primary);
    --bs-link-color-rgb: var(--qs-primary-rgb);
    --bs-link-hover-color: #680020;
    --bs-body-font-family: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-body-bg: var(--qs-bg);
    --bs-border-radius: .6rem;
    --bs-border-radius-lg: .85rem;
}

[data-bs-theme="dark"] {
    --qs-primary: #f07a95;
    --qs-primary-rgb: 240, 122, 149;
    --qs-primary-soft: rgba(240, 122, 149, .15);
    --qs-sidebar-bg: #1a070c;
    --qs-sidebar-fg: #f1dde2;
    --qs-sidebar-muted: #a07c86;
    --qs-bg: #170f11;
    --qs-surface: #21161a;
    --qs-border: #35252a;
    --bs-primary: var(--qs-primary);
    --bs-primary-rgb: var(--qs-primary-rgb);
    --bs-link-color: var(--qs-primary);
    --bs-link-color-rgb: var(--qs-primary-rgb);
    --bs-link-hover-color: #f6a3b5;
    --bs-body-bg: var(--qs-bg);
    --bs-body-color: #ece2e4;
    --bs-border-color: var(--qs-border);
}

body { background: var(--qs-bg); -webkit-font-smoothing: antialiased; }

.btn-primary {
    --bs-btn-bg: var(--qs-primary); --bs-btn-border-color: var(--qs-primary);
    --bs-btn-hover-bg: #680020; --bs-btn-hover-border-color: #680020;
    --bs-btn-active-bg: #52001a; --bs-btn-active-border-color: #52001a;
    --bs-btn-disabled-bg: var(--qs-primary); --bs-btn-disabled-border-color: var(--qs-primary);
}
[data-bs-theme="dark"] .btn-primary { --bs-btn-color: #2a0510; --bs-btn-hover-color: #2a0510; --bs-btn-hover-bg: #f6a3b5; --bs-btn-hover-border-color: #f6a3b5; --bs-btn-active-color: #2a0510; }
.btn-outline-primary { --bs-btn-color: var(--qs-primary); --bs-btn-border-color: var(--qs-primary); --bs-btn-hover-bg: var(--qs-primary); --bs-btn-hover-border-color: var(--qs-primary); --bs-btn-active-bg: var(--qs-primary); }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: rgba(var(--qs-primary-rgb), .6); box-shadow: 0 0 0 .2rem rgba(var(--qs-primary-rgb), .2); }
.form-check-input:checked { background-color: var(--qs-primary); border-color: var(--qs-primary); }
.pagination { --bs-pagination-active-bg: var(--qs-primary); --bs-pagination-active-border-color: var(--qs-primary); --bs-pagination-color: var(--qs-primary); }
.nav-pills { --bs-nav-pills-link-active-bg: var(--qs-primary); }
.nav-link { color: var(--bs-body-color); }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
    --bs-offcanvas-width: 260px;
    --bs-offcanvas-bg: var(--qs-sidebar-bg);
    /* !important: Bootstrap's .offcanvas-lg forces a transparent background on desktop */
    background-color: var(--qs-sidebar-bg) !important;
    color: var(--qs-sidebar-fg);
    width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    transition: width .2s ease;
}
@media (min-width: 992px) {
    .sidebar { position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; overflow-x: hidden; scrollbar-width: none; }
    .sidebar::-webkit-scrollbar { display: none; }
}
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.1rem .75rem; }
.brand-link { display: flex; align-items: center; gap: .75rem; color: #fff; text-decoration: none; white-space: nowrap; }
.brand-link strong { color: #fff; }
.brand-link small { display: block; font-size: .72rem; color: var(--qs-sidebar-muted); font-weight: 500; }
/* Logo is bordeaux on transparent: rendered white on the dark sidebar */
.brand-link { flex-direction: column; align-items: flex-start; gap: .35rem; }
.brand-logo { height: 36px; width: auto; filter: brightness(0) invert(1); }
.brand-mark-img { display: none; width: 40px; height: 40px; filter: brightness(0) invert(1); }
.auth-logo { width: 220px; max-width: 70%; height: auto; }
[data-bs-theme="dark"] .auth-logo { filter: brightness(0) invert(1); }

.sidebar-nav { padding: .25rem .65rem 1rem; display: flex; flex-direction: column; gap: 1px; }
.nav-section { font-size: .66rem; text-transform: uppercase; letter-spacing: .08em; color: var(--qs-sidebar-muted); padding: .75rem .75rem .25rem; font-weight: 600; white-space: nowrap; }
.nav-item {
    display: flex; align-items: center; gap: .75rem; padding: .45rem .75rem; border-radius: .5rem;
    color: var(--qs-sidebar-fg); text-decoration: none; font-size: .9rem; font-weight: 500; white-space: nowrap;
    transition: background-color .15s, color .15s;
}
.nav-item i { font-size: 1.05rem; opacity: .9; flex-shrink: 0; }
.nav-item:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav-item.active { background: var(--qs-sidebar-active); color: #fff; box-shadow: inset 3px 0 0 #f07a95; }
.nav-item:focus-visible { outline: 2px solid #f07a95; outline-offset: -2px; }

/* Collapsed (icon rail) â€” desktop only, toggled from the topbar and remembered per browser */
@media (min-width: 992px) {
    .sidebar-collapsed .sidebar { width: 72px; }
    .sidebar-collapsed .sidebar .nav-label,
    .sidebar-collapsed .sidebar .bi-box-arrow-up-right { display: none; }
    .sidebar-collapsed .sidebar-brand { justify-content: center; padding-inline: 0; }
    .sidebar-collapsed .brand-logo { display: none; }
    .sidebar-collapsed .brand-mark-img { display: block; }
    .sidebar-collapsed .sidebar-nav { padding-inline: .6rem; }
    .sidebar-collapsed .nav-item { justify-content: center; padding: .55rem 0; }
    .sidebar-collapsed .nav-item i { font-size: 1.15rem; }
    .sidebar-collapsed .nav-section { padding: .5rem 0; margin: 0 .4rem; border-top: 1px solid rgba(255, 255, 255, .08); }
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .5rem;
    padding: .65rem 1rem; background: color-mix(in srgb, var(--qs-surface) 88%, transparent);
    backdrop-filter: saturate(180%) blur(10px); border-bottom: 1px solid var(--qs-border);
}
.topbar-title { font-weight: 600; font-size: 1rem; }
@media (min-width: 992px) { .topbar-title { visibility: hidden; } }
.btn-icon { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 10px; padding: 0; color: var(--bs-body-color); }
.btn-icon:hover { background: rgba(var(--qs-primary-rgb), .08); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--qs-primary); color: #fff; font-weight: 600; font-size: .85rem; }
[data-bs-theme="dark"] .avatar { color: #2a0510; }

.content { padding: 1.25rem; width: 100%; }
@media (min-width: 768px) { .content { padding: 1.75rem 2rem; } }

/* ---------- Page header ---------- */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.page-header .subtitle { color: var(--bs-secondary-color); font-size: .9rem; margin-top: .15rem; }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.breadcrumb { font-size: .82rem; margin-bottom: .25rem; }

/* ---------- Cards ---------- */
.card { background: var(--qs-surface); border: 1px solid var(--qs-border); border-radius: var(--bs-border-radius-lg); box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.card-header { background: transparent; border-bottom: 1px solid var(--qs-border); font-weight: 600; padding: .9rem 1.1rem; }
.card-body { padding: 1.1rem; }
.section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--bs-secondary-color); font-weight: 600; margin-bottom: .75rem; }

.stat-card { display: flex; flex-direction: row; align-items: center; gap: 1rem; padding: 1.1rem; text-decoration: none; color: inherit; height: 100%; transition: transform .15s, box-shadow .15s; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(16, 24, 40, .08); color: inherit; }
.stat-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 1.35rem; flex-shrink: 0; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--bs-secondary-color); font-size: .85rem; }
.tone-brand { background: #fbe6ec; color: #7f0025; }
.tone-amber { background: #fef3c7; color: #b45309; }
.tone-blue { background: #dbeafe; color: #1d4ed8; }
.tone-rose { background: #ffe4e6; color: #be123c; }
.tone-violet { background: #ede9fe; color: #6d28d9; }
[data-bs-theme="dark"] .tone-brand { background: rgba(240, 122, 149, .15); color: #f6a3b5; }
[data-bs-theme="dark"] .tone-amber { background: rgba(251, 191, 36, .15); color: #fcd34d; }
[data-bs-theme="dark"] .tone-blue { background: rgba(96, 165, 250, .15); color: #93c5fd; }
[data-bs-theme="dark"] .tone-rose { background: rgba(251, 113, 133, .15); color: #fda4af; }
[data-bs-theme="dark"] .tone-violet { background: rgba(167, 139, 250, .15); color: #c4b5fd; }

/* ---------- Toolbar & filters ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .85rem 1rem; border-bottom: 1px solid var(--qs-border); }
.toolbar .search { position: relative; flex: 1 1 220px; max-width: 360px; }
.toolbar .search i { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--bs-secondary-color); }
.toolbar .search input { padding-left: 2.2rem; }
.toolbar .form-select { width: auto; min-width: 150px; }
@media (max-width: 575.98px) {
    .toolbar .search { max-width: none; flex-basis: 100%; }
    .toolbar .form-select { flex: 1 1 45%; min-width: 0; }
}

/* ---------- Data table â†’ cards on mobile ---------- */
.table-data { margin: 0; --bs-table-bg: transparent; }
.table-data thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--bs-secondary-color); font-weight: 600; border-bottom-width: 1px; white-space: nowrap; padding: .7rem 1rem; }
.table-data thead th a { color: inherit; text-decoration: none; }
.table-data td { padding: .75rem 1rem; vertical-align: middle; border-color: var(--qs-border); }
.table-data tbody tr:hover { background: rgba(var(--qs-primary-rgb), .035); }
.table-data .actions { white-space: nowrap; text-align: right; }
.cell-title { font-weight: 600; color: var(--bs-body-color); text-decoration: none; }
.cell-title:hover { color: var(--qs-primary); }
.cell-sub { font-size: .8rem; color: var(--bs-secondary-color); }
.thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: var(--qs-border); }

@media (max-width: 767.98px) {
    .table-data thead { display: none; }
    .table-data, .table-data tbody, .table-data tr, .table-data td { display: block; width: 100%; }
    .table-data tr { padding: .85rem 1rem; border-bottom: 1px solid var(--qs-border); position: relative; }
    .table-data td { border: 0; padding: .15rem 0; display: flex; gap: .75rem; justify-content: space-between; text-align: right; }
    .table-data td::before { content: attr(data-label); font-size: .78rem; color: var(--bs-secondary-color); text-align: left; flex-shrink: 0; }
    .table-data td.td-main { display: block; text-align: left; padding-bottom: .4rem; padding-right: 5.5rem; }
    .table-data td.td-main::before { display: none; }
    .table-data td.actions { position: absolute; top: .65rem; right: .75rem; width: auto; padding: 0; }
    .table-data td.actions::before { display: none; }
    .table-data td.hide-mobile { display: none; }
}

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--bs-secondary-color); }
.empty-state i { font-size: 2.5rem; display: block; margin-bottom: .5rem; opacity: .5; }

.pager-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; padding: .85rem 1rem; border-top: 1px solid var(--qs-border); }

/* ---------- Badges ---------- */
.badge-soft { font-weight: 600; font-size: .74rem; padding: .35em .65em; border-radius: 999px; }
.status-0 { background: #dbeafe; color: #1d4ed8; }
.status-1 { background: #fef3c7; color: #b45309; }
.status-2 { background: #dcfce7; color: #15803d; }
.status-3 { background: #ffe4e6; color: #be123c; }
.status-4 { background: #e0f2fe; color: #0369a1; }
.status-5 { background: #f1f5f9; color: #475569; }
.badge-yes { background: #dcfce7; color: #15803d; }
.badge-no { background: #f1f5f9; color: #64748b; }
[data-bs-theme="dark"] .status-0, [data-bs-theme="dark"] .status-4 { background: rgba(96, 165, 250, .16); color: #93c5fd; }
[data-bs-theme="dark"] .status-1 { background: rgba(251, 191, 36, .16); color: #fcd34d; }
[data-bs-theme="dark"] .status-2, [data-bs-theme="dark"] .badge-yes { background: rgba(74, 222, 128, .16); color: #86efac; }
[data-bs-theme="dark"] .status-3 { background: rgba(251, 113, 133, .16); color: #fda4af; }
[data-bs-theme="dark"] .status-5, [data-bs-theme="dark"] .badge-no { background: rgba(148, 163, 184, .16); color: #cbd5e1; }

/* ---------- Forms ---------- */
.form-label { font-weight: 500; font-size: .88rem; margin-bottom: .3rem; }
.form-text { font-size: .78rem; }
.form-actions {
    position: sticky; bottom: 0; z-index: 10; display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end;
    padding: .85rem 1rem; margin: 1rem -1rem -1rem; background: color-mix(in srgb, var(--qs-surface) 92%, transparent);
    backdrop-filter: blur(8px); border-top: 1px solid var(--qs-border); border-radius: 0 0 var(--bs-border-radius-lg) var(--bs-border-radius-lg);
}
@media (max-width: 575.98px) { .form-actions .btn { flex: 1 1 auto; } }
.field-validation-error, .validation-summary-errors { color: var(--bs-danger); font-size: .82rem; }
.validation-summary-errors ul { margin: 0; padding-left: 1rem; }
.input-validation-error { border-color: var(--bs-danger) !important; }

.image-preview { position: relative; display: inline-block; }
.image-preview img { max-width: 100%; max-height: 220px; border-radius: .6rem; border: 1px solid var(--qs-border); }

.rte { background: var(--qs-surface); border-radius: var(--bs-border-radius); }
.rte .ql-toolbar.ql-snow { border-color: var(--bs-border-color); border-radius: var(--bs-border-radius) var(--bs-border-radius) 0 0; }
.rte .ql-container.ql-snow { border-color: var(--bs-border-color); border-radius: 0 0 var(--bs-border-radius) var(--bs-border-radius); min-height: 180px; font-family: inherit; font-size: .95rem; }
[data-bs-theme="dark"] .rte .ql-stroke { stroke: #cbd5e1; }
[data-bs-theme="dark"] .rte .ql-fill { fill: #cbd5e1; }
[data-bs-theme="dark"] .rte .ql-picker { color: #cbd5e1; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; }
.gallery-item { position: relative; border-radius: .6rem; overflow: hidden; border: 1px solid var(--qs-border); aspect-ratio: 4 / 3; }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; }
.gallery-item form { position: absolute; top: .35rem; right: .35rem; }

.dl-grid { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; font-size: .9rem; margin: 0; }
.dl-grid dt { color: var(--bs-secondary-color); font-weight: 500; }
.dl-grid dd { margin: 0; word-break: break-word; }

.timeline-item { display: flex; gap: .75rem; padding: .75rem 0; border-bottom: 1px dashed var(--qs-border); }
.timeline-item:last-child { border-bottom: 0; }

/* ---------- Auth ---------- */
.auth-body { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem 1rem;
    background: radial-gradient(1200px 600px at 10% -10%, rgba(127, 0, 37, .14), transparent), radial-gradient(900px 500px at 110% 110%, rgba(127, 0, 37, .10), transparent), var(--qs-bg); }
.auth-card { width: 100%; max-width: 420px; background: var(--qs-surface); border: 1px solid var(--qs-border); border-radius: 1.1rem; padding: 2rem 1.5rem; box-shadow: 0 20px 50px rgba(16, 24, 40, .08); }
@media (min-width: 576px) { .auth-card { padding: 2.5rem 2.25rem; } }

.min-w-0 { min-width: 0; }
@media print {
    .sidebar, .topbar, .form-actions, .page-actions, .no-print { display: none !important; }
    .content { padding: 0; }
}
