/*
 * TanyaPsikologi UI system
 * Calm, accessible colours for long and emotionally sensitive sessions.
 */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
    color-scheme: light;
    --primary: #247c78;
    --primary-dark: #185f5c;
    --primary-rgb: 36, 124, 120;
    --primary-soft: #e5f3f1;
    --secondary: #5577a8;
    --secondary-dark: #405f8c;
    --accent: #c47c5a;
    --bg-light: #f5f8f7;
    --surface: #ffffff;
    --surface-raised: #ffffff;
    --surface-hover: #edf4f2;
    --text-main: #18302f;
    --text-muted: #5d706f;
    --text-light: #718584;
    --border: #dce7e4;
    --border-strong: #c4d4d1;
    --danger: #b94c54;
    --danger-soft: #fbeaec;
    --warning: #a56d20;
    --warning-soft: #fff4dd;
    --success: #287a59;
    --success-soft: #e5f4ec;
    --info: #426f9f;
    --info-soft: #e8f0f8;
    --sidebar-width: 272px;
    --topbar-height: 72px;
    --shadow-sm: 0 1px 2px rgba(24, 48, 47, .06);
    --shadow-md: 0 10px 28px rgba(24, 48, 47, .08);
    --shadow-lg: 0 24px 60px rgba(24, 48, 47, .13);
    --radius-sm: .5rem;
    --radius-md: .75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.25rem;
    --bs-primary: var(--primary);
    --bs-primary-rgb: var(--primary-rgb);
    --bs-body-bg: var(--bg-light);
    --bs-body-color: var(--text-main);
    --bs-border-color: var(--border);
}

[data-theme="dark"] {
    color-scheme: dark;
    --primary: #6fc7bd;
    --primary-dark: #9adbd3;
    --primary-rgb: 111, 199, 189;
    --primary-soft: #173f3d;
    --secondary: #91acd1;
    --secondary-dark: #b2c5df;
    --accent: #e0a181;
    --bg-light: #101a1c;
    --surface: #172426;
    --surface-raised: #1c2b2e;
    --surface-hover: #213436;
    --text-main: #ecf5f3;
    --text-muted: #adc0bd;
    --text-light: #8ea4a1;
    --border: #2b4142;
    --border-strong: #3a5555;
    --danger: #f08a91;
    --danger-soft: #44262b;
    --warning: #edbd6e;
    --warning-soft: #41351f;
    --success: #73c99e;
    --success-soft: #1d3c31;
    --info: #91b9e1;
    --info-soft: #21364a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .2);
    --shadow-md: 0 10px 28px rgba(0, 0, 0, .24);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, .34);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    min-height: 100vh;
    margin: 0;
    background: var(--bg-light);
    color: var(--text-main);
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    font-size: .9375rem;
    line-height: 1.6;
    letter-spacing: -.01em;
    -webkit-font-smoothing: antialiased;
    transition: background-color .2s ease, color .2s ease;
    overflow-x: hidden;
}
a { color: var(--primary); text-underline-offset: .2em; }
a:hover { color: var(--primary-dark); }
:focus-visible { outline: 3px solid rgba(var(--primary-rgb), .35); outline-offset: 2px; }
.skip-link { position: fixed; left: 1rem; top: -4rem; z-index: 9999; padding: .65rem 1rem; background: var(--surface); color: var(--text-main); border-radius: var(--radius-sm); }
.skip-link:focus { top: 1rem; }

/* Dashboard composition */
.dashboard-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.dashboard-heading h1 {
    margin: 0 0 .3rem;
    font-size: clamp(1.45rem, 2.5vw, 2rem);
    font-weight: 800;
    letter-spacing: -.035em;
}
.dashboard-heading p { margin: 0; color: var(--text-muted); }
.dashboard-grid { margin-bottom: 1.5rem; }
.metric-card {
    position: relative;
    display: flex;
    min-height: 134px;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.metric-card::after {
    position: absolute;
    right: -2rem;
    bottom: -3rem;
    width: 7rem;
    height: 7rem;
    content: "";
    background: var(--primary-soft);
    border-radius: 50%;
    opacity: .55;
}
.metric-card:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.metric-label { margin-bottom: .35rem; color: var(--text-muted); font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.metric-value { color: var(--text-main); font-size: clamp(1.65rem, 3vw, 2.15rem); font-weight: 800; line-height: 1.1; letter-spacing: -.04em; }
.stat-icon {
    position: relative;
    z-index: 1;
    display: grid !important;
    width: 50px !important;
    height: 50px !important;
    flex: 0 0 50px;
    place-items: center !important;
    color: var(--primary) !important;
    background: var(--primary-soft) !important;
    border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--border));
    border-radius: var(--radius-md) !important;
    font-size: 1.25rem !important;
}
.dashboard-panel {
    height: 100%;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.dashboard-panel .card-header {
    display: flex;
    min-height: 64px;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: 1rem 1.25rem !important;
    background: transparent !important;
    border-bottom: 1px solid var(--border) !important;
}
.dashboard-panel .card-body { padding: 1.25rem; }
.progress { overflow: hidden; background: var(--surface-hover) !important; border-radius: 999px; }
.quick-action {
    min-height: 76px;
    color: var(--text-main) !important;
    background: var(--surface-raised) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-md) !important;
}
.quick-action:hover { background: var(--surface-hover) !important; border-color: var(--border-strong) !important; }
.welcome-panel {
    position: relative;
    padding: clamp(1.5rem, 4vw, 2.5rem);
    overflow: hidden;
    color: #fff;
    background: linear-gradient(135deg, #185f5c, #247c78);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}
.welcome-panel::after {
    position: absolute;
    width: 240px;
    height: 240px;
    right: -80px;
    bottom: -145px;
    content: "";
    background: rgba(255,255,255,.08);
    border-radius: 50%;
}
.welcome-panel h1 { font-size: clamp(1.45rem, 3vw, 2rem); }
.dashboard-empty { padding: 3rem 1rem; color: var(--text-muted); text-align: center; }
.dashboard-empty i { display: block; margin-bottom: .75rem; color: var(--text-light); font-size: 2.4rem; }

.heading-sm { font-size: 1.05rem; font-weight: 700; }
.heading-md { font-size: clamp(1.3rem, 2vw, 1.65rem); font-weight: 750; }
.heading-lg { font-size: clamp(1.8rem, 4vw, 2.5rem); font-weight: 800; }
.fw-500 { font-weight: 500 !important; }
.fw-600 { font-weight: 600 !important; }
.fw-700 { font-weight: 700 !important; }
.fw-800 { font-weight: 800 !important; }
.text-muted { color: var(--text-muted) !important; }
.text-primary { color: var(--primary) !important; }

.app-shell { min-height: 100vh; }
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    display: flex;
    width: var(--sidebar-width);
    flex-direction: column;
    overflow: hidden;
    background: var(--surface);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: transform .25s ease;
}
.sidebar-brand {
    min-height: var(--topbar-height);
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}
.brand-mark {
    display: inline-grid;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    place-items: center;
    color: #fff;
    font-size: 1.25rem;
    background: var(--primary);
    border-radius: .8rem;
    box-shadow: 0 8px 20px rgba(var(--primary-rgb), .2);
}
.brand-copy { min-width: 0; }
.sidebar-brand h6 { margin: 0; color: var(--text-main); font-size: .95rem; font-weight: 750; }
.sidebar-brand small { display: block; overflow: hidden; color: var(--text-muted); font-size: .65rem; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem 0 6.5rem; scrollbar-width: thin; }
.sidebar .nav-section-title {
    margin: 1rem 1.25rem .4rem;
    color: var(--text-light);
    font-size: .67rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
}
.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: .15rem .75rem;
    padding: .68rem .85rem;
    color: var(--text-muted);
    font-size: .84rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    transition: background .15s ease, color .15s ease, transform .15s ease;
}
.sidebar .nav-link i { width: 1.2rem; color: var(--text-light); font-size: 1rem; text-align: center; }
.sidebar .nav-link:hover { color: var(--text-main); background: var(--surface-hover); transform: translateX(2px); }
.sidebar .nav-link.active { color: var(--primary-dark); background: var(--primary-soft); }
.sidebar .nav-link.active i { color: var(--primary); }
.sidebar-user {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    padding: .9rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
}
.avatar {
    display: inline-grid;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    place-items: center;
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    background: var(--primary);
    border-radius: 50%;
}
.main-content { min-height: 100vh; margin-left: var(--sidebar-width); transition: margin .25s ease; }
.topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    min-height: var(--topbar-height);
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .8rem clamp(1rem, 3vw, 2rem);
    background: color-mix(in srgb, var(--surface) 91%, transparent);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(14px);
}
.page-content { width: 100%; max-width: 1600px; margin: 0 auto; padding: clamp(1rem, 3vw, 2rem); }
.sidebar-backdrop { position: fixed; inset: 0; z-index: 1035; display: none; background: rgba(7, 20, 21, .48); backdrop-filter: blur(2px); }

.theme-toggle, .icon-button {
    display: inline-grid;
    width: 40px;
    height: 40px;
    padding: 0;
    place-items: center;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.theme-toggle:hover, .icon-button:hover { color: var(--primary); background: var(--surface-hover); border-color: var(--border-strong); }
.sidebar-theme-toggle {
    display: flex;
    width: 100%;
    height: 38px;
    align-items: center;
    justify-content: flex-start;
    gap: .65rem;
    padding: 0 .75rem;
    font-size: .75rem;
    font-weight: 650;
}
.theme-toggle-floating {
    position: fixed;
    left: 1rem;
    bottom: 1rem;
    z-index: 1050;
    box-shadow: var(--shadow-md);
}

.card, .glass-card, .glass-panel {
    color: var(--text-main);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.card { overflow: hidden; }
.card-header, .card-footer { color: var(--text-main); background: var(--surface-raised); border-color: var(--border); }
.card-header { padding: 1rem 1.25rem; }
.card-body { padding: 1.25rem; }
.glass-card { transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease; }
.glass-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-2px); }

.btn {
    min-height: 40px;
    font-weight: 650;
    border-radius: var(--radius-sm);
    transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { color: #fff; background: #247c78; border-color: #247c78; }
.btn-primary:hover, .btn-primary:focus { color: #fff; background: #185f5c; border-color: #185f5c; box-shadow: 0 6px 18px rgba(36,124,120,.22); }
[data-theme="dark"] .btn-primary { color: #10201f; background: #6fc7bd; border-color: #6fc7bd; }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { color: var(--surface); background: var(--primary); border-color: var(--primary); }
.btn-light, .bg-light { color: var(--text-main) !important; background: var(--surface-hover) !important; border-color: var(--border) !important; }

.form-label { color: var(--text-main); font-weight: 600; }
.form-control, .form-select, .input-group-text {
    min-height: 44px;
    color: var(--text-main);
    background-color: var(--surface);
    border-color: var(--border-strong);
    border-radius: var(--radius-sm);
}
.form-control::placeholder { color: var(--text-light); }
.form-control:focus, .form-select:focus {
    color: var(--text-main);
    background: var(--surface);
    border-color: var(--primary);
    box-shadow: 0 0 0 .2rem rgba(var(--primary-rgb), .15);
}
.form-check-input { background-color: var(--surface); border-color: var(--border-strong); }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }

.table { --bs-table-bg: transparent; --bs-table-color: var(--text-main); --bs-table-border-color: var(--border); }
.table-responsive { border-radius: var(--radius-md); }
.table-modern { width: 100%; border-collapse: separate; border-spacing: 0 .45rem; }
.table-modern th { padding: .5rem 1rem; color: var(--text-muted); font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; border: 0; }
.table-modern td { padding: .9rem 1rem; color: var(--text-main); background: var(--surface); border-block: 1px solid var(--border); vertical-align: middle; }
.table-modern td:first-child { border-left: 1px solid var(--border); border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.table-modern td:last-child { border-right: 1px solid var(--border); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.table-modern tr:hover td { background: var(--surface-hover); }

.badge { padding: .4em .75em; font-weight: 650; border-radius: 999px; }
.bg-primary { background-color: var(--primary) !important; }
.bg-secondary { background-color: var(--secondary) !important; }
.bg-success { background-color: var(--success) !important; }
.bg-danger { background-color: var(--danger) !important; }
.bg-warning { color: #3c2a08 !important; background-color: var(--warning) !important; }
.alert { color: var(--text-main); background: var(--surface); border-color: var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
.alert-success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 35%, var(--border)); }
.alert-danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.alert-warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 35%, var(--border)); }
.alert-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 35%, var(--border)); }
.modal-content, .dropdown-menu, .list-group-item { color: var(--text-main); background: var(--surface); border-color: var(--border); }
.dropdown-item { color: var(--text-main); }
.dropdown-item:hover { color: var(--text-main); background: var(--surface-hover); }
.btn-close { filter: var(--close-filter, none); }
[data-theme="dark"] { --close-filter: invert(1) grayscale(1); }

.empty-state-icon, .pre-call-icon, .feature-icon-wrap, .form-logo {
    display: inline-grid;
    place-items: center;
    color: var(--primary);
    background: var(--primary-soft);
    border-radius: var(--radius-lg);
}
.empty-state-icon i, .pre-call-icon i, .feature-icon-wrap i, .form-logo i { font-size: inherit; }
.whatsapp-float {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 1010;
    display: grid;
    width: 52px;
    height: 52px;
    place-items: center;
    color: #fff;
    background: #187a55;
    border: 3px solid var(--surface);
    border-radius: 50%;
    box-shadow: var(--shadow-md);
}
.whatsapp-float:hover { color: #fff; background: #126444; transform: translateY(-2px); }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .sidebar-backdrop.show { display: block; }
    .main-content { margin-left: 0; }
    body.sidebar-open { overflow: hidden; }
    .sidebar-theme-toggle { display: flex; }
}
@media (max-width: 575.98px) {
    .topbar { min-height: 64px; padding: .65rem .9rem; }
    .page-content { padding: .9rem; }
    .card-body, .card-header { padding: 1rem; }
    .role-badge { display: none; }
    .table-responsive { margin-inline: -.25rem; }
    .btn:not(.btn-sm):not(.icon-button):not(.theme-toggle) { min-height: 44px; }
    h1, h2, h3, p { overflow-wrap: anywhere; }
    .dashboard-heading { align-items: flex-start; flex-direction: column; }
    .metric-card { min-height: 112px; padding: 1rem; }
    .dashboard-panel .card-header { align-items: flex-start; flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
