/*
 * KPI tizimi: umumiy dizayn tizimi (user va admin sahifalari uchun).
 * - ranglar CSS o'zgaruvchilarida (kun/tun rejimi, yon panel va yuqori panel ranglari)
 * - Bootstrap komponentlari shu o'zgaruvchilarga moslashtirilgan
 * - sozlama paneli (o'ng tomondan chiqadigan panel) uslublari
 * Bu fayl Bootstrap CSS dan KEYIN ulanishi kerak.
 */

/* ---------- Asosiy o'zgaruvchilar (kun rejimi) ---------- */
:root {
    --font-sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --radius: 8px;
    --radius-sm: 6px;
    --sidebar-w: 264px;
    --navbar-h: 60px;

    --bg: #f3f5f8;
    --surface: #ffffff;
    --surface-2: #f7f9fb;
    --border: #dbe2ea;
    --border-strong: #c3ceda;
    --text: #1b2633;
    --text-muted: #5b6777;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
    --shadow-md: 0 6px 18px rgba(16, 24, 40, .10);

    /* yon panel (standart: zumrad) */
    --sb-bg: #0e5a46;
    --sb-fg: #ffffff;
    --sb-fg-muted: rgba(255, 255, 255, .72);
    --sb-hover: rgba(255, 255, 255, .10);
    --sb-active: rgba(255, 255, 255, .18);
    --sb-border: rgba(255, 255, 255, .14);

    /* yuqori panel (standart: zumrad) */
    --nav-bg: #0e5a46;
    --nav-fg: #ffffff;
    --nav-hover: rgba(255, 255, 255, .12);

    /* asosiy tugma / havola rangi (yuqori panel rangidan olinadi) */
    --acc: #0e5a46;
    --acc-rgb: 14, 90, 70;
    --acc-dk: #4fcfa3;
    --primary: var(--acc);
    --primary-rgb: var(--acc-rgb);
    --primary-hover: color-mix(in srgb, var(--primary) 85%, #000);

    color-scheme: light;
}

/* ---------- Tun rejimi ---------- */
html[data-theme="dark"] {
    --bg: #0f151c;
    --surface: #17202a;
    --surface-2: #1c2733;
    --border: #2a3644;
    --border-strong: #3a4859;
    --text: #e6ebf1;
    --text-muted: #9aa7b6;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 8px 22px rgba(0, 0, 0, .5);
    --primary: var(--acc-dk);
    --primary-rgb: var(--acc-dk-rgb, 79, 207, 163);
    --primary-hover: color-mix(in srgb, var(--primary) 85%, #fff);
    color-scheme: dark;
}

/* ---------- Yon panel ranglari (6 ta) ---------- */
html[data-sidebar="emerald"]  { --sb-bg: #0e5a46; }
html[data-sidebar="navy"]     { --sb-bg: #1b3a6b; }
html[data-sidebar="indigo"]   { --sb-bg: #3b3a94; }
html[data-sidebar="graphite"] { --sb-bg: #2b3541; }
html[data-sidebar="burgundy"] { --sb-bg: #761c39; }
html[data-sidebar="light"] {
    --sb-bg: #ffffff;
    --sb-fg: #1b2633;
    --sb-fg-muted: #5b6777;
    --sb-hover: rgba(15, 23, 42, .06);
    --sb-active: rgba(var(--acc-rgb), .12);
    --sb-border: #dbe2ea;
}
html[data-theme="dark"][data-sidebar="light"] {
    --sb-bg: #17202a;
    --sb-fg: #e6ebf1;
    --sb-fg-muted: #9aa7b6;
    --sb-hover: rgba(255, 255, 255, .07);
    --sb-active: rgba(255, 255, 255, .14);
    --sb-border: #2a3644;
}

/* ---------- Yuqori panel ranglari (6 ta); asosiy rang ham shundan olinadi ---------- */
html[data-navbar="emerald"]  { --nav-bg: #0e5a46; --acc: #0e5a46; --acc-rgb: 14, 90, 70;   --acc-dk: #4fcfa3; --acc-dk-rgb: 79, 207, 163; }
html[data-navbar="navy"]     { --nav-bg: #1b3a6b; --acc: #1b4f9c; --acc-rgb: 27, 79, 156;  --acc-dk: #7fb0ff; --acc-dk-rgb: 127, 176, 255; }
html[data-navbar="indigo"]   { --nav-bg: #3b3a94; --acc: #4240b3; --acc-rgb: 66, 64, 179;  --acc-dk: #a3a1ff; --acc-dk-rgb: 163, 161, 255; }
html[data-navbar="graphite"] { --nav-bg: #2b3541; --acc: #3d4b5c; --acc-rgb: 61, 75, 92;   --acc-dk: #9fb3c8; --acc-dk-rgb: 159, 179, 200; }
html[data-navbar="burgundy"] { --nav-bg: #761c39; --acc: #8f1f45; --acc-rgb: 143, 31, 69;  --acc-dk: #ff8fb0; --acc-dk-rgb: 255, 143, 176; }
html[data-navbar="light"] {
    --nav-bg: #ffffff;
    --nav-fg: #1b2633;
    --nav-hover: rgba(15, 23, 42, .06);
    --acc: #1b4f9c; --acc-rgb: 27, 79, 156; --acc-dk: #7fb0ff; --acc-dk-rgb: 127, 176, 255;
}
html[data-theme="dark"][data-navbar="light"] {
    --nav-bg: #17202a;
    --nav-fg: #e6ebf1;
    --nav-hover: rgba(255, 255, 255, .08);
}

/* ---------- Bootstrap bilan moslash ---------- */
:root, [data-bs-theme="light"], [data-bs-theme="dark"] {
    --bs-body-font-family: var(--font-sans);
    --bs-body-font-size: .9375rem;
    --bs-body-bg: var(--bg);
    --bs-body-color: var(--text);
    --bs-border-color: var(--border);
    --bs-secondary-color: var(--text-muted);
    --bs-card-bg: var(--surface);
    --bs-link-color: var(--primary);
    --bs-link-hover-color: var(--primary-hover);
    --bs-border-radius: var(--radius-sm);
}

html { scroll-behavior: smooth; }
body {
    font-family: var(--font-sans);
    font-size: .9375rem;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: var(--font-sans);
    font-weight: 600;
    letter-spacing: 0;
    color: var(--text);
}
h1, .h1 { font-size: 1.75rem; }
h2, .h2 { font-size: 1.5rem; }
h3, .h3 { font-size: 1.25rem; }
h4, .h4 { font-size: 1.125rem; }
h5, .h5 { font-size: 1rem; }
h6, .h6 { font-size: .9375rem; }
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
.text-muted, .text-secondary { color: var(--text-muted) !important; }
.text-primary { color: var(--primary) !important; }
.border-primary { border-color: var(--primary) !important; }
.bg-primary { background-color: var(--primary) !important; color: #fff; }
:focus-visible { outline: 2px solid rgba(var(--primary-rgb), .55); outline-offset: 2px; }

/* Kartochkalar */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    color: var(--text);
}
.card-header, .card-footer { background: var(--surface-2); border-color: var(--border); }
.card-title { font-weight: 600; }

/* Jadvallar */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text);
    --bs-table-border-color: var(--border);
    --bs-table-striped-bg: var(--surface-2);
    --bs-table-striped-color: var(--text);
    --bs-table-hover-bg: rgba(var(--primary-rgb), .06);
    --bs-table-hover-color: var(--text);
    color: var(--text);
    border-color: var(--border);
    vertical-align: middle;
}
.table > thead > tr > th {
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: .8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
    border-bottom: 1px solid var(--border-strong);
}
.table-bordered > :not(caption) > * > * { border-color: var(--border); }

/* Formalar */
.form-control, .form-select, .input-group-text {
    background-color: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
}
.form-control::placeholder { color: var(--text-muted); opacity: .75; }
.form-control:focus, .form-select:focus {
    background-color: var(--surface);
    color: var(--text);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .18);
}
.form-control:disabled, .form-control[readonly], .form-select:disabled { background-color: var(--surface-2); }
.form-label, label { color: var(--text); font-weight: 500; }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.form-check-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .18); }
.input-group-text { background: var(--surface-2); color: var(--text-muted); }

/* Tugmalar */
.btn { border-radius: var(--radius-sm); font-weight: 500; letter-spacing: 0; }
.btn-primary {
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary-hover);
    --bs-btn-hover-border-color: var(--primary-hover);
    --bs-btn-active-bg: var(--primary-hover);
    --bs-btn-active-border-color: var(--primary-hover);
    --bs-btn-disabled-bg: var(--primary);
    --bs-btn-disabled-border-color: var(--primary);
    --bs-btn-color: #fff;
    --bs-btn-hover-color: #fff;
    --bs-btn-active-color: #fff;
    --bs-btn-focus-shadow-rgb: var(--primary-rgb);
}
html[data-theme="dark"] .btn-primary { --bs-btn-color: #0b1218; --bs-btn-hover-color: #0b1218; --bs-btn-active-color: #0b1218; }
.btn-outline-primary {
    --bs-btn-color: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary);
    --bs-btn-hover-border-color: var(--primary);
    --bs-btn-active-bg: var(--primary);
    --bs-btn-active-border-color: var(--primary);
    --bs-btn-hover-color: #fff;
    --bs-btn-active-color: #fff;
    --bs-btn-focus-shadow-rgb: var(--primary-rgb);
}
html[data-theme="dark"] .btn-outline-primary { --bs-btn-hover-color: #0b1218; --bs-btn-active-color: #0b1218; }
.btn-success { --bs-btn-bg: #1e7e4f; --bs-btn-border-color: #1e7e4f; --bs-btn-hover-bg: #186a42; --bs-btn-hover-border-color: #186a42; --bs-btn-active-bg: #186a42; }
.btn-warning { --bs-btn-color: #1b2633; }
.btn-close { filter: none; }
html[data-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

/* Modal, dropdown, offcanvas, accordion, breadcrumb, pagination, alert */
.modal-content, .offcanvas, .dropdown-menu, .popover {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}
.modal-header, .modal-footer, .offcanvas-header { border-color: var(--border); }
.modal-title { font-size: 1.125rem; font-weight: 600; }
.dropdown-menu { border-radius: var(--radius-sm); }
.dropdown-item { color: var(--text); }
.dropdown-item:hover, .dropdown-item:focus { background: rgba(var(--primary-rgb), .08); color: var(--text); }
.accordion {
    --bs-accordion-bg: var(--surface);
    --bs-accordion-color: var(--text);
    --bs-accordion-border-color: var(--border);
    --bs-accordion-btn-color: var(--text);
    --bs-accordion-btn-bg: var(--surface);
    --bs-accordion-active-color: var(--primary);
    --bs-accordion-active-bg: rgba(var(--primary-rgb), .07);
    --bs-accordion-btn-focus-box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .18);
}
html[data-theme="dark"] .accordion-button::after { filter: invert(1) brightness(1.6); }
.breadcrumb { --bs-breadcrumb-divider-color: var(--text-muted); --bs-breadcrumb-item-active-color: var(--text-muted); background: transparent; padding: 0; margin-bottom: 1rem; font-size: .875rem; }
.pagination { --bs-pagination-bg: var(--surface); --bs-pagination-border-color: var(--border); --bs-pagination-color: var(--primary); --bs-pagination-active-bg: var(--primary); --bs-pagination-active-border-color: var(--primary); --bs-pagination-hover-bg: var(--surface-2); --bs-pagination-disabled-bg: var(--surface-2); }
.progress { --bs-progress-bg: rgba(128, 140, 155, .25); --bs-progress-bar-bg: var(--primary); border-radius: 999px; }
.list-group { --bs-list-group-bg: var(--surface); --bs-list-group-color: var(--text); --bs-list-group-border-color: var(--border); }
.nav-tabs { --bs-nav-tabs-link-active-bg: var(--surface); --bs-nav-tabs-link-active-color: var(--primary); --bs-nav-tabs-border-color: var(--border); --bs-nav-tabs-link-active-border-color: var(--border) var(--border) var(--surface); }
hr { border-color: var(--border); opacity: 1; }

/* Skrollbar */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-muted); background-clip: content-box; }

/* ---------- Xabar (toast) ---------- */
.tast {
    position: relative;
    width: 340px;
    max-width: calc(100vw - 32px);
    margin-bottom: 10px;
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    padding: 14px 40px 14px 16px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transform: translateX(calc(100% + 30px));
    transition: transform .35s ease;
    z-index: 10000;
}
.tast.active { transform: translateX(0); }
.tast .toast-content { display: flex; align-items: center; gap: 12px; }
.toast-content .check {
    display: flex; align-items: center; justify-content: center;
    height: 32px; min-width: 32px;
    background: var(--primary); color: #fff;
    font-size: 16px; border-radius: 50%;
}
html[data-theme="dark"] .toast-content .check { color: #0b1218; }
.toast-content .message { display: flex; flex-direction: column; margin: 0; }
.message .text { font-size: .9375rem; font-weight: 400; color: var(--text); }
.message .text.text-1 { font-weight: 600; }
.tast .close {
    position: absolute; top: 8px; right: 10px; left: auto;
    padding: 4px; cursor: pointer; opacity: .6; color: var(--text-muted);
    font-style: normal; font-weight: 600;
}
.tast .close:hover { opacity: 1; }
.tast .progress { position: absolute; bottom: 0; left: 0; height: 3px; width: 100%; border-radius: 0; background: transparent; }
.tast .progress:before { content: ""; position: absolute; bottom: 0; right: 0; height: 100%; width: 100%; background: var(--primary); }
.progress.active:before { animation: tast-progress 5s linear forwards; }
@keyframes tast-progress { 100% { right: 100%; } }
.tast-rows { position: fixed; top: 20px; right: 20px; z-index: 10000; }

/* ---------- Sozlama paneli (o'ngdan ochiladigan) ---------- */
.tp-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px;
    border: 0; border-radius: var(--radius-sm);
    background: transparent; color: inherit;
    cursor: pointer; transition: background .15s;
}
.tp-toggle:hover { background: var(--nav-hover); }
.tp-toggle svg { width: 20px; height: 20px; }
.tp-fab {
    position: fixed; right: 0; top: 42%; z-index: 1040;
    width: 40px; height: 40px;
    border: 1px solid var(--border); border-right: 0;
    border-radius: 10px 0 0 10px;
    background: var(--surface); color: var(--text);
    box-shadow: var(--shadow-md); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.tp-fab svg { width: 20px; height: 20px; }
.tp-overlay {
    position: fixed; inset: 0; z-index: 1999;
    background: rgba(10, 16, 24, .45);
    opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s;
}
.tp-panel {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 2000;
    width: 340px; max-width: 100vw;
    background: var(--surface); color: var(--text);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    transform: translateX(100%); visibility: hidden;
    transition: transform .25s ease, visibility .25s;
    display: flex; flex-direction: column;
    font-family: var(--font-sans);
}
html.tp-open .tp-overlay { opacity: 1; visibility: visible; }
html.tp-open .tp-panel { transform: translateX(0); visibility: visible; }
.tp-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.tp-head h5 { margin: 0; font-size: 1rem; }
.tp-close { border: 0; background: transparent; color: var(--text-muted); font-size: 22px; line-height: 1; width: 32px; height: 32px; border-radius: var(--radius-sm); cursor: pointer; }
.tp-close:hover { background: var(--surface-2); color: var(--text); }
.tp-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.tp-section { margin-bottom: 22px; }
.tp-section h6 { font-size: .8125rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: 10px; }
.tp-preview {
    height: 92px; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg); display: flex; overflow: hidden; margin-bottom: 22px;
}
.tp-preview .pv-side { width: 26%; background: var(--sb-bg); }
.tp-preview .pv-main { flex: 1; display: flex; flex-direction: column; }
.tp-preview .pv-nav { height: 22px; background: var(--nav-bg); border-bottom: 1px solid var(--border); }
.tp-preview .pv-body { flex: 1; padding: 8px; display: flex; gap: 6px; }
.tp-preview .pv-card { flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; }
.tp-seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tp-seg button {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 10px 6px; font-size: .8125rem; font-weight: 500;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm); cursor: pointer;
}
.tp-seg button svg { width: 20px; height: 20px; }
.tp-seg button:hover { background: var(--surface-2); }
.tp-seg button[aria-checked="true"] { border-color: var(--primary); background: rgba(var(--primary-rgb), .10); color: var(--primary); }
.tp-swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.tp-swatches button {
    position: relative; aspect-ratio: 1; border-radius: 50%;
    border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong);
    cursor: pointer; padding: 0;
}
.tp-swatches button[aria-checked="true"] { box-shadow: 0 0 0 2px var(--primary); }
.tp-swatches button[aria-checked="true"]::after {
    content: ""; position: absolute; left: 50%; top: 50%; width: 5px; height: 10px;
    border: solid #fff; border-width: 0 2px 2px 0; transform: translate(-50%, -60%) rotate(45deg);
}
.tp-swatches button[data-color="light"][aria-checked="true"]::after { border-color: #1b2633; }
.tp-swatch-label { font-size: .8125rem; color: var(--text-muted); margin-top: 8px; min-height: 1.2em; }
.tp-reset { width: 100%; padding: 9px 12px; background: transparent; color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-weight: 500; cursor: pointer; }
.tp-reset:hover { background: var(--surface-2); }
.tp-swatches button[data-color="emerald"]  { background: #0e5a46; }
.tp-swatches button[data-color="navy"]     { background: #1b3a6b; }
.tp-swatches button[data-color="indigo"]   { background: #3b3a94; }
.tp-swatches button[data-color="graphite"] { background: #2b3541; }
.tp-swatches button[data-color="burgundy"] { background: #761c39; }
.tp-swatches button[data-color="light"]    { background: #ffffff; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
