/* ==========================================================
   DISPO – Modern UI System
   Bordeaux + Charcoal · Light/Dark · Sidebar Layout
   ========================================================== */

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

/* ==========================================================
   Design Tokens
   ========================================================== */
:root {
    /* Brand */
    --brand-50:  #FAF0F2;
    --brand-100: #F2D9DD;
    --brand-200: #E0AAB0;
    --brand-300: #C97983;
    --brand-400: #A84957;
    --brand-500: #7A1F2B;        /* Mid */
    --brand-600: #5C0F1A;        /* Primary */
    --brand-700: #46091F;
    --brand-800: #2E0612;
    --brand-900: #1A0309;

    /* Light theme (default) */
    --bg:          #F7F7F8;
    --bg-elev:     #FFFFFF;
    --bg-subtle:   #EDEDF0;
    --bg-hover:    #F0F0F3;

    --text:        #1A1A1F;
    --text-muted:  #5A5A66;
    --text-subtle: #8A8A95;
    --text-on-brand: #FFFFFF;

    --border:      #E5E5EA;
    --border-strong: #D0D0D7;

    --sidebar-bg:        var(--brand-600);
    --sidebar-text:      rgba(255, 255, 255, 0.92);
    --sidebar-text-muted:rgba(255, 255, 255, 0.55);
    --sidebar-hover:     rgba(255, 255, 255, 0.08);
    --sidebar-active:    rgba(255, 255, 255, 0.14);
    --sidebar-border:    rgba(255, 255, 255, 0.08);

    --accent:      var(--brand-600);
    --accent-hover:var(--brand-700);
    --accent-soft: var(--brand-50);

    --success:     #1F7A47;
    --success-bg:  #E5F4EC;
    --warning:     #B5731D;
    --warning-bg:  #FBF1E0;
    --danger:      #B0001F;
    --danger-bg:   #FBE5E9;
    --info:        #1E5C9F;
    --info-bg:     #E3EEFA;

    --shadow-sm: 0 1px 2px rgba(15, 15, 25, 0.04), 0 1px 1px rgba(15, 15, 25, 0.03);
    --shadow:    0 4px 12px rgba(15, 15, 25, 0.06), 0 1px 3px rgba(15, 15, 25, 0.04);
    --shadow-lg: 0 12px 32px rgba(15, 15, 25, 0.10), 0 4px 12px rgba(15, 15, 25, 0.05);
    --shadow-focus: 0 0 0 3px rgba(92, 15, 26, 0.18);

    --radius-sm: 6px;
    --radius:    10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    --sidebar-width: 248px;
    --topbar-height: 64px;

    --font-display: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body:    'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono:    'SFMono-Regular', Menlo, Consolas, monospace;

    --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg:          #0E0E12;
    --bg-elev:     #16161D;
    --bg-subtle:   #1C1C25;
    --bg-hover:    #20202A;

    --text:        #ECECF1;
    --text-muted:  #9A9AA8;
    --text-subtle: #6E6E7A;
    --text-on-brand: #FFFFFF;

    --border:      #25252F;
    --border-strong: #34343F;

    --sidebar-bg:        #0A0A0E;
    --sidebar-text:      rgba(255, 255, 255, 0.88);
    --sidebar-text-muted:rgba(255, 255, 255, 0.45);
    --sidebar-hover:     rgba(255, 255, 255, 0.05);
    --sidebar-active:    rgba(168, 73, 87, 0.18);
    --sidebar-border:    rgba(255, 255, 255, 0.06);

    --accent:      var(--brand-400);
    --accent-hover:var(--brand-300);
    --accent-soft: rgba(168, 73, 87, 0.12);

    --success-bg: rgba(31, 122, 71, 0.15);
    --warning-bg: rgba(181, 115, 29, 0.15);
    --danger-bg:  rgba(176, 0, 31, 0.15);
    --info-bg:    rgba(30, 92, 159, 0.15);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow:    0 4px 12px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
    --shadow-focus: 0 0 0 3px rgba(168, 73, 87, 0.35);
}

/* ==========================================================
   Reset & Base
   ========================================================== */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font-body);
    color: var(--text);
    background: var(--bg);
    line-height: 1.55;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color var(--transition), color var(--transition);
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

h1, h2, h3, h4 {
    font-family: var(--font-display);
    color: var(--text);
    margin: 0 0 0.5em;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.01em;
}
h1 { font-size: 1.75rem; letter-spacing: -0.02em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
h4 { font-size: 0.95rem; }

p { margin: 0 0 1rem; }
small { font-size: 0.82rem; }

code, pre {
    font-family: var(--font-mono);
    font-size: 0.85em;
}
code {
    background: var(--bg-subtle);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    color: var(--text);
}

/* ==========================================================
   App Shell – Sidebar + Main
   ========================================================== */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    border-right: 1px solid var(--sidebar-border);
}

.sidebar-brand {
    padding: 1.75rem 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-brand img,
.sidebar-brand picture {
    display: block;
    max-width: 100%;
    height: auto;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0.75rem;
}
.sidebar-section {
    margin-bottom: 1.25rem;
}
.sidebar-section-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sidebar-text-muted);
    padding: 0 0.75rem;
    margin-bottom: 0.4rem;
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 0.75rem;
    color: var(--sidebar-text);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
    margin-bottom: 1px;
}
.sidebar-nav a:hover {
    background: var(--sidebar-hover);
    color: #fff;
    text-decoration: none;
}
.sidebar-nav a.active {
    background: var(--sidebar-active);
    color: #fff;
    font-weight: 600;
}
.sidebar-nav a svg {
    width: 18px; height: 18px;
    flex-shrink: 0;
    opacity: 0.85;
}
.sidebar-nav a.disabled {
    opacity: 0.4;
    pointer-events: none;
}
.sidebar-nav a .badge-soon {
    margin-left: auto;
    font-size: 0.65rem;
    background: rgba(255,255,255,0.1);
    padding: 1px 6px;
    border-radius: 99px;
    font-weight: 500;
    letter-spacing: 0.05em;
}

.sidebar-footer {
    padding: 0.85rem 1rem;
    border-top: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.sidebar-user {
    flex: 1;
    overflow: hidden;
    min-width: 0;
    text-decoration: none;
    padding: 0.4rem 0.5rem;
    margin: -0.4rem -0.5rem;
    border-radius: 6px;
    transition: background var(--transition);
}
.sidebar-user:hover {
    background: rgba(255, 255, 255, 0.06);
    text-decoration: none;
}
.sidebar-user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-role {
    font-size: 0.7rem;
    color: var(--sidebar-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ---------- Theme Toggle ---------- */
.theme-toggle {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--transition);
}
.theme-toggle:hover { background: rgba(255,255,255,0.12); }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }

.logout-link {
    color: var(--sidebar-text-muted) !important;
    width: 32px; height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background var(--transition), color var(--transition);
}
.logout-link:hover { background: rgba(255,255,255,0.08); color: #fff !important; }
.logout-link svg { width: 16px; height: 16px; }

/* ---------- Main Content ---------- */
.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: var(--topbar-height);
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar-title {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
}
.topbar-meta {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.content {
    padding: 2rem;
    max-width: 1280px;
    width: 100%;
}
@media (min-width: 1280px) { .content { padding: 2.5rem 3rem; } }

/* ==========================================================
   Cards
   ========================================================== */
.card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}
.card-compact { padding: 1rem 1.25rem; }
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.card-header h2 { margin: 0; }
.card-header p { color: var(--text-muted); margin: 0.25rem 0 0; }

.card-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.tile {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    text-decoration: none !important;
    color: var(--text);
}
.tile:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.tile-icon {
    width: 36px; height: 36px;
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
}
.tile-icon svg { width: 18px; height: 18px; }
.tile-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
}
.tile-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.45;
}
.tile.disabled { opacity: 0.55; pointer-events: none; }

/* ==========================================================
   Wizard Stepper (für Setup)
   ========================================================== */
.wizard-shell {
    max-width: 760px;
    margin: 3rem auto;
    padding: 0 1.5rem;
}

.stepper {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    counter-reset: step;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1rem;
    box-shadow: var(--shadow-sm);
}
.stepper .step {
    flex: 1;
    text-align: center;
    position: relative;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.stepper .step::before {
    counter-increment: step;
    content: counter(step);
    display: block;
    width: 32px; height: 32px;
    line-height: 32px;
    border-radius: 50%;
    background: var(--bg-subtle);
    color: var(--text-subtle);
    margin: 0 auto 0.4rem;
    font-size: 0.9rem;
    font-weight: 700;
    transition: background var(--transition), color var(--transition);
    font-family: var(--font-display);
}
.stepper .step.active::before {
    background: var(--accent);
    color: var(--text-on-brand);
    box-shadow: 0 0 0 4px var(--accent-soft);
}
.stepper .step.done::before {
    background: var(--success);
    color: #fff;
    content: "✓";
}
.stepper .step.active { color: var(--accent); }
.stepper .step:not(:last-child)::after {
    content: "";
    position: absolute;
    top: 16px; left: 60%;
    width: 80%; height: 2px;
    background: var(--border);
    z-index: -1;
}

/* ==========================================================
   Forms
   ========================================================== */
.form-group { margin-bottom: 1.15rem; }
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    color: var(--text);
}
.form-group small {
    display: block;
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-top: 0.3rem;
}
/* Globales Form-Element-Styling (greift überall, nicht nur in .form-group) */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
input[type="number"],
input[type="search"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
select,
textarea {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-family: inherit;
    background: var(--bg-elev);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
    box-sizing: border-box;
}
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="date"]:focus,
input[type="datetime-local"]:focus,
input[type="time"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--shadow-focus);
}
input::placeholder { color: var(--text-subtle); }

/* Eigenes Caret-Icon für Selects (statt des Browser-Defaults) */
select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237A7A85' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 12px;
    padding-right: 2.2rem;
    cursor: pointer;
}

/* Form-Group: behält sein vorheriges Verhalten */
.form-group input,
.form-group select,
.form-group textarea {
    /* Eigenschaften kommen jetzt vom globalen Styling oben */
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    /* Eigenschaften kommen jetzt vom globalen Styling oben */
}

.form-row {
    display: flex;
    gap: 1rem;
}
.form-row .form-group { flex: 1; min-width: 0; }

fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem 1.25rem;
    margin: 1.25rem 0;
    background: var(--bg);
}
fieldset legend {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--accent);
    padding: 0 0.5rem;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
}

/* ==========================================================
   Buttons
   ========================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.1rem;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--text-on-brand) !important;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none !important;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
    font-family: inherit;
    line-height: 1.2;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn:disabled { background: var(--bg-subtle); color: var(--text-subtle) !important; cursor: not-allowed; }

.btn-secondary {
    background: var(--bg-elev);
    color: var(--text) !important;
    border: 1px solid var(--border-strong);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--text-muted); }

.btn-ghost {
    background: transparent;
    color: var(--text-muted) !important;
    border: 0;
}
.btn-ghost:hover { background: var(--bg-subtle); color: var(--text) !important; }

.btn-row {
    display: flex;
    gap: 0.7rem;
    margin-top: 1.5rem;
    justify-content: space-between;
    align-items: center;
}

/* ==========================================================
   Alerts
   ========================================================== */
.alert {
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.2rem;
    border-left: 3px solid var(--text-muted);
    background: var(--bg-subtle);
    font-size: 0.9rem;
    color: var(--text);
}
.alert strong { font-weight: 600; }
.alert-success { border-color: var(--success); background: var(--success-bg); }
.alert-error   { border-color: var(--danger);  background: var(--danger-bg); }
.alert-warning { border-color: var(--warning); background: var(--warning-bg); }
.alert-info    { border-color: var(--info);    background: var(--info-bg); }

/* ==========================================================
   Check-Liste (Setup Wizard)
   ========================================================== */
.check-list { list-style: none; padding: 0; margin: 0; }
.check-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.7rem 0.25rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}
.check-list li:last-child { border-bottom: none; }

.badge {
    padding: 0.2rem 0.6rem;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.badge-ok   { background: var(--success-bg); color: var(--success); }
.badge-fail { background: var(--danger-bg);  color: var(--danger); }
.badge-soft { background: var(--bg-subtle);  color: var(--text-muted); }

/* ==========================================================
   Auth Page (Login/Magiclink)
   ========================================================== */
.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem 1rem;
    background:
        radial-gradient(ellipse at top left, rgba(92, 15, 26, 0.08), transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(92, 15, 26, 0.05), transparent 50%),
        var(--bg);
}
[data-theme="dark"] .auth-shell {
    background:
        radial-gradient(ellipse at top left, rgba(168, 73, 87, 0.12), transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(92, 15, 26, 0.18), transparent 50%),
        var(--bg);
}
.auth-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    width: 100%;
    max-width: 420px;
    padding: 2.5rem 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}
.auth-card .auth-brand {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1.75rem;
}
.auth-card .auth-brand img,
.auth-card .auth-brand picture { display: block; }

/* ==========================================================
   Wizard / Auth: Logo for header
   ========================================================== */
.wizard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 0 0;
    margin-bottom: 1rem;
}
.wizard-brand {
    display: flex;
    align-items: center;
    text-decoration: none !important;
}
.wizard-brand img,
.wizard-brand picture { display: block; }

/* ==========================================================
   Footer
   ========================================================== */
.footer {
    text-align: center;
    color: var(--text-subtle);
    font-size: 0.8rem;
    padding: 2rem 1rem 1rem;
}

/* ==========================================================
   Responsive
   ========================================================== */
@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
    }
    .sidebar {
        position: static;
        height: auto;
        max-height: 100vh;
    }
    .form-row { flex-direction: column; gap: 0; }
    .content { padding: 1.5rem 1.25rem; }
    .topbar { padding: 0 1.25rem; }
}

/* ==========================================================
   Utilities
   ========================================================== */
.muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.gap-2 { gap: 0.5rem; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }

/* No flash of light on dark theme load */
html[data-theme] body { transition: background-color var(--transition); }
