/*
 * Basis-Stylesheet des Kundenportals. Handgeschrieben, kein Build-Step,
 * kein Framework. Helles SaaS-Panel-Design mit linker Seitenleiste
 * (Vorbild: 24fire-Control-Panel), Gold als Markenakzent. Rajdhani fuer
 * Ueberschriften, DM Mono fuer technische Werte, Nunito Sans als Lesetext.
 *
 * Schriften liegen lokal unter /assets/fonts/ (selbst gehostet statt via
 * Google Fonts CDN) - so bleibt die strikte Content-Security-Policy
 * (default-src 'self') unangetastet.
 */

@font-face {
    font-family: 'Rajdhani';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/assets/fonts/rajdhani-500.woff2') format('woff2');
}
@font-face {
    font-family: 'Rajdhani';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/assets/fonts/rajdhani-600.woff2') format('woff2');
}
@font-face {
    font-family: 'Rajdhani';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/assets/fonts/rajdhani-700.woff2') format('woff2');
}
@font-face {
    font-family: 'DM Mono';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/assets/fonts/dm-mono-400.woff2') format('woff2');
}
@font-face {
    font-family: 'DM Mono';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/assets/fonts/dm-mono-500.woff2') format('woff2');
}
@font-face {
    font-family: 'Nunito Sans';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/assets/fonts/nunito-sans-400.woff2') format('woff2');
}
@font-face {
    font-family: 'Nunito Sans';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/assets/fonts/nunito-sans-600.woff2') format('woff2');
}

:root {
    --gold:     #F5A623;
    --gold-dk:  #C97F0E;
    --teal:     #1A8FA0;
    --teal-lt:  #5BC4D4;
    --olive:    #A8A865;
    --green:    #1a9e56;

    --color-bg:            #f5f6f8;
    --color-surface:       #ffffff;
    --color-surface-alt:   #f0f1f4;
    --color-border:        #e3e5ea;
    --color-text:          #1a1d23;
    --color-text-muted:    #6b7280;

    --color-primary:          var(--gold);
    --color-primary-hover:    var(--gold-dk);
    --color-primary-contrast: #2b1c04;
    --color-focus:            var(--teal);

    --color-success-bg:     #e8f7ee;
    --color-success-text:   var(--green);
    --color-success-border: #b8e6c8;

    --color-error-bg:     #fdecec;
    --color-error-text:   #c0392b;
    --color-error-border: #f3c2c2;

    --color-warning-bg:     #fff8e6;
    --color-warning-text:   #966a0a;
    --color-warning-border: #f0dba0;

    --sidebar-width: 240px;
    --radius: 10px;
    --shadow-card: 0 1px 2px rgba(20, 24, 30, 0.05), 0 1px 1px rgba(20, 24, 30, 0.04);
    --font-heading: 'Rajdhani', sans-serif;
    --font-sans: 'Nunito Sans', -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'DM Mono', ui-monospace, SFMono-Regular, "Cascadia Code", Consolas, monospace;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: 14.5px;
    line-height: 1.6;
}

a {
    color: var(--teal);
    text-decoration: none;
}
a:hover {
    color: var(--gold-dk);
    text-decoration: underline;
}

h1, h2, h3 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.25;
    margin: 0 0 0.6em;
    color: var(--color-text);
}

/* --- App-Gerüst: Sidebar + Hauptbereich --- */

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

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px;
    border-bottom: 1px solid var(--color-border);
    text-decoration: none;
}
.sidebar__brand:hover {
    text-decoration: none;
}

.sidebar__logo-chip {
    background: #14171f;
    border-radius: 8px;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sidebar__logo-chip img {
    height: 22px;
    width: auto;
    display: block;
}

.sidebar__brand-text {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 16px;
    line-height: 1.2;
    color: var(--color-text);
}
.sidebar__brand-text .accent {
    color: var(--gold-dk);
}
.sidebar__brand-sub {
    display: block;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 10.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-top: 1px;
}

.sidebar__nav {
    flex: 1;
    padding: 14px 10px;
    overflow-y: auto;
}

.sidebar__section-label {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    padding: 14px 10px 6px;
}

.sidebar__nav > a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 7px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--color-text);
    text-decoration: none;
    margin-bottom: 2px;
}
.sidebar__nav a svg {
    flex-shrink: 0;
    opacity: 0.65;
}
.sidebar__nav > a:hover {
    background: var(--color-surface-alt);
    text-decoration: none;
}
.sidebar__nav a.is-active {
    background: rgba(245, 166, 35, 0.13);
    color: var(--gold-dk);
}
.sidebar__nav a.is-active svg {
    opacity: 1;
}

/* --- Aufklappbarer Sidebar-Bereich (z.B. "Produkte") - natives <details>,
   kein JS noetig fuer das Auf-/Zuklappen. --- */

.sidebar__group {
    margin-bottom: 2px;
}

.sidebar__group summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 7px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--color-text);
    cursor: pointer;
    list-style: none;
}
.sidebar__group summary::-webkit-details-marker {
    display: none;
}
.sidebar__group summary:hover {
    background: var(--color-surface-alt);
}
.sidebar__group summary svg.chevron {
    margin-left: auto;
    opacity: 0.5;
    transition: transform 0.15s ease;
}
.sidebar__group[open] summary svg.chevron {
    transform: rotate(90deg);
}

.sidebar__group-items {
    padding: 2px 0 4px 14px;
    border-left: 1px solid var(--color-border);
    margin: 2px 0 4px 24px;
}
.sidebar__group-items a {
    display: block;
    padding: 7px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-muted);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar__group-items a:hover {
    background: var(--color-surface-alt);
    color: var(--color-text);
    text-decoration: none;
}
.sidebar__group-items a.is-active {
    color: var(--gold-dk);
    font-weight: 700;
}
.sidebar__group-empty {
    padding: 6px 12px;
    font-size: 12.5px;
    color: var(--color-text-muted);
}

.sidebar__footer {
    padding: 14px;
    border-top: 1px solid var(--color-border);
}

.sidebar__user {
    font-size: 12.5px;
    color: var(--color-text-muted);
    margin-bottom: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.main {
    flex: 1;
    min-width: 0;
    padding: 32px 36px 64px;
}

.container {
    max-width: 1040px;
    margin: 0 auto;
}

.container--narrow {
    max-width: 460px;
    padding: 0 20px;
}

.auth-logo {
    display: block;
    height: 56px;
    width: auto;
    margin: 0 auto 16px;
}

/* --- Card --- */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 24px 26px;
    margin-bottom: 20px;
}

.card h2 {
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin: 0 0 16px;
}

.card--danger {
    background: var(--color-error-bg);
    border-color: var(--color-error-border);
}
.card--danger h2 {
    color: var(--color-error-text);
}
.card--danger p {
    color: var(--color-error-text);
    font-size: 13px;
}

/* --- Formulare --- */

label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    color: var(--color-text);
    margin: 16px 0 6px;
}

label:first-child {
    margin-top: 0;
}

.hint {
    font-size: 12.5px;
    color: var(--color-text-muted);
    margin-top: 4px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 7px;
    background: var(--color-surface);
    color: var(--color-text);
    font-family: inherit;
    font-size: 14px;
}

input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--color-focus);
    outline-offset: 1px;
    border-color: var(--color-focus);
}

.field-error {
    color: var(--color-error-text);
    font-size: 12.5px;
    margin-top: 4px;
}

input.has-error, select.has-error {
    border-color: var(--color-error-border);
}

.form-actions {
    margin-top: 22px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.checkbox-line {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0;
}

.checkbox-line label {
    margin: 0;
    font-weight: 400;
}

.field-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.field-row .field-value {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 7px;
    background: var(--color-surface-alt);
    color: var(--color-text);
    font-size: 14px;
}

/* --- Buttons --- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 7px;
    border: 1px solid transparent;
    font-family: var(--font-sans);
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.3;
}

.btn-primary {
    background: var(--color-primary);
    color: var(--color-primary-contrast);
}
.btn-primary:hover {
    background: var(--color-primary-hover);
    color: var(--color-primary-contrast);
    text-decoration: none;
}

.btn-secondary {
    background: var(--color-surface);
    border-color: var(--color-border);
    color: var(--color-text);
}
.btn-secondary:hover {
    border-color: var(--teal);
    color: var(--teal);
    text-decoration: none;
}

.btn-danger {
    background: #ffffff;
    color: var(--color-error-text);
    border-color: var(--color-error-border);
}
.btn-danger:hover {
    background: var(--color-error-bg);
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- Meldungen / Banner --- */

.alert {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 13.5px;
}

.alert-success {
    background: var(--color-success-bg);
    color: var(--color-success-text);
    border-color: var(--color-success-border);
}
.alert-error {
    background: var(--color-error-bg);
    color: var(--color-error-text);
    border-color: var(--color-error-border);
}
.alert-warning {
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
    border-color: var(--color-warning-border);
}

/* --- Tabellen --- */

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

th {
    text-align: left;
    padding: 11px 14px;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 11.5px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

td {
    text-align: left;
    padding: 11px 14px;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: var(--color-surface-alt);
}

/* --- Fortschrittsbalken (Quota) --- */

.meter {
    background: var(--color-surface-alt);
    border-radius: 999px;
    height: 9px;
    overflow: hidden;
    border: 1px solid var(--color-border);
}

.meter__fill {
    height: 100%;
    background: var(--gold);
    border-radius: 999px 0 0 999px;
}
.meter__fill.is-warning {
    background: var(--olive);
}
.meter__fill.is-critical {
    background: var(--color-error-text);
}

.meter-row {
    display: flex;
    justify-content: space-between;
    font-size: 12.5px;
    color: var(--color-text-muted);
    margin-bottom: 6px;
}

/* --- Badges --- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    background: var(--color-surface-alt);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}
.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}
.badge-ok {
    background: var(--color-success-bg);
    color: var(--color-success-text);
    border-color: var(--color-success-border);
}
.badge-off {
    background: var(--color-surface-alt);
    color: var(--color-text-muted);
}

/* --- Stat-Kacheln (Dashboard) --- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.stat-tile {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 16px 18px;
}
.stat-tile__label {
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 6px;
}
.stat-tile__value {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 700;
    color: var(--color-text);
}

/* --- Produkt-Kacheln (Übersicht) --- */

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    /* Kein max-height/overflow hier - bei vielen Produkten waechst die Seite
       einfach nach unten, die Seite selbst scrollt ganz normal. */
}

.product-tile {
    display: block;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 20px 22px;
    text-decoration: none;
    color: var(--color-text);
    transition: border-color 0.12s ease, transform 0.12s ease;
}
.product-tile:hover {
    border-color: var(--gold);
    text-decoration: none;
    color: var(--color-text);
    transform: translateY(-1px);
}

.product-tile__name {
    font-family: var(--font-heading);
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 12px;
}

.product-tile__stat {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}
.product-tile__stat .muted {
    font-size: 13px;
    font-family: var(--font-sans);
    font-weight: 600;
}

.product-tile__meta {
    margin-top: 10px;
    font-size: 12.5px;
    color: var(--color-text-muted);
}

.product-tile__error {
    font-size: 13px;
    color: var(--color-error-text);
    font-weight: 600;
}

/* --- Ladezustand fuer asynchron nachgeladene Inhalte (z.B. Live-Daten aus
   einer Kunden-Nextcloud) - siehe /assets/js/async-load.js. Die Seite selbst
   laedt sofort, nur der Bereich mit externen Daten zeigt zunaechst dieses
   Skelett und wird per Hintergrund-Request ersetzt. --- */

.skeleton-block {
    border-radius: 8px;
    background: linear-gradient(100deg, var(--color-surface-alt) 30%, var(--color-border) 45%, var(--color-surface-alt) 60%);
    background-size: 300% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

@keyframes skeleton-shimmer {
    0% { background-position: 120% 0; }
    100% { background-position: -20% 0; }
}

.skeleton-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.skeleton-stat-grid .skeleton-block { height: 74px; }

.skeleton-card .skeleton-block { height: 16px; margin-bottom: 10px; }
.skeleton-card .skeleton-block:last-child { margin-bottom: 0; width: 60%; }

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--color-border);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spinner-spin 0.7s linear infinite;
    vertical-align: -3px;
    margin-right: 8px;
}
@keyframes spinner-spin {
    to { transform: rotate(360deg); }
}

.async-status {
    display: flex;
    align-items: center;
    color: var(--color-text-muted);
    font-size: 13.5px;
    padding: 4px 0 18px;
}

/* --- Auth: Hintergrund + Karte --- */

.auth-glow {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(680px 460px at 12% -8%, rgba(245, 166, 35, 0.16), transparent 60%),
        radial-gradient(620px 460px at 102% 20%, rgba(26, 143, 160, 0.14), transparent 60%);
}

.auth-shell {
    position: relative;
    z-index: 1;
}

.auth-card {
    animation: auth-rise 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes auth-rise {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --- Auth: Schritt-Indikator --- */

.auth-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 22px;
}

.auth-steps__dot {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 2px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-muted);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 12.5px;
    transition: border-color 0.25s, background 0.25s, color 0.25s;
}

.auth-steps__dot.is-active {
    border-color: var(--gold);
    background: var(--gold);
    color: var(--color-primary-contrast);
}

.auth-steps__dot.is-done {
    border-color: var(--teal);
    background: var(--teal);
    color: #ffffff;
}

.auth-steps__line {
    width: 34px;
    height: 2px;
    background: var(--color-border);
    transition: background 0.25s;
}

.auth-steps__line.is-done {
    background: var(--teal);
}

.auth-identity-static {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 9px 12px;
    margin-bottom: 18px;
    font-size: 13px;
    font-family: var(--font-mono);
    color: var(--color-text);
}

.auth-identity-static svg {
    flex-shrink: 0;
    color: var(--teal);
}

/* --- Auth: Login-Wizard (E-Mail -> Passwort) ---
 * Ohne .is-wizard (kein JS bzw. bevor auth-wizard.js initialisiert hat)
 * bleiben beide Felder normal untereinander sichtbar - [data-next]/
 * [data-back] sind dann ausgeblendet, der Login funktioniert wie ein
 * gewoehnliches einstufiges Formular. Erst mit .is-wizard wird daraus
 * ein horizontal gleitender Zwei-Panel-Schritt.
 */

.auth-wizard [data-next],
.auth-wizard [data-back] {
    display: none;
}

.auth-wizard.is-wizard [data-next],
.auth-wizard.is-wizard [data-back] {
    display: inline-flex;
}

.auth-wizard.is-wizard .auth-wizard__viewport {
    overflow: hidden;
}

.auth-wizard.is-wizard .auth-wizard__track {
    display: flex;
    width: 200%;
    transition: transform 0.45s cubic-bezier(0.65, 0, 0.35, 1);
}

.auth-wizard.is-wizard .auth-wizard__panel {
    flex: 0 0 50%;
    width: 50%;
    min-width: 0;
}

.auth-wizard.is-wizard[data-step="2"] .auth-wizard__track {
    transform: translateX(-50%);
}

.auth-wizard__identity {
    appearance: none;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin: 0 0 18px;
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 9px 12px;
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--color-text);
    cursor: pointer;
    text-align: left;
}

.auth-wizard__identity:hover {
    border-color: var(--teal);
}

.auth-wizard__identity svg {
    flex-shrink: 0;
    color: var(--color-text-muted);
}

.auth-wizard__identity [data-email-display] {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 12.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.auth-wizard__identity-edit {
    color: var(--teal);
    font-weight: 700;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* --- Hilfsklassen --- */

.muted { color: var(--color-text-muted); }
.text-mono { font-family: var(--font-mono); }
.mt-0 { margin-top: 0; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }
.stack > * + * { margin-top: 12px; }

.btn-sm {
    padding: 6px 12px;
    font-size: 12.5px;
}

.btn-group {
    display: inline-flex;
    gap: 6px;
    flex-wrap: wrap;
}

@media (max-width: 860px) {
    .app-shell { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }
    .sidebar__brand { border-bottom: none; border-right: 1px solid var(--color-border); }
    .sidebar__nav { display: flex; flex-wrap: wrap; padding: 8px; flex: 1; }
    .sidebar__section-label { display: none; }
    .sidebar__nav a { margin: 2px; }
    .sidebar__footer { border-top: none; border-left: 1px solid var(--color-border); }
    .main { padding: 20px; }
}
