/* Dashboard concept preview — isolated from the production public/ directory. */
:root {
    --primary: #f15a24;
    --primary-hover: #d94714;
    --primary-soft: rgba(241, 90, 36, 0.11);
    --accent: #0e9f8b;
    --accent-soft: rgba(14, 159, 139, 0.12);
    --navy: #10213f;
    --navy-soft: #1c3155;
    --bg-color: #f3f6fa;
    --box-bg: #ffffff;
    --text-main: #17233b;
    --text-muted: #6b7890;
    --border: #dfe5ee;
    --table-header: #f4f7fb;
    --row-hover: #f8fafc;
    --success: #159b62;
    --warning: #e59b16;
    --danger: #d94343;
    --info: #2575d0;
    --shadow-sm: 0 2px 10px rgba(16, 33, 63, 0.06);
    --shadow-md: 0 14px 34px rgba(16, 33, 63, 0.10);
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 22px;
}

[data-theme="dark"] {
    --primary: #ff7543;
    --primary-hover: #ff8b64;
    --primary-soft: rgba(255, 117, 67, 0.15);
    --accent: #32c9b1;
    --accent-soft: rgba(50, 201, 177, 0.13);
    --navy: #eef4ff;
    --navy-soft: #cedcf5;
    --bg-color: #0b1220;
    --box-bg: #121c2d;
    --text-main: #edf3fc;
    --text-muted: #9cacbf;
    --border: #29364a;
    --table-header: #182438;
    --row-hover: #18273b;
    --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.22);
    --shadow-md: 0 18px 38px rgba(0, 0, 0, 0.32);
}

html { background: var(--bg-color); }

body.ui-preview {
    min-height: 100vh;
    padding: 48px 24px 28px;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 9% 4%, rgba(241, 90, 36, 0.10), transparent 24rem),
        radial-gradient(circle at 92% 1%, rgba(14, 159, 139, 0.09), transparent 26rem),
        var(--bg-color);
    font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
    line-height: 1.45;
}

.ui-preview button,
.ui-preview input,
.ui-preview select,
.ui-preview textarea { font: inherit; }

.preview-environment {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 100000;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 18px;
    color: #fff;
    background: linear-gradient(90deg, #10213f, #18345e 56%, #0e766c);
    box-shadow: 0 2px 10px rgba(16, 33, 63, 0.24);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.preview-environment small {
    padding-left: 9px;
    border-left: 1px solid rgba(255, 255, 255, 0.32);
    color: rgba(255, 255, 255, 0.74);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
}

.ui-preview .container {
    width: min(1720px, 100%);
    max-width: 1720px;
    margin: 0 auto;
    padding: 0;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
}

/* Brand header */
.ui-preview .header,
.ui-preview .admin-shell-header {
    min-height: 108px;
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto;
    column-gap: 16px;
    align-items: center;
    margin: 0 0 20px;
    padding: 22px 24px;
    text-align: left;
    background: linear-gradient(110deg, #10213f 0%, #18335c 68%, #165b63 118%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    color: #fff;
    overflow: hidden;
    position: relative;
}

.ui-preview .header::after,
.ui-preview .admin-shell-header::after {
    content: "";
    position: absolute;
    width: 290px;
    height: 290px;
    right: 6%;
    top: -220px;
    border: 50px solid rgba(255, 255, 255, 0.045);
    border-radius: 50%;
    pointer-events: none;
}

.brand-mark {
    grid-column: 1;
    grid-row: 1 / 4;
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    color: #fff;
    background: linear-gradient(145deg, #ff7a3d, #ed4c19);
    box-shadow: 0 10px 24px rgba(241, 90, 36, 0.32);
    font-size: 21px;
}

.ui-preview .header-copy { grid-column: 2; grid-row: 1; }
.eyebrow {
    display: block;
    margin-bottom: 2px;
    color: #72dfd0;
    font-size: 10px;
    line-height: 1.2;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.ui-preview .header h2 {
    grid-column: 2;
    grid-row: 2;
    margin: 1px 0 2px;
    color: #fff;
    font-size: clamp(20px, 2vw, 28px);
    line-height: 1.2;
    letter-spacing: -0.02em;
    text-transform: none;
}

.ui-preview .header h2 i { color: #ff8456; }
.ui-preview .header > p {
    grid-column: 2;
    grid-row: 3;
    margin: 0;
    color: rgba(255, 255, 255, 0.68);
    font-size: 12px;
}

.ui-preview .theme-toggle {
    grid-column: 3;
    grid-row: 1 / 4;
    position: static;
    width: 42px;
    height: 42px;
    padding: 0;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 13px;
    color: #fff;
    background: rgba(255, 255, 255, 0.09);
    font-size: 16px;
    backdrop-filter: blur(8px);
}

.ui-preview .theme-toggle:hover { background: rgba(255, 255, 255, 0.17); }

.admin-shell-header { grid-template-rows: auto auto auto; }
.admin-shell-header > div:last-child { grid-column: 2; grid-row: 1 / 4; }
.admin-shell-header h1 { margin: 2px 0 1px; color: #fff; font-size: 26px; line-height: 1.25; }
.admin-shell-header p { margin: 0; color: rgba(255, 255, 255, 0.68); font-size: 12px; }

/* Authentication */
.ui-preview .login-box {
    position: relative;
    max-width: 460px;
    margin: 72px auto 110px;
    padding: 74px 42px 42px;
    background: var(--box-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: visible;
}

.login-brand {
    position: absolute;
    width: 70px;
    height: 70px;
    left: calc(50% - 35px);
    top: -35px;
    display: grid;
    place-items: center;
    border: 7px solid var(--bg-color);
    border-radius: 22px;
    color: #fff;
    background: linear-gradient(145deg, #ff7a3d, #e94612);
    box-shadow: 0 12px 22px rgba(241, 90, 36, 0.28);
    font-size: 22px;
}

.ui-preview .login-box h3 { margin-bottom: 6px !important; color: var(--navy); font-size: 19px; }
.ui-preview .login-box input:not([type="checkbox"]) {
    width: min(100%, 320px);
    height: 46px;
    padding: 0 14px;
    background: var(--bg-color);
    border-color: var(--border);
    border-radius: var(--radius-sm);
}
.ui-preview .login-box input:not([type="checkbox"]):focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
}
.ui-preview .login-box label { width: min(100%, 320px) !important; }
.ui-preview .login-box .btn { width: min(100%, 320px) !important; min-height: 46px; }

/* Buttons and fields */
.ui-preview .btn {
    min-height: 38px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-weight: 700;
    box-shadow: none;
}
.ui-preview .btn:hover { transform: translateY(-1px); }
.ui-preview .btn-primary { background: linear-gradient(135deg, #f36b35, #e94b18); }
.ui-preview .btn-primary:hover { box-shadow: 0 8px 18px rgba(241, 90, 36, 0.23); }
.ui-preview .btn-secondary { color: var(--text-main); background: var(--table-header); border-color: var(--border); }
.ui-preview .btn-secondary:hover { background: var(--row-hover); border-color: #b8c4d3; }
.ui-preview .btn-success { background: #159b62; }
.ui-preview .btn-danger { background: #d94343; }
.ui-preview .btn-warning { background: #f2ae2e; }
.ui-preview .btn-sm { min-height: 32px; padding: 6px 11px; border-radius: 8px; }
.ui-preview .btn-voice { background: #6e53c9; border-color: #6e53c9; }

.ui-preview input:not([type="checkbox"]):not([type="radio"]),
.ui-preview select,
.ui-preview textarea {
    border-radius: 9px !important;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.ui-preview input:not([type="checkbox"]):not([type="radio"]):focus,
.ui-preview select:focus,
.ui-preview textarea:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 4px var(--primary-soft) !important;
}

/* Report controls */
.ui-preview .toolbar {
    margin-bottom: 18px;
    padding: 0;
    background: var(--box-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.ui-preview .toolbar-top {
    min-height: 68px;
    margin: 0;
    padding: 12px 18px;
    background: linear-gradient(180deg, var(--box-bg), var(--table-header));
    border-bottom: 1px solid var(--border);
}
.ui-preview .report-tabs { gap: 6px !important; }
.ui-preview .r-tab-btn {
    min-height: 40px;
    margin: 0;
    padding: 9px 15px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: 13px;
}
.ui-preview .r-tab-btn:hover { color: var(--primary); background: var(--primary-soft); }
.ui-preview .r-tab-btn.active {
    color: #fff;
    background: var(--navy);
    border-color: var(--navy);
    box-shadow: 0 7px 16px rgba(16, 33, 63, 0.16);
}
[data-theme="dark"] .ui-preview .r-tab-btn.active { color: #0b1220; }

.ui-preview .toolbar > .flex-between {
    margin: 0 !important;
    padding: 13px 18px !important;
    background: var(--box-bg);
    border-bottom: 1px solid var(--border) !important;
}
.ui-preview .btn-quick {
    padding: 7px 12px;
    border-radius: 20px;
    color: var(--text-muted);
    background: var(--table-header);
    border-color: var(--border);
    font-size: 11px;
}
.ui-preview .btn-quick:hover { color: var(--primary); background: var(--primary-soft); border-color: rgba(241, 90, 36, 0.30); }
.ui-preview .filter-grid { gap: 12px; padding: 16px 18px 18px; }
.ui-preview .filter-item { min-width: 150px; }
.ui-preview .filter-item label {
    margin-bottom: 6px;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.ui-preview .filter-item select,
.ui-preview .filter-item input {
    min-height: 40px;
    padding: 8px 11px;
    background: var(--bg-color);
    border-color: var(--border);
}

/* KPI layer */
.ui-preview .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.ui-preview .kpi-card {
    position: relative;
    min-height: 136px;
    padding: 22px 22px 18px 78px;
    text-align: left;
    background: var(--box-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.ui-preview .kpi-card::before {
    position: absolute;
    left: 20px;
    top: 24px;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    color: var(--primary);
    background: var(--primary-soft);
    font-family: "Font Awesome 6 Free";
    font-size: 16px;
    font-weight: 900;
}
.ui-preview .kpi-card:nth-child(1)::before { content: "\f03d"; }
.ui-preview .kpi-card:nth-child(2)::before { content: "\f06e"; color: var(--info); background: rgba(37, 117, 208, 0.11); }
.ui-preview .kpi-card:nth-child(3)::before { content: "\f017"; color: var(--accent); background: var(--accent-soft); }
.ui-preview .kpi-card:nth-child(4)::before { content: "\f201"; color: #7c5dc7; background: rgba(124, 93, 199, 0.12); }
.ui-preview .kpi-title { margin: 0 0 6px; color: var(--text-muted); font-size: 10px; letter-spacing: 0.07em; }
.ui-preview .kpi-value { margin: 0 0 8px; color: var(--navy); font-size: 29px; line-height: 1.1; }
.ui-preview .kpi-trend { padding: 4px 8px; font-size: 10px; }
.ui-preview .kpi-card::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), transparent 70%);
}

/* Charts, cards and tables */
.ui-preview .dashboard-grid { gap: 16px; }
.ui-preview .chart-container,
.ui-preview .card {
    background: var(--box-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}
.ui-preview .chart-container { height: 450px; padding: 24px 18px 16px; }
.ui-preview .card { padding: 22px; }
.ui-preview .card-title {
    color: var(--navy);
    border-bottom: 1px solid var(--border);
    font-size: 15px;
}
.ui-preview .text-primary-bold { color: var(--primary); }
.ui-preview .table-wrapper,
.ui-preview .table-scroll {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--box-bg);
    box-shadow: none;
}
.ui-preview .table-wrapper { max-height: 64vh; margin-top: 2px; box-shadow: var(--shadow-sm); }
.ui-preview table { font-size: 12px; }
.ui-preview th,
.ui-preview td { padding: 13px 12px; border-bottom-color: var(--border); }
.ui-preview th,
.ui-preview .table-scroll th {
    color: var(--text-muted);
    background: var(--table-header);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.035em;
    text-transform: uppercase;
    box-shadow: inset 0 -1px var(--border);
}
.ui-preview tbody tr { transition: background 0.15s ease; }
.ui-preview tbody tr:hover { background: var(--row-hover); }
.ui-preview .avatar-sm,
.ui-preview .avatar-placeholder { width: 40px; height: 40px; border-radius: 12px; }
.ui-preview .badge,
.ui-preview .badge-role { padding: 4px 7px; border-radius: 7px; }
.ui-preview #paginationControls,
.ui-preview #conflictPagination { backdrop-filter: blur(10px); }

/* Admin workspace */
.admin-page #appArea[style*="block"] {
    display: grid !important;
    grid-template-columns: 250px minmax(0, 1fr);
    grid-auto-flow: row;
    gap: 0 20px;
    align-items: start;
}
.admin-page #appArea > .flex-between:first-child {
    grid-column: 1 / -1;
    min-height: 58px;
    margin: 0 0 16px !important;
    padding: 9px 14px;
    background: var(--box-bg);
    border: 1px solid var(--border);
    border-radius: 13px;
    box-shadow: var(--shadow-sm);
}
.admin-page .admin-tabs {
    grid-column: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: sticky;
    top: 50px;
    margin: 0;
    padding: 12px;
    background: #10213f;
    border: 0;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    overflow: visible;
}
.admin-page .tab-btn {
    width: 100%;
    min-height: 45px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    text-align: left;
    color: rgba(255, 255, 255, 0.69);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: 12px;
}
.admin-page .tab-btn i { width: 18px; text-align: center; }
.admin-page .tab-btn:hover { color: #fff; background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.08); }
.admin-page .tab-btn.active {
    color: #fff;
    background: linear-gradient(135deg, #f36b35, #e94b18);
    border-color: transparent;
    box-shadow: 0 8px 18px rgba(241, 90, 36, 0.22);
}
.admin-page .tab-content { grid-column: 2; min-width: 0; }
.admin-page .tab-content > .card:first-child,
.admin-page .tab-content > .flex-row:first-child { margin-top: 0; }
.admin-page .form-card { top: 50px; max-height: calc(100vh - 72px); }
.admin-page .flex-row { gap: 16px; }
.admin-page .role-checkbox-container {
    padding: 12px;
    background: var(--bg-color);
    border-radius: 11px;
}
.admin-page .role-checkbox-item { padding: 7px; border-radius: 8px; }
.admin-page .role-checkbox-item:hover { background: var(--box-bg); }
.admin-page .scroll-checkbox-list { background: var(--bg-color); border-radius: 10px; }
.admin-page .upload-box { background: rgba(37, 117, 208, 0.06); border-color: rgba(37, 117, 208, 0.38); border-radius: 12px; }
.admin-page .toggle-group { border-radius: 10px; }
.admin-page .toggle-btn { padding: 9px 13px; }
.admin-page .toggle-btn.active { background: var(--navy); }
.admin-page #adminNavButtons .theme-toggle {
    grid-column: auto;
    grid-row: auto;
    color: var(--text-main);
    background: var(--table-header);
    border-color: var(--border);
}
[data-theme="dark"] .admin-page .toggle-btn.active { color: #fff; background: #10213f; }
.admin-page .search-bar { min-height: 40px; background: var(--bg-color); border-radius: 10px; }

/* Modal and feedback polish */
.ui-preview .modal-overlay {
    padding: 24px;
    background: rgba(6, 14, 29, 0.66);
    backdrop-filter: blur(5px);
}
.ui-preview .modal-content {
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 28px 80px rgba(4, 13, 28, 0.34);
}
.ui-preview .modal-header { min-height: 62px; padding: 15px 20px; background: var(--box-bg); }
.ui-preview .modal-header h3 { color: var(--navy); }
.ui-preview .close-btn {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: var(--table-header);
    font-size: 16px;
}
.ui-preview .voice-panel { border-radius: 12px; }
.ui-preview .voice-panel-title { padding: 12px 14px; }
.ui-preview .voice-transcript { line-height: 1.72; }
.ui-preview .toast { border: 1px solid var(--border); border-left: 4px solid var(--success); border-radius: 12px; box-shadow: var(--shadow-md); }
.ui-preview .loader-overlay { background: rgba(6, 14, 29, 0.76); backdrop-filter: blur(7px); }
.ui-preview .spinner { border-width: 4px; border-top-color: #ff7543; }

/* Scrollbars */
.ui-preview * { scrollbar-color: #aeb9c8 transparent; scrollbar-width: thin; }
.ui-preview *::-webkit-scrollbar { width: 8px; height: 8px; }
.ui-preview *::-webkit-scrollbar-track { background: transparent; }
.ui-preview *::-webkit-scrollbar-thumb { background: #b9c3d0; border: 2px solid transparent; border-radius: 999px; background-clip: padding-box; }

@media (max-width: 1180px) {
    .admin-page #appArea[style*="block"] { grid-template-columns: 210px minmax(0, 1fr); }
    .admin-page .tab-btn { font-size: 11px; }
    .admin-page .form-card { position: static; max-height: none; overflow: visible; }
}

@media (max-width: 960px) {
    body.ui-preview { padding-inline: 14px; }
    .ui-preview .toolbar-top { align-items: flex-start; flex-direction: column; }
    .ui-preview #userActionMenu { width: 100%; justify-content: space-between; }
    .ui-preview .dashboard-grid { grid-template-columns: 1fr; }
    .ui-preview .chart-container { height: 390px; }
    .admin-page #appArea[style*="block"] { display: block !important; }
    .admin-page .admin-tabs {
        position: static;
        flex-direction: row;
        margin-bottom: 16px;
        overflow-x: auto;
        border-radius: 13px;
    }
    .admin-page .tab-btn { width: auto; flex: 0 0 auto; }
    .admin-page .tab-content { width: 100%; }
}

@media (max-width: 640px) {
    body.ui-preview { padding: 44px 9px 18px; }
    .preview-environment { justify-content: flex-start; padding-left: 13px; }
    .preview-environment small { display: none; }
    .ui-preview .header,
    .ui-preview .admin-shell-header { min-height: 96px; padding: 17px; border-radius: 16px; grid-template-columns: 45px minmax(0, 1fr) auto; column-gap: 11px; }
    .brand-mark { width: 44px; height: 44px; border-radius: 13px; font-size: 17px; }
    .ui-preview .header > p,
    .admin-shell-header p { display: none; }
    .ui-preview .header h2,
    .admin-shell-header h1 { font-size: 19px; }
    .ui-preview .theme-toggle { width: 36px; height: 36px; }
    .ui-preview .login-box { margin: 58px 0 80px; padding: 62px 20px 30px; }
    .ui-preview .report-tabs { width: 100%; overflow-x: auto; padding-bottom: 3px !important; }
    .ui-preview .r-tab-btn { flex: 0 0 auto; padding-inline: 12px; }
    .ui-preview .filter-grid { display: grid; grid-template-columns: 1fr 1fr; }
    .ui-preview .filter-item { min-width: 0 !important; width: auto; }
    .ui-preview .filter-item[style*="min-width: 380px"] { grid-column: 1 / -1; }
    .ui-preview .kpi-grid { grid-template-columns: 1fr; }
    .ui-preview .kpi-card { min-height: 112px; }
    .ui-preview .chart-container { height: 340px; padding-inline: 9px; }
    .ui-preview .card { padding: 15px; }
    .ui-preview .modal-overlay { padding: 8px; }
    .ui-preview .modal-content { max-height: 92vh; border-radius: 14px; }
    .admin-page .flex-row { display: block; }
    .admin-page .flex-row > .card { min-width: 0 !important; max-width: none !important; width: 100%; }
}

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