/*
 * Solar-OS Layout + Komponenten — branding-agnostisch.
 * Nutzt CSS-Variablen aus branding.css.
 */
* { box-sizing: border-box; }

html {
    /* Scrollbar IMMER reservieren — sonst springt der Viewport beim Wechsel
       zwischen Seiten unterschiedlicher Höhe. */
    overflow-y: scroll;
    scrollbar-gutter: stable;
    /* Fix font-size Basis damit rem-basierte Größen konstant bleiben */
    font-size: 16px;
    /* Verhindert Browser-Mobile-Auto-Resize von Schrift */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: var(--font-stack);
    background: var(--neutral-50);
    color: var(--neutral-700);
    margin: 0;
    line-height: 1.5;
    font-size: 1rem;
}

a { color: var(--brand-primary); }
a:hover { color: var(--brand-primary-dark); }

h1 { color: var(--neutral-900); margin-top: 0; font-size: 1.5rem; }
h2 { color: var(--neutral-900); font-size: 1.125rem; }

/* Layout — Sidebar links, Content rechts */
.app-layout {
    display: flex;
    min-height: 100vh;
}
.sidebar {
    width: 240px;
    min-width: 240px;
    max-width: 240px;
    background: var(--surface);
    border-right: 1px solid var(--neutral-200);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    flex-grow: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    /* Defensive: keine Animation/Transition auf der Sidebar */
    transition: none;
}
.sidebar-brand {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--neutral-100);
    text-decoration: none;
    color: var(--neutral-900);
    display: block;
}
.sidebar-brand .brand-name {
    font-weight: 700;
    letter-spacing: 0.05em;
    font-size: 0.9375rem;
}
.sidebar-brand small {
    display: block;
    color: var(--brand-primary);
    font-weight: 500;
    font-size: 0.75rem;
    margin-top: 0.125rem;
    letter-spacing: 0.04em;
}
.sidebar-nav {
    padding: 0.75rem 0.625rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.875rem;
    color: var(--neutral-700);
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.9375rem;
    /* Border-Left als Active-Indikator. Immer 3 px breit (transparent für inactive),
       damit der Klick-Wechsel KEINE Layout-Verschiebung erzeugt. */
    border-left: 3px solid transparent;
    padding-left: calc(0.875rem - 3px);
}
.sidebar-nav a:hover {
    background: var(--neutral-100);
    color: var(--brand-primary);
}
.sidebar-nav a.active {
    background: var(--brand-primary-soft);
    color: var(--brand-on-soft);
    border-left-color: var(--brand-primary);
    /* font-weight bewusst NICHT geändert — Bold-Text ist breiter als Regular
       und verursacht beim Durchklicken minimale Layout-Shifts. */
}
.sidebar-nav a svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    stroke-width: 1.75;
}
.sidebar-nav .group-label {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--neutral-400);
    padding: 0.875rem 0.875rem 0.375rem;
    font-weight: 600;
}
.sidebar-footer {
    border-top: 1px solid var(--neutral-100);
    padding: 0.625rem 0.875rem;
    font-size: 0.8125rem;
}
.sidebar-footer .user-name {
    font-weight: 600;
    color: var(--neutral-900);
}
.sidebar-footer .user-rolle {
    color: var(--neutral-400);
    font-size: 0.75rem;
}
.sidebar-footer .logout {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    color: var(--neutral-400);
    text-decoration: none;
    margin-top: 0.5rem;
    font-size: 0.8125rem;
}
.sidebar-footer .logout:hover { color: var(--color-danger); }
.sidebar-footer .logout svg { width: 14px; height: 14px; stroke-width: 2; }

.app-main {
    flex: 1;
    min-width: 0;
    background: var(--neutral-50);
}
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Mobile: Sidebar wird Off-Canvas */
.sidebar-toggle {
    display: none;
    background: var(--surface);
    border: 0;
    padding: 0.625rem;
    cursor: pointer;
    border-bottom: 1px solid var(--neutral-200);
    width: 100%;
    text-align: left;
    color: var(--neutral-700);
}
.sidebar-toggle svg { width: 20px; height: 20px; vertical-align: middle; margin-right: 0.5rem; }

@media (max-width: 768px) {
    .app-layout { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        border-right: 0;
        border-bottom: 1px solid var(--neutral-200);
        max-height: 100vh;
    }
    .sidebar:not(.open) .sidebar-nav,
    .sidebar:not(.open) .sidebar-footer { display: none; }
    .sidebar-toggle { display: block; }
    main { padding: 1rem; }
}

/* Buttons mit Icons */
.btn svg, .btn-secondary svg {
    width: 16px;
    height: 16px;
    vertical-align: -3px;
    margin-right: 0.25rem;
    stroke-width: 2;
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--neutral-200);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}
.empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--neutral-400);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

/* Buttons */
.actions { margin: 1rem 0; }
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--brand-primary);
    color: white;
    border: 0;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.btn:hover { background: var(--brand-primary-dark); color: white; }
.btn-secondary {
    background: var(--neutral-200);
    color: var(--neutral-700);
}
.btn-secondary:hover {
    background: var(--neutral-300);
    color: var(--neutral-700);
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--neutral-200);
    border-radius: 12px;
    overflow: hidden;
}
th, td {
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--neutral-100);
}
th {
    background: var(--neutral-50);
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--neutral-400);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
tr:last-child td { border-bottom: 0; }
tr:hover td { background: var(--neutral-50); }

/* Flashes */
.flash {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}
.flash-success {
    background: var(--color-success-bg);
    color: var(--color-success-text);
    border: 1px solid var(--color-success-border);
}
.flash-error {
    background: var(--color-danger-bg);
    color: var(--color-danger-text);
    border: 1px solid var(--color-danger-border);
}

/* Forms */
label {
    display: block;
    margin: 0.5rem 0 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
}
input[type=text],
input[type=email],
input[type=tel],
input[type=password],
input[type=datetime-local],
input[type=date],
input[type=number],
textarea,
select {
    width: 100%;
    padding: 0.5rem 0.625rem;
    border: 1px solid var(--neutral-200);
    border-radius: 6px;
    font-size: 0.9375rem;
    font-family: inherit;
    background: var(--surface);
}
input:focus, textarea:focus, select:focus {
    outline: 2px solid var(--brand-primary);
    outline-offset: -1px;
    border-color: transparent;
}
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 1rem;
}
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 600px) {
    .form-grid { grid-template-columns: 1fr; }
}
