/* ============================================================
   BLUERED CRM — Shared CSS
   Dark theme, sidebar layout
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
a { text-decoration: none; color: inherit; }
button { font-family: inherit; }
img { max-width: 100%; }

/* ── CSS VARIABLES ── */
:root {
    --sidebar-w:     260px;
    --sidebar-coll:  64px;
    --header-h:      60px;

    /* Palette */
    --navy:    #0D1424;
    --navy2:   #16202F;
    --navy3:   #1D2B3A;
    --navy4:   #243040;
    --sidebar: #111C2D;

    --cyan:    #00D9FF;
    --cyan2:   #00B8D9;
    --blue:    #3B82F6;
    --blue2:   #2563EB;
    --purple:  #7C3AED;
    --green:   #10B981;
    --red:     #EF4444;
    --yellow:  #F59E0B;
    --orange:  #F97316;
    --pink:    #EC4899;

    /* Text */
    --text:        rgba(255,255,255,.92);
    --text-muted:  rgba(255,255,255,.50);
    --text-dim:    rgba(255,255,255,.28);

    /* Borders & Glass */
    --border:      rgba(255,255,255,.08);
    --border-med:  rgba(255,255,255,.13);
    --glass:       rgba(255,255,255,.04);
    --glass2:      rgba(255,255,255,.07);

    /* Shadows */
    --shadow-sm:  0 2px 8px rgba(0,0,0,.35);
    --shadow:     0 4px 20px rgba(0,0,0,.45);
    --shadow-lg:  0 8px 40px rgba(0,0,0,.55);

    /* Radius — NiceAdmin style (slightly rounded) */
    --r-sm: 4px;
    --r:    7px;
    --r-lg: 10px;
    --r-xl: 12px;

    /* Transition */
    --ease: .18s ease;
}

/* ── BASE ── */
html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--navy);
    color: var(--text);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
    overflow-x: hidden;
}

/* ── LAYOUT ── */
.layout {
    display: flex;
    min-height: 100vh;
}

/* ── SIDEBAR ── */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: width var(--ease), transform var(--ease);
    overflow: hidden;
}

.sidebar.collapsed {
    width: var(--sidebar-coll);
}

.sidebar-logo {
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 18px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--blue), var(--cyan));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
    font-weight: 800;
    color: #fff;
    letter-spacing: -.5px;
}

/* SVG logo bez pozadí */
.sidebar-logo-svg {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 30px;
    height: 30px;
}

.sidebar-logo-text {
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
    opacity: 1;
    transition: opacity var(--ease);
}

.sidebar.collapsed .sidebar-logo-text { opacity: 0; width: 0; }

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-section-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .08em;
    color: var(--text-dim);
    text-transform: uppercase;
    padding: 8px 10px 4px;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--ease);
}
.sidebar.collapsed .nav-section-label { opacity: 0; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 10px;
    border-radius: var(--r-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: background var(--ease), color var(--ease);
    white-space: nowrap;
    position: relative;
    margin-bottom: 2px;
    text-decoration: none;
}

.nav-item:hover {
    background: var(--glass2);
    color: var(--text);
}

.nav-item.active {
    background: rgba(59,130,246,.18);
    color: var(--blue);
    font-weight: 500;
}

.nav-item.active .nav-icon { color: var(--blue); }

.nav-icon {
    flex-shrink: 0;
    width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-label {
    opacity: 1;
    transition: opacity var(--ease);
    font-size: 13.5px;
}
.sidebar.collapsed .nav-label { opacity: 0; width: 0; overflow: hidden; }

/* Tooltip for collapsed mode */
.sidebar.collapsed .nav-item::after {
    content: attr(data-label);
    position: absolute;
    left: calc(var(--sidebar-coll) + 8px);
    background: var(--navy3);
    border: 1px solid var(--border-med);
    color: var(--text);
    padding: 5px 10px;
    border-radius: var(--r-sm);
    font-size: 12.5px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .12s;
    z-index: 999;
    box-shadow: var(--shadow);
}
.sidebar.collapsed .nav-item:hover::after { opacity: 1; }

.sidebar-footer {
    padding: 12px 8px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* ── TOGGLE ── */
.sidebar-toggle {
    all: unset;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    color: var(--text-muted);
    transition: background var(--ease), color var(--ease);
    margin-left: auto;
    flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--glass2); color: var(--text); }

/* Topbar sidebar toggle — always visible */
.topbar-toggle {
    all: unset;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--r-sm);
    color: var(--text-muted);
    transition: background var(--ease), color var(--ease);
    flex-shrink: 0;
}
.topbar-toggle:hover { background: var(--glass2); color: var(--text); }

/* ── MAIN AREA ── */
.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--ease);
}

.sidebar.collapsed ~ .main,
body.sidebar-collapsed .main {
    margin-left: var(--sidebar-coll);
}

/* ── TOPBAR ── */
.topbar {
    position: sticky;
    top: 0;
    height: var(--header-h);
    background: rgba(13,20,36,.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px;
    z-index: 100;
    flex-shrink: 0;
}

.topbar-title {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
}

.topbar-spacer { flex: 1; }

/* Search */
.topbar-search {
    position: relative;
    max-width: 300px;
    width: 100%;
}

/* Vnitřní flex obal — ikona + input vedle sebe */
.topbar-search-inner {
    display: flex;
    align-items: center;
    gap: 7px;
    height: 36px;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0 14px;
    transition: border-color var(--ease), background var(--ease);
}
.topbar-search-inner:focus-within {
    border-color: rgba(59,130,246,.5);
    background: var(--glass2);
}

.topbar-search .search-icon {
    color: var(--text-dim);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    pointer-events: none;
}

.topbar-search input,
.topbar-search .search-input {
    border: none;
    background: transparent;
    outline: none;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    flex: 1;
    min-width: 0;
    padding: 0;
    height: 100%;
}
.topbar-search input::placeholder { color: var(--text-dim); }

/* Search dropdown */
.search-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--navy3);
    border: 1px solid var(--border-med);
    border-radius: var(--r);
    box-shadow: var(--shadow-lg);
    z-index: 999;
    display: none;
    overflow: hidden;
}
.search-dropdown.open { display: block; }

.search-result {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    cursor: pointer;
    transition: background var(--ease);
}
.search-result:hover { background: var(--glass2); }
.search-result-type {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    background: var(--glass);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--text-muted);
}
.search-result-main { flex: 1; min-width: 0; }
.search-result-label { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result-sub { font-size: 11px; color: var(--text-muted); }
.search-no-results { padding: 14px; text-align: center; color: var(--text-muted); font-size: 13px; }

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ── PAGE CONTENT ── */
.page-content {
    flex: 1;
    padding: 28px 28px 40px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── CARD ── */
.card {
    background: var(--navy2);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 7px;
}

/* ── STAT CARDS ── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--navy2);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
}

.stat-card.cyan::before  { background: var(--cyan); }
.stat-card.blue::before  { background: var(--blue); }
.stat-card.green::before { background: var(--green); }
.stat-card.red::before   { background: var(--red); }
.stat-card.yellow::before{ background: var(--yellow); }

.stat-label {
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -.02em;
}

.stat-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ── BUTTONS ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--r-sm);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: transform .12s, box-shadow .12s, background .12s, opacity .12s;
    white-space: nowrap;
    text-decoration: none;
    user-select: none;
}
.btn:hover   { transform: translateY(-1px); }
.btn:active  { transform: translateY(0); }
.btn:disabled { opacity: .5; pointer-events: none; }

.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 14px; }
.btn-icon { padding: 7px; }

.btn-primary {
    background: linear-gradient(135deg, var(--blue), var(--blue2));
    color: #fff;
    box-shadow: 0 3px 12px rgba(59,130,246,.35);
}
.btn-primary:hover { box-shadow: 0 5px 18px rgba(59,130,246,.5); }

.btn-success {
    background: linear-gradient(135deg, var(--green), #059669);
    color: #fff;
    box-shadow: 0 3px 12px rgba(16,185,129,.3);
}
.btn-success:hover { box-shadow: 0 5px 18px rgba(16,185,129,.45); }

.btn-danger {
    background: linear-gradient(135deg, var(--red), #DC2626);
    color: #fff;
    box-shadow: 0 3px 12px rgba(239,68,68,.3);
}
.btn-danger:hover { box-shadow: 0 5px 18px rgba(239,68,68,.45); }

.btn-warning {
    background: linear-gradient(135deg, var(--yellow), #D97706);
    color: #fff;
    box-shadow: 0 3px 12px rgba(245,158,11,.3);
}

.btn-cyan {
    background: linear-gradient(135deg, var(--cyan), var(--cyan2));
    color: var(--navy);
    box-shadow: 0 3px 12px rgba(0,217,255,.3);
    font-weight: 600;
}
.btn-cyan:hover { box-shadow: 0 5px 18px rgba(0,217,255,.45); }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--glass2); color: var(--text); border-color: var(--border-med); }

.btn-secondary {
    background: var(--glass);
    color: var(--text);
    border: 1px solid var(--border);
    backdrop-filter: blur(8px);
}
.btn-secondary:hover { background: var(--glass2); border-color: var(--border-med); }

/* ── BADGES ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .02em;
}

.badge-issued  { background: rgba(59,130,246,.18);   color: #60a5fa; }
.badge-paid    { background: rgba(16,185,129,.18);   color: #34d399; }
.badge-overdue { background: rgba(239,68,68,.18);    color: #f87171; }
.badge-pending { background: rgba(245,158,11,.15);   color: #fbbf24; }
.badge-sent    { background: rgba(16,185,129,.15);   color: #34d399; }
.badge-excluded{ background: rgba(255,255,255,.07);  color: var(--text-muted); }
.badge-active  { background: rgba(59,130,246,.18);   color: #60a5fa; }
.badge-done    { background: rgba(16,185,129,.18);   color: #34d399; }
.badge-paused  { background: rgba(245,158,11,.15);   color: #fbbf24; }
.badge-changed { background: rgba(124,58,237,.2);    color: #a78bfa; }

/* ── FORMS ── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.form-label {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
}

.form-control,
input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
input[type="date"],
input[type="url"],
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    background: var(--navy3);
    border: 1px solid var(--border-med);
    border-radius: var(--r-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 13.5px;
    transition: border-color var(--ease), background var(--ease);
    outline: none;
    -webkit-appearance: none;
}
.form-control:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
input[type="url"]:focus,
select:focus,
textarea:focus {
    border-color: var(--blue);
    background: var(--navy4);
}
.form-control::placeholder,
input::placeholder,
textarea::placeholder { color: var(--text-dim); }

select { cursor: pointer; }
select option { background: var(--navy3); }

textarea { resize: vertical; min-height: 80px; }

.form-hint {
    font-size: 11.5px;
    color: var(--text-dim);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.input-with-btn {
    display: flex;
    gap: 8px;
}
.input-with-btn input { flex: 1; }

/* ── TABLE ── */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--r-lg);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--navy3);
}

th {
    padding: 11px 14px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    text-align: left;
    white-space: nowrap;
}

td {
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    font-size: 13.5px;
    vertical-align: middle;
}

tbody tr:hover { background: var(--glass); }

.td-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: flex-end;
}

/* ── ALERTS ── */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--r);
    margin-bottom: 16px;
    font-size: 13.5px;
    font-weight: 500;
}
.alert-success { background: rgba(16,185,129,.15);  border: 1px solid rgba(16,185,129,.3);  color: #34d399; }
.alert-error   { background: rgba(239,68,68,.15);   border: 1px solid rgba(239,68,68,.3);   color: #f87171; }
.alert-info    { background: rgba(59,130,246,.15);  border: 1px solid rgba(59,130,246,.3);  color: #60a5fa; }
.alert-warning { background: rgba(245,158,11,.12);  border: 1px solid rgba(245,158,11,.3);  color: #fbbf24; }

/* ── MODAL ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.65);
    backdrop-filter: blur(4px);
    z-index: 500;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal {
    background: var(--navy2);
    border: 1px solid var(--border-med);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: modalIn .18s ease;
}

.modal-lg { max-width: 860px; }
.modal-xl { max-width: 1100px; }

@keyframes modalIn {
    from { opacity: 0; transform: translateY(12px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-header h2 {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close {
    all: unset;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: background var(--ease), color var(--ease);
}
.modal-close:hover { background: var(--glass2); color: var(--text); }

.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 24px 20px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* ── PAGINATION ── */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: center;
    margin-top: 20px;
}

.page-btn {
    all: unset;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-sm);
    font-size: 13px;
    color: var(--text-muted);
    transition: background var(--ease), color var(--ease);
}
.page-btn:hover { background: var(--glass2); color: var(--text); }
.page-btn.active { background: var(--blue); color: #fff; font-weight: 600; }
.page-btn:disabled { opacity: .35; pointer-events: none; }

.page-info {
    font-size: 12.5px;
    color: var(--text-muted);
    padding: 0 8px;
}

/* ── EMPTY STATE ── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state-icon {
    display: inline-flex;
    padding: 20px;
    border-radius: 50%;
    background: var(--glass);
    margin-bottom: 16px;
}
.empty-state h3 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.empty-state p  { font-size: 13.5px; max-width: 320px; margin: 0 auto 20px; }

/* ── TOAST ── */
.toast-container {
    position: fixed;
    top: calc(var(--header-h) + 12px);
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10000;
    pointer-events: none;
}
.toast-container .toast {
    pointer-events: auto;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: var(--navy3);
    border: 1px solid var(--border-med);
    border-radius: var(--r);
    box-shadow: var(--shadow-lg);
    font-size: 13.5px;
    font-weight: 500;
    animation: toastIn .2s ease;
    max-width: 320px;
}
.toast.success { border-color: rgba(16,185,129,.4); color: #34d399; }
.toast.error   { border-color: rgba(239,68,68,.4);  color: #f87171; }
.toast.info    { border-color: rgba(59,130,246,.4); color: #60a5fa; }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── TABS ── */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.tab-btn {
    all: unset;
    cursor: pointer;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color var(--ease), border-color var(--ease);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── DRAG HANDLE (tasks) ── */
.drag-handle {
    cursor: grab;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    padding: 0 4px;
}
.drag-handle:active { cursor: grabbing; }

/* Sortable ghost */
.sortable-ghost { opacity: .3; }
.sortable-drag   { background: var(--navy4) !important; box-shadow: var(--shadow-lg); }

/* ── COLOR LABELS ── */
.color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── DIVIDER ── */
.divider {
    height: 1px;
    background: var(--border);
    margin: 16px 0;
}

/* ── SPINNER ── */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-med);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-w) !important;
    }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .main { margin-left: 0 !important; }
    .topbar { padding: 0 16px; }
    .page-content { padding: 20px 16px 30px; }
}

@media (max-width: 600px) {
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .form-row  { grid-template-columns: 1fr; }
    .topbar-search { display: none; }
    .page-header { flex-direction: column; align-items: flex-start; }
}

/* ── WYSIWYG EDITOR ── */
.editor-wrap {
    border: 1px solid var(--border-med);
    border-radius: var(--r);
    overflow: hidden;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 6px 10px;
    background: var(--navy3);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.editor-btn {
    all: unset;
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    color: var(--text-muted);
    transition: background var(--ease), color var(--ease);
    font-size: 12px;
    font-weight: 700;
}
.editor-btn:hover, .editor-btn.active { background: var(--glass2); color: var(--text); }
.editor-btn:disabled { opacity: .35; pointer-events: none; }

.editor-sep {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 4px;
}

.editor-content {
    min-height: 120px;
    padding: 12px 14px;
    background: var(--navy3);
    color: var(--text);
    outline: none;
    font-size: 13.5px;
    line-height: 1.6;
}
.editor-content:focus { background: var(--navy4); }
.editor-content h1,h2,h3,h4 { margin: 8px 0 4px; }
.editor-content p { margin: 4px 0; }
.editor-content a { color: var(--blue); }
.editor-content ul, .editor-content ol { padding-left: 20px; }
.editor-content table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.editor-content table td, .editor-content table th { border: 1px solid var(--border-med); padding: 5px 9px; }

/* ── MISC UTILITIES ── */
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-4        { gap: 4px; }
.gap-8        { gap: 8px; }
.gap-12       { gap: 12px; }
.gap-16       { gap: 16px; }
.mt-4         { margin-top: 4px; }
.mt-8         { margin-top: 8px; }
.mt-12        { margin-top: 12px; }
.mt-16        { margin-top: 16px; }
.mt-24        { margin-top: 24px; }
.mb-16        { margin-bottom: 16px; }
.mb-24        { margin-bottom: 24px; }
.text-muted   { color: var(--text-muted); }
.text-sm      { font-size: 12px; }
.text-xs      { font-size: 11px; }
.fw-600       { font-weight: 600; }
.truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden       { display: none !important; }

/* ── CHECKBOX / TASK ── */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.checkbox-label input[type="checkbox"] { display: none; }
.checkbox-custom {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-med);
    border-radius: 4px;
    transition: background var(--ease), border-color var(--ease);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.checkbox-label input:checked + .checkbox-custom {
    background: var(--green);
    border-color: var(--green);
}
.checkbox-label input:checked + .checkbox-custom::after {
    content: '';
    width: 5px;
    height: 8px;
    border: 2px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg) translateY(-1px);
}

/* ── FILE UPLOAD ZONE ── */
.upload-zone {
    border: 2px dashed var(--border-med);
    border-radius: var(--r-lg);
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--ease), background var(--ease);
}
.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--blue);
    background: rgba(59,130,246,.05);
}
.upload-zone-icon { color: var(--text-dim); margin-bottom: 10px; }
.upload-zone-text { font-size: 13.5px; color: var(--text-muted); }
.upload-zone-hint { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

/* Progress bar */
.progress-bar-wrap {
    background: var(--navy3);
    border-radius: 20px;
    height: 6px;
    overflow: hidden;
    margin: 8px 0;
}
.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--blue), var(--cyan));
    border-radius: 20px;
    transition: width .2s;
}

/* ── LIGHT THEME ── */
html.theme-light {
    --navy:       #F0F2F5;
    --navy2:      #FFFFFF;
    --navy3:      #F5F7FA;
    --navy4:      #EBEEf3;
    --sidebar:    #FFFFFF;

    --text:        rgba(15,23,42,.90);
    --text-muted:  rgba(15,23,42,.52);
    --text-dim:    rgba(15,23,42,.28);

    --border:      rgba(15,23,42,.10);
    --border-med:  rgba(15,23,42,.15);
    --glass:       rgba(15,23,42,.04);
    --glass2:      rgba(15,23,42,.07);

    --shadow-sm:  0 2px 8px rgba(0,0,0,.08);
    --shadow:     0 4px 20px rgba(0,0,0,.10);
    --shadow-lg:  0 8px 40px rgba(0,0,0,.14);
}
html.theme-light body { background: var(--navy); color: var(--text); }
html.theme-light .topbar { background: rgba(255,255,255,.92); border-bottom: 1px solid rgba(15,23,42,.08); }
html.theme-light .topbar-search input { background: var(--glass); color: var(--text); }
html.theme-light .search-dropdown { background: #fff; }
html.theme-light .modal { background: #fff; }
html.theme-light .card { background: #fff; }
html.theme-light .stat-card { background: #fff; }
html.theme-light select option { background: #fff; color: var(--text); }
html.theme-light .sidebar { border-right: 1px solid rgba(15,23,42,.10); box-shadow: 2px 0 16px rgba(0,0,0,.06); }
html.theme-light .sidebar-logo { border-bottom-color: rgba(15,23,42,.08); }
html.theme-light .sidebar-logo-text { color: var(--text); }
html.theme-light .sidebar-footer { border-top-color: rgba(15,23,42,.08); }
html.theme-light .nav-item:hover { background: rgba(15,23,42,.05); }
html.theme-light .nav-item.active { background: rgba(59,130,246,.10); }

/* ── TOGGLE SWITCH ── */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}
.toggle-switch input { display: none; }
.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--glass2);
    border: 1px solid var(--border-med);
    border-radius: 24px;
    transition: background .2s, border-color .2s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 2px;
    top: 2px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: transform .2s, background .2s;
}
.toggle-switch input:checked + .toggle-slider {
    background: var(--blue);
    border-color: var(--blue);
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
    background: #fff;
}

/* Toggle row (label + toggle inline) */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-row-info { flex: 1; }
.toggle-row-title { font-size: 13.5px; font-weight: 500; margin-bottom: 2px; }
.toggle-row-desc  { font-size: 12px; color: var(--text-muted); }

/* ── FORM REQUIRED / OPTIONAL ── */
.form-label .req  { color: var(--red);  font-size: 11px; margin-left: 2px; }
.form-label .opt  { color: var(--text-dim); font-size: 11px; margin-left: 4px; font-weight: 400; }

/* ── FORM ICON INPUT ── */
.input-icon-wrap {
    position: relative;
}
.input-icon-wrap .input-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    pointer-events: none;
    display: flex;
}
.input-icon-wrap input,
.input-icon-wrap select,
.input-icon-wrap textarea {
    padding-left: 34px;
}

/* ── COLORED FORM FOCUS ── */
.form-control:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
input[type="url"]:focus,
select:focus,
textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
