/**
 * SMARTER Gest — theme (dark/light) + sidebar
 */

:root,
[data-theme="dark"] {
    --color-bg: #0d0f14;
    --color-bg-elevated: #171b26;
    --color-bg-card: #1d2230;
    --color-bg-input: #262d3d;
    --color-bg-hover: #313a4d;
    --sidebar-bg: #1c2232;
    --color-sidebar-border: rgba(255, 255, 255, 0.1);
    --color-sidebar-text: #d2dae8;
    --color-sidebar-text-muted: #9aa6bc;

    --color-text: #f1f4fa;
    --color-text-muted: #b8c2d4;
    --color-text-label: #cdd5e3;

    --color-border: #3d475c;
    --color-primary: #6b93ff;
    --color-primary-hover: #5580f5;
    --color-success: #4ade80;
    --color-warning: #fbbf24;
    --color-danger: #f87171;

    --radius-md: 8px;
    --sidebar-width: 240px;
    --header-height: 56px;
    --font-sans: "Segoe UI", system-ui, -apple-system, sans-serif;
}

[data-theme="light"] {
    --color-bg: #f4f6f9;
    --color-bg-elevated: #ffffff;
    --color-bg-card: #ffffff;
    --color-bg-input: #ffffff;
    --color-bg-hover: #eef1f6;
    --sidebar-bg: #ffffff;
    --color-sidebar-border: #e2e8f0;
    --color-sidebar-text: #334155;
    --color-sidebar-text-muted: #64748b;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-text-label: #475569;
    --color-border: #e2e8f0;
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--color-sidebar-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar__brand {
    padding: 1rem 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-sidebar-text);
    border-bottom: 1px solid var(--color-sidebar-border);
}

.sidebar__brand-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--color-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}

.sidebar__nav { list-style: none; margin: 0; padding: 0.5rem 0; flex: 1; }
.sidebar__nav li { margin: 0; }

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 1.25rem;
    color: var(--color-sidebar-text-muted);
}

.sidebar__link:hover { background: var(--color-bg-hover); color: var(--color-sidebar-text); text-decoration: none; }
.sidebar__link--active { background: rgba(107, 147, 255, 0.15); color: var(--color-sidebar-text); font-weight: 600; }

.sidebar__footer { padding: 1rem 1.25rem; border-top: 1px solid var(--color-sidebar-border); }
.sidebar__version, .sidebar__email { font-size: 0.75rem; margin-bottom: 0.5rem; }

.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    height: var(--header-height);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg-elevated);
}

.topbar__title { margin: 0; font-size: 1.1rem; flex: 1; }
.topbar__actions { display: flex; gap: 0.5rem; }

.content-wrapper { padding: 1.25rem; flex: 1; }

.card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.card__body { padding: 1.25rem; }
.card__title { margin: 0 0 0.75rem; font-size: 1.25rem; }

.form-group { margin-bottom: 1rem; }
.form-label { display: block; margin-bottom: 0.35rem; font-size: 0.875rem; color: var(--color-text-label); }
.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-input);
    color: var(--color-text);
    font: inherit;
}

.form-hint { font-size: 0.8rem; color: var(--color-text-muted); margin-top: 0.25rem; }
.form-actions { margin-top: 1rem; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font: inherit;
    cursor: pointer;
    text-decoration: none;
}

.btn--primary { background: var(--color-primary); color: #fff; }
.btn--primary:hover { background: var(--color-primary-hover); }
.btn--secondary { background: var(--color-bg-hover); color: var(--color-text); border-color: var(--color-border); }
.btn--block { width: 100%; }
.btn--sm { padding: 0.35rem 0.75rem; font-size: 0.85rem; }

.btn-theme-toggle, .btn-sidebar-toggle {
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 0.35rem 0.6rem;
    cursor: pointer;
    color: var(--color-text);
    font-size: 1.1rem;
}

.alert { padding: 0.75rem 1rem; border-radius: var(--radius-md); margin-bottom: 1rem; }
.alert--success { background: rgba(74, 222, 128, 0.15); border: 1px solid var(--color-success); }
.alert--warning { background: rgba(251, 191, 36, 0.15); border: 1px solid var(--color-warning); }
.alert--danger { background: rgba(248, 113, 113, 0.15); border: 1px solid var(--color-danger); }

.text-muted { color: var(--color-text-muted); }
.text-muted--sm { font-size: 0.875rem; }
.text-center { text-align: center; }
.text-primary { color: var(--color-primary); font-weight: 600; }
.mb-0 { margin-bottom: 0; }
.mb-3 { margin-bottom: 1rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-3 { margin-top: 1rem; }
.p-4 { padding: 1.25rem; }
.small { font-size: 0.8rem; }

.dashboard-widgets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.widget {
    padding: 1rem;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-md);
    text-align: center;
}

.widget__label { display: block; font-size: 0.8rem; color: var(--color-text-muted); }
.widget__value { display: block; font-size: 1.5rem; font-weight: 700; margin-top: 0.25rem; }

.sidebar-overlay[hidden] { display: none; }

@media (max-width: 768px) {
    .sidebar { position: fixed; z-index: 100; height: 100%; transform: translateX(-100%); transition: transform 0.2s; }
    .sidebar.is-open { transform: translateX(0); }
    .sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 99; }
}

/* Party mode */
[data-party-mode="1"] body {
    animation: gest-party-hue 6s linear infinite;
}

@keyframes gest-party-hue {
    0% { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(360deg); }
}

[data-party-mode="1"] .sidebar__brand-icon {
    animation: gest-party-bounce 0.8s ease-in-out infinite alternate;
}

@keyframes gest-party-bounce {
    from { transform: scale(1) rotate(-5deg); }
    to { transform: scale(1.1) rotate(5deg); }
}