@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
:root {
    --sidebar-width: 278px;
    --app-bg: #f5f3ee;
    --app-surface: rgba(255, 255, 255, .88);
    --app-surface-solid: #ffffff;
    --app-border: rgba(148, 163, 184, .22);
    --app-primary: #7c3aed;
    --app-primary-2: #2563eb;
    --app-accent: #d97706;
    --app-success: #059669;
    --app-warning: #d97706;
    --app-danger: #dc2626;
    --app-dark: #111827;
    --app-muted: #64748b;
    --shadow-soft: 0 12px 35px rgba(15, 23, 42, .08);
    --shadow-premium: 0 24px 65px rgba(15, 23, 42, .13);
    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 14px;
}
* { box-sizing: border-box; }
html { min-height: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Vazirmatn', Tahoma, Arial, sans-serif;
    color: #1f2937;
    background:
        radial-gradient(circle at 10% 0%, rgba(124, 58, 237, .10), transparent 34%),
        radial-gradient(circle at 90% 10%, rgba(217, 119, 6, .11), transparent 30%),
        linear-gradient(135deg, #f8fafc 0%, #f5f3ee 48%, #eef2ff 100%);
    background-attachment: fixed;
}
a { text-decoration: none; }
img, svg { max-width: 100%; }
::selection { background: rgba(124, 58, 237, .18); }

.app-shell { min-height: 100vh; display: flex; align-items: stretch; }
.app-sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    position: sticky;
    top: 0;
    color: #fff;
    background:
        radial-gradient(circle at top right, rgba(124, 58, 237, .32), transparent 30%),
        linear-gradient(180deg, #0b1020 0%, #111827 48%, #17111e 100%);
    padding: 16px 13px;
    box-shadow: -12px 0 45px rgba(15, 23, 42, .20);
    overflow-y: auto;
    z-index: 1040;
}
.app-sidebar::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 130px;
    background: linear-gradient(135deg, rgba(255,255,255,.12), rgba(255,255,255,0));
    pointer-events: none;
}
.sidebar-inner { position: relative; z-index: 1; }
.brand-box {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 8px 18px;
    margin-bottom: 10px;
}
.brand-icon {
    width: 48px;
    height: 48px;
    border-radius: 18px;
    background: linear-gradient(135deg, #f59e0b, #7c3aed 58%, #2563eb);
    display: grid;
    place-items: center;
    font-size: 21px;
    box-shadow: 0 14px 35px rgba(124, 58, 237, .35);
}
.brand-title { font-weight: 800; font-size: 17px; letter-spacing: -.2px; }
.brand-subtitle { color: #cbd5e1; font-size: 12px; margin-top: 2px; }
.side-section {
    color: #94a3b8;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .4px;
    padding: 12px 14px 7px;
    text-transform: uppercase;
}
.side-nav { display: grid; gap: 6px; }
.side-nav a {
    color: #dbe3ef;
    padding: 12px 12px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 11px;
    position: relative;
    overflow: hidden;
    transition: .18s ease;
    border: 1px solid transparent;
}
.side-nav a::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0;
    background: linear-gradient(135deg, rgba(255,255,255,.13), rgba(255,255,255,.04));
    transition: .18s ease;
}
.side-nav a:hover,
.side-nav a.active {
    color: #fff;
    transform: translateX(-2px);
    border-color: rgba(255,255,255,.10);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.10), 0 12px 24px rgba(0,0,0,.16);
}
.side-nav a:hover::before,
.side-nav a.active::before { opacity: 1; }
.side-nav a.active { background: rgba(255,255,255,.08); }
.side-nav i {
    width: 30px;
    height: 30px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    text-align: center;
    color: #fde68a;
    background: rgba(255,255,255,.08);
    position: relative;
    z-index: 1;
}
.side-nav span { position: relative; z-index: 1; }
.sidebar-footer {
    margin-top: 18px;
    padding: 12px;
    border-radius: 18px;
    color: #cbd5e1;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.08);
    font-size: 12px;
}

.app-main {
    flex: 1;
    min-width: 0;
    padding: 22px;
}
.topbar {
    position: sticky;
    top: 14px;
    z-index: 20;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    background: rgba(255,255,255,.78);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255,255,255,.72);
    border-radius: 24px;
    padding: 14px 16px;
    box-shadow: var(--shadow-soft);
    margin-bottom: 18px;
}
.topbar-title-wrap { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-icon {
    width: 44px;
    height: 44px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, var(--app-primary), var(--app-primary-2));
    box-shadow: 0 14px 25px rgba(37, 99, 235, .22);
}
.topbar h1 { font-size: 22px; font-weight: 800; margin: 0; letter-spacing: -.3px; }
.topbar-date { color: var(--app-muted); font-size: 12px; margin-top: 3px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: end; }
.user-pill {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 40px;
    padding: 7px 12px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid #e8edf5;
    box-shadow: 0 8px 20px rgba(15,23,42,.05);
    color: #334155;
    font-size: 13px;
}
.user-pill i { color: var(--app-primary); }

.content-card,
.stat-card,
.page-hero {
    background: var(--app-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,.75);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-soft);
}
.content-card {
    padding: 18px;
    position: relative;
    overflow: hidden;
}
.content-card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, var(--app-accent), var(--app-primary), var(--app-primary-2));
}
.content-card h2 { font-size: 18px; font-weight: 800; margin-bottom: 6px; }
.page-hero {
    padding: 18px;
    overflow: hidden;
    position: relative;
    background:
        radial-gradient(circle at 10% 5%, rgba(245, 158, 11, .17), transparent 32%),
        radial-gradient(circle at 95% 0%, rgba(124, 58, 237, .15), transparent 30%),
        rgba(255,255,255,.84);
}
.page-hero::after {
    content: '';
    position: absolute;
    left: -60px;
    top: -70px;
    width: 180px;
    height: 180px;
    border-radius: 999px;
    background: rgba(124, 58, 237, .08);
}
.page-hero > * { position: relative; z-index: 1; }
.page-kicker {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #6d28d9;
    background: rgba(124, 58, 237, .10);
    border: 1px solid rgba(124, 58, 237, .12);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    padding: 6px 10px;
    margin-bottom: 10px;
}
.page-hero h2 { font-size: 24px; font-weight: 900; margin: 0 0 6px; letter-spacing: -.4px; }
.page-hero p { color: var(--app-muted); margin: 0; }

.stat-card {
    min-height: 94px;
    padding: 17px;
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
    overflow: hidden;
}
.stat-card::after {
    content: '';
    position: absolute;
    left: -18px;
    top: -18px;
    width: 86px;
    height: 86px;
    border-radius: 999px;
    background: rgba(124,58,237,.06);
}
.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, rgba(124,58,237,.14), rgba(37,99,235,.12));
    color: var(--app-primary);
    font-size: 21px;
    position: relative;
    z-index: 1;
}
.stat-title { color: var(--app-muted); font-size: 13px; font-weight: 600; }
.stat-value { font-size: 23px; font-weight: 900; margin-top: 3px; color: #111827; }
.stat-warning .stat-icon { background: rgba(245, 158, 11, .15); color: var(--app-warning); }
.stat-success .stat-icon { background: rgba(5, 150, 105, .12); color: var(--app-success); }
.mini-stat { min-height: 92px; }

.btn {
    border-radius: 14px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 38px;
}
.btn-sm { border-radius: 11px; min-height: 32px; }
.btn-primary {
    border: 0;
    background: linear-gradient(135deg, var(--app-primary), var(--app-primary-2));
    box-shadow: 0 13px 28px rgba(37, 99, 235, .20);
}
.btn-primary:hover { filter: brightness(.98); transform: translateY(-1px); box-shadow: 0 18px 34px rgba(37, 99, 235, .26); }
.btn-outline-primary { border-color: rgba(124,58,237,.24); color: #6d28d9; background: rgba(124,58,237,.04); }
.btn-outline-primary:hover { background: #6d28d9; border-color: #6d28d9; color: #fff; }
.btn-outline-secondary { border-color: #dbe3ef; color: #475569; background: #fff; }
.btn-outline-secondary:hover { background: #f1f5f9; color: #111827; border-color: #cbd5e1; }
.btn-light, .btn-soft {
    background: #fff;
    border: 1px solid #e5edf6;
    color: #334155;
    box-shadow: 0 8px 18px rgba(15,23,42,.04);
}
.btn-soft:hover, .btn-light:hover { background: #f8fafc; border-color: #dbe3ef; }
.btn-icon {
    width: 36px;
    padding-inline: 0;
}
.action-group { display: inline-flex; gap: 6px; align-items: center; justify-content: end; }

.filter-box {
    background: linear-gradient(180deg, rgba(248,250,252,.95), rgba(255,255,255,.88));
    border: 1px solid #e6edf6;
    border-radius: 20px;
    padding: 14px;
}
.form-label { font-weight: 800; color: #334155; font-size: 12px; margin-bottom: 6px; }
.form-control,
.form-select {
    border-color: #dbe3ef;
    border-radius: 14px;
    min-height: 43px;
    background-color: rgba(255,255,255,.92);
    transition: .15s ease;
}
.form-control:hover,
.form-select:hover { border-color: #c6d3e2; }
.form-control:focus,
.form-select:focus {
    border-color: rgba(124, 58, 237, .45);
    box-shadow: 0 0 0 .22rem rgba(124, 58, 237, .10);
}
textarea.form-control { min-height: 86px; }
.input-group-text { border-radius: 14px; border-color: #dbe3ef; background: #f8fafc; }

.table-responsive {
    border: 1px solid #edf1f7;
    border-radius: 20px;
    overflow: auto;
    background: #fff;
}
.app-table { margin-bottom: 0; }
.app-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f8fafc;
    color: #475569;
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
    border-bottom: 1px solid #e2e8f0;
    padding: 13px 12px;
}
.app-table tbody td {
    font-size: 14px;
    vertical-align: middle;
    border-color: #eef2f7;
    padding: 13px 12px;
}
.app-table tbody tr { transition: .12s ease; }
.app-table tbody tr:hover { background: #fbfdff; transform: scale(1.001); }
.table-thumb {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 15px;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, #d97706, #7c3aed);
    box-shadow: 0 10px 22px rgba(124,58,237,.16);
}
.book-title-cell { display: flex; align-items: center; gap: 11px; min-width: 230px; }
.book-title { font-weight: 900; color: #111827; }
.book-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 7px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #64748b;
    font-size: 11px;
    white-space: nowrap;
}
.badge { font-weight: 800; letter-spacing: 0; }
.badge.text-bg-light { background: #f1f5f9 !important; color: #334155 !important; border: 1px solid #e2e8f0; }
.badge.text-bg-success { background: #dcfce7 !important; color: #166534 !important; border: 1px solid #bbf7d0; }
.badge.text-bg-secondary { background: #e2e8f0 !important; color: #475569 !important; }
.badge.text-bg-warning { background: #fef3c7 !important; color: #92400e !important; border: 1px solid #fde68a; }
.row-warning-soft td { background: #fffbeb !important; }
.empty-box,
.empty-mini {
    border: 1px dashed #cbd5e1;
    background: linear-gradient(180deg, #f8fafc, #fff);
    border-radius: 20px;
    color: #94a3b8;
    text-align: center;
    padding: 30px 16px;
}
.empty-box { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 170px; }
.empty-box i { font-size: 30px; }
.empty-state-icon {
    width: 60px;
    height: 60px;
    border-radius: 22px;
    display: grid;
    place-items: center;
    margin: 0 auto 10px;
    background: rgba(124,58,237,.08);
    color: #7c3aed;
    font-size: 24px;
}

.alert {
    border: 0;
    border-radius: 18px;
    box-shadow: var(--shadow-soft);
    font-weight: 700;
}
.modal-content {
    border: 1px solid rgba(255,255,255,.78);
    border-radius: 26px;
    overflow: hidden;
    box-shadow: var(--shadow-premium);
}
.modal-header {
    background:
        radial-gradient(circle at 10% 0, rgba(217,119,6,.12), transparent 30%),
        linear-gradient(180deg, #fff, #f8fafc);
    border-bottom: 1px solid #edf1f7;
    padding: 17px 20px;
}
.modal-title { font-weight: 900; }
.modal-body { padding: 18px 20px; }
.modal-footer { border-top: 1px solid #edf1f7; padding: 14px 20px; background: #fbfdff; }
.modal-header .btn-close { margin: 0; }
.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background:
        radial-gradient(circle at top right, rgba(124, 58, 237, .16), transparent 35%),
        radial-gradient(circle at bottom left, rgba(217, 119, 6, .16), transparent 32%),
        #f8fafc;
}
.auth-card {
    width: 100%;
    max-width: 430px;
    background: rgba(255,255,255,.88);
    backdrop-filter: blur(14px);
    border: 1px solid rgba(255,255,255,.70);
    border-radius: 28px;
    padding: 30px;
    box-shadow: var(--shadow-premium);
}
.auth-card-wide { max-width: 560px; }
.auth-logo {
    width: 62px;
    height: 62px;
    border-radius: 22px;
    display: grid;
    place-items: center;
    margin-bottom: 16px;
    color: #fff;
    background: linear-gradient(135deg, #f59e0b, #7c3aed 60%, #2563eb);
    font-size: 25px;
    box-shadow: 0 18px 35px rgba(124,58,237,.24);
}
.auth-card h1 { font-size: 24px; font-weight: 900; }
.ts-wrapper.single .ts-control {
    border-radius: 14px;
    min-height: 43px;
    border-color: #dbe3ef;
    padding: 8px 12px;
    background: rgba(255,255,255,.92);
}
.ts-wrapper.focus .ts-control { border-color: rgba(124,58,237,.45); box-shadow: 0 0 0 .22rem rgba(124,58,237,.10); }
.ts-dropdown {
    direction: rtl;
    text-align: right;
    border-radius: 16px;
    border-color: #dbe3ef;
    box-shadow: 0 18px 40px rgba(15,23,42,.12);
    overflow: hidden;
}
.ts-dropdown .option { padding: 10px 12px; }
.ts-dropdown .active { background: #f3e8ff; color: #581c87; }



/* Fix Tom Select without needing external tom-select.css */
.ts-wrapper {
    position: relative;
    width: 100%;
    min-height: 43px;
}
.ts-wrapper .ts-control {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 6px;
    width: 100%;
    overflow: hidden;
    cursor: pointer;
}
.ts-wrapper.single .ts-control .item {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ts-wrapper .ts-control > input {
    min-width: 24px !important;
    flex: 1 1 auto !important;
    border: 0 !important;
    outline: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    color: #111827;
}
.ts-wrapper.single.input-hidden .ts-control > input {
    position: absolute !important;
    opacity: 0 !important;
    width: 1px !important;
    min-width: 1px !important;
}
.ts-wrapper.single .ts-control::after {
    content: '\f107';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    color: #64748b;
    margin-inline-start: auto;
    pointer-events: none;
}
.ts-wrapper.dropdown-active .ts-control::after { transform: rotate(180deg); }
.ts-dropdown {
    position: absolute !important;
    top: calc(100% + 7px) !important;
    right: 0 !important;
    left: 0 !important;
    width: 100% !important;
    z-index: 3000 !important;
    display: none;
    background: #fff;
}
.ts-wrapper.dropdown-active .ts-dropdown { display: block; }
.ts-dropdown-content {
    max-height: 230px;
    overflow-y: auto;
    padding: 6px;
}
.ts-dropdown .option,
.ts-dropdown .no-results {
    border-radius: 11px;
    margin-bottom: 2px;
}
.ts-dropdown .no-results {
    padding: 10px 12px;
    color: #94a3b8;
}
.plugin-clear_button .clear-button,
.ts-wrapper .clear-button {
    display: none !important;
}

/* Cleaner books filter bar */
.filter-box .form-label {
    display: block;
    line-height: 1.2;
}
.filter-box .btn {
    width: 100%;
}
.filter-box .row {
    align-items: end;
}
@media (min-width: 1200px) {
    .filter-box .col-xl-search { flex: 0 0 auto; width: 42%; }
    .filter-box .col-xl-category { flex: 0 0 auto; width: 25%; }
    .filter-box .col-xl-status { flex: 0 0 auto; width: 15%; }
    .filter-box .col-xl-button { flex: 0 0 auto; width: 18%; }
}

@media (max-width: 991px) {
    .app-sidebar {
        position: fixed;
        right: calc(var(--sidebar-width) * -1 - 20px);
        transition: .22s ease;
    }
    body.sidebar-open .app-sidebar { right: 0; }
    body.sidebar-open::after {
        content: '';
        position: fixed;
        inset: 0;
        z-index: 1030;
        background: rgba(15,23,42,.45);
        backdrop-filter: blur(2px);
    }
    .app-main { padding: 12px; }
    .topbar { position: relative; top: auto; flex-wrap: wrap; border-radius: 20px; }
    .topbar-actions { width: 100%; justify-content: space-between; }
    .page-hero h2 { font-size: 20px; }
}
@media (max-width: 767px) {
    .content-card, .page-hero { padding: 14px; border-radius: 20px; }
    .app-table { min-width: 980px; }
    .stat-card { min-height: 84px; }
    .stat-value { font-size: 19px; }
}

/* Step 3 fix 3: hide the original select after Tom Select initializes.
   Without the official tom-select.css, the native <select> can stay visible in modals. */
select.tomselected,
select.ts-hidden-accessible,
.ts-hidden-accessible {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    position: absolute !important;
    width: 0 !important;
    height: 0 !important;
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
}

.modal .ts-wrapper {
    width: 100% !important;
    margin: 0 !important;
}

.modal .ts-wrapper.single .ts-control {
    min-height: 40px;
}

/* Step 7: premium sales/purchase list pages */
.list-hero {
    border: 1px solid rgba(124, 58, 237, .12);
}
.purchase-hero {
    background:
        radial-gradient(circle at 10% 5%, rgba(34, 197, 94, .14), transparent 32%),
        radial-gradient(circle at 95% 0%, rgba(249, 115, 22, .15), transparent 30%),
        rgba(255,255,255,.84);
}
.list-filter-card {
    padding-top: 16px;
}
.list-filter-card::before,
.list-card::before {
    height: 3px;
}
.list-stat .stat-icon {
    color: #fff;
    background: linear-gradient(135deg, var(--app-primary), var(--app-primary-2));
}
.stat-success-soft .stat-icon {
    background: linear-gradient(135deg, #10b981, #059669);
}
.list-card .table-responsive {
    border-radius: 18px;
    border: 1px solid rgba(226, 232, 240, .85);
    overflow: auto;
}
.btn-soft-primary {
    color: #5b21b6;
    background: rgba(124, 58, 237, .10);
    border-color: rgba(124, 58, 237, .16);
    font-weight: 800;
}
.btn-soft-primary:hover {
    color: #fff;
    background: linear-gradient(135deg, var(--app-primary), var(--app-primary-2));
    border-color: transparent;
}
.profit-text {
    color: #047857;
    font-weight: 900;
    white-space: nowrap;
}
.detail-chip {
    height: 100%;
    border-radius: 18px;
    padding: 12px 14px;
    background: linear-gradient(135deg, rgba(248,250,252,.96), rgba(255,255,255,.78));
    border: 1px solid rgba(226,232,240,.9);
    box-shadow: 0 10px 24px rgba(15,23,42,.05);
}
.detail-chip span {
    display: block;
    color: #64748b;
    font-size: 12px;
    margin-bottom: 5px;
}
.detail-chip strong {
    color: #0f172a;
    font-size: 15px;
}
.premium-modal .modal-header {
    background:
        radial-gradient(circle at top right, rgba(124, 58, 237, .10), transparent 36%),
        linear-gradient(180deg, #fff, #f8fafc);
}
.premium-modal .modal-footer {
    background: #f8fafc;
}
.premium-modal .app-table {
    min-width: 900px;
}
@media (max-width: 991px) {
    .list-filter-card .row > [class*="col-"] {
        width: 100%;
    }
}
