/* ==========================================================================
   YtPodcast – Design-System im Apple/iOS-Stil
   Light & Dark über prefers-color-scheme, Safe-Areas fürs iPhone,
   SF-Systemschrift, weiche „squircle"-Radien, translucent Nav-Bars.
   ========================================================================== */

:root {
    /* Farb-Token (Light) – angelehnt an iOS System Colors */
    --bg: #f2f2f7;
    --surface: #ffffff;
    --surface-2: #f2f2f7;
    --surface-hover: #f7f7fa;
    --label: #1c1c1e;
    --label-2: rgba(60, 60, 67, 0.6);
    --label-3: rgba(60, 60, 67, 0.3);
    --separator: rgba(60, 60, 67, 0.16);
    --tint: #5856d6;          /* systemIndigo */
    --tint-soft: rgba(88, 86, 214, 0.12);
    --green: #34c759;
    --red: #ff3b30;
    --orange: #ff9500;
    --blue: #007aff;

    --nav-blur: saturate(180%) blur(20px);
    --nav-bg: rgba(249, 249, 249, 0.8);

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

    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.06);

    --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
            "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;

    --tab-h: 50px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #000000;
        --surface: #1c1c1e;
        --surface-2: #2c2c2e;
        --surface-hover: #2c2c2e;
        --label: #ffffff;
        --label-2: rgba(235, 235, 245, 0.6);
        --label-3: rgba(235, 235, 245, 0.3);
        --separator: rgba(84, 84, 88, 0.6);
        --tint: #5e5ce6;
        --tint-soft: rgba(94, 92, 230, 0.22);
        --green: #30d158;
        --red: #ff453a;
        --orange: #ff9f0a;
        --blue: #0a84ff;
        --nav-bg: rgba(30, 30, 30, 0.7);
        --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4);
    }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--label);
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    /* iOS: nicht überscrollen/gummibandeln über die Ränder hinaus */
    overscroll-behavior-y: none;
}

h1, h2, h3, p { margin: 0; }
a { color: var(--tint); text-decoration: none; }
button { font-family: inherit; }

/* ---------- App-Shell ---------------------------------------------------- */

.app {
    min-height: 100vh;
    min-height: 100dvh;
    padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
}

/* Translucent Top-Bar mit iOS-Blur */
.nav-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--nav-bg);
    -webkit-backdrop-filter: var(--nav-blur);
    backdrop-filter: var(--nav-blur);
    border-bottom: 0.5px solid var(--separator);
    padding-top: env(safe-area-inset-top);
}

.nav-inner {
    height: 44px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 max(16px, env(safe-area-inset-left)) 0 max(16px, env(safe-area-inset-right));
    max-width: 780px;
    margin: 0 auto;
}

.nav-brand {
    font-weight: 600;
    font-size: 17px;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--label);
}
.nav-brand .dot {
    width: 22px; height: 22px; border-radius: 7px;
    background: linear-gradient(160deg, #6f6cf0, #a45ce0 55%, #d05ac8);
    display: inline-grid; place-items: center;
    box-shadow: 0 2px 6px rgba(120, 80, 220, 0.4);
}
.nav-brand .dot svg { width: 14px; height: 14px; color: #fff; }

.nav-links { margin-left: auto; display: flex; gap: 4px; }
.nav-links a {
    color: var(--label-2);
    font-size: 15px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 999px;
}
.nav-links a.active { color: var(--tint); background: var(--tint-soft); }

.nav-logout { margin-left: 8px; display: flex; }
.nav-logout .btn-icon { color: var(--label-2); }

/* ---------- Login ---------------------------------------------------------- */

.login-wrap {
    min-height: 100dvh;
    display: grid; place-items: center;
    padding: 24px max(16px, env(safe-area-inset-left)) calc(24px + env(safe-area-inset-bottom));
}
.login-card {
    width: 100%; max-width: 360px;
    background: var(--surface); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card); padding: 32px 24px;
    display: flex; flex-direction: column; gap: 12px; text-align: center;
}
.login-logo {
    width: 56px; height: 56px; margin: 0 auto 4px; border-radius: 16px;
    display: grid; place-items: center; color: #fff;
    background: linear-gradient(160deg, #6f6cf0, #a45ce0 55%, #d05ac8);
    box-shadow: 0 6px 18px rgba(120, 80, 220, 0.4);
}
.login-logo svg { width: 30px; height: 30px; }
.login-card h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.login-sub { color: var(--label-2); font-size: 14px; margin-bottom: 8px; }
.login-card .field { text-align: left; }
.login-card .btn { margin-top: 6px; }
.login-error { color: var(--red); font-size: 14px; }

/* ---------- Content ------------------------------------------------------ */

.content {
    max-width: 780px;
    margin: 0 auto;
    padding: 8px max(16px, env(safe-area-inset-left)) 32px max(16px, env(safe-area-inset-right));
}

.large-title {
    font-size: 34px;
    font-weight: 700;
    letter-spacing: -0.03em;
    padding: 12px 4px 4px;
}
.subtitle { color: var(--label-2); font-size: 15px; padding: 0 4px 12px; }

.section-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--label-2);
    padding: 20px 4px 8px;
}

/* ---------- Cards & Listen ------------------------------------------------ */

.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.list { display: flex; flex-direction: column; }
.row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    position: relative;
}
.row + .row::before {
    content: "";
    position: absolute; top: 0; left: 16px; right: 0;
    height: 0.5px; background: var(--separator);
}
.row-main { min-width: 0; flex: 1; }
.row-title {
    font-size: 16px; font-weight: 500; letter-spacing: -0.01em;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
}
.row-sub {
    color: var(--label-2); font-size: 13px; margin-top: 2px;
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}

.thumb {
    width: 44px; height: 44px; border-radius: 10px; object-fit: cover;
    background: var(--surface-2); flex-shrink: 0;
}
.thumb-fallback {
    display: grid; place-items: center;
    color: #fff; font-weight: 600; font-size: 18px;
    background: linear-gradient(160deg, #6f6cf0, #d05ac8);
}

/* ---------- Status-Pills -------------------------------------------------- */

.pill {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 12px; font-weight: 600; letter-spacing: 0.01em;
    padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.new      { color: var(--blue);   background: color-mix(in srgb, var(--blue) 14%, transparent); }
.pill.approved { color: var(--tint);   background: var(--tint-soft); }
.pill.downloading { color: var(--orange); background: color-mix(in srgb, var(--orange) 16%, transparent); }
.pill.downloaded  { color: var(--green);  background: color-mix(in srgb, var(--green) 16%, transparent); }
.pill.rejected { color: var(--label-2); background: color-mix(in srgb, var(--label-2) 14%, transparent); }
.pill.failed   { color: var(--red);    background: color-mix(in srgb, var(--red) 14%, transparent); }

/* ---------- Buttons ------------------------------------------------------- */

.btn {
    -webkit-appearance: none; appearance: none; border: none; cursor: pointer;
    font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
    padding: 10px 16px; border-radius: var(--radius-sm);
    background: var(--surface-2); color: var(--label);
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    transition: transform 0.08s ease, opacity 0.15s ease, background 0.15s ease;
    -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary { background: var(--tint); color: #fff; }
.btn-green   { background: var(--green); color: #fff; }
.btn-tinted  { background: var(--tint-soft); color: var(--tint); }
.btn-plain   { background: transparent; color: var(--tint); padding-left: 8px; padding-right: 8px; }
.btn-danger  { background: transparent; color: var(--red); }
.btn-block   { width: 100%; }
.btn-sm { font-size: 14px; padding: 7px 12px; }
.btn-icon {
    padding: 8px; width: 36px; height: 36px; border-radius: 10px;
    background: transparent; color: var(--label-2);
}
.btn-icon svg { width: 20px; height: 20px; }

.row-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }

/* ---------- Segmented Control (Filter) ----------------------------------- */

.segmented {
    display: flex; gap: 2px; padding: 2px;
    background: var(--surface-2); border-radius: 10px;
    margin: 4px 0 16px; overflow-x: auto; scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented button {
    flex: 1; white-space: nowrap;
    border: none; background: transparent; cursor: pointer;
    font-size: 13px; font-weight: 600; color: var(--label);
    padding: 6px 12px; border-radius: 8px;
    transition: background 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}
.segmented button.active {
    background: var(--surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
@media (prefers-color-scheme: dark) {
    .segmented button.active { background: #636366; }
}

/* ---------- Formularfelder ------------------------------------------------ */

.field { display: flex; flex-direction: column; gap: 6px; }
.input {
    -webkit-appearance: none; appearance: none;
    font-family: inherit; font-size: 16px; /* 16px verhindert iOS-Zoom beim Fokus */
    color: var(--label); background: var(--surface);
    border: 0.5px solid var(--separator); border-radius: var(--radius-sm);
    padding: 12px 14px; width: 100%;
    transition: border-color 0.15s ease;
}
.input::placeholder { color: var(--label-3); }
.input:focus { outline: none; border-color: var(--tint); }

/* ---------- Leerzustand & Hinweise --------------------------------------- */

.empty {
    text-align: center; padding: 56px 24px; color: var(--label-2);
}
.empty .icon {
    width: 56px; height: 56px; margin: 0 auto 14px; color: var(--label-3);
}
.empty .icon svg { width: 100%; height: 100%; }
.empty h3 { font-size: 18px; font-weight: 600; color: var(--label); margin-bottom: 4px; }

.note {
    font-size: 14px;
    background: var(--tint-soft); color: var(--tint);
    padding: 10px 14px; border-radius: var(--radius-sm); margin: 4px 0;
}

/* ---------- Spinner ------------------------------------------------------- */

.spinner {
    width: 18px; height: 18px; border-radius: 50%;
    border: 2px solid var(--label-3); border-top-color: var(--tint);
    animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Bottom Tab-Bar (iOS) ----------------------------------------- */

.tab-bar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
    display: flex; justify-content: space-around; align-items: stretch;
    background: var(--nav-bg);
    -webkit-backdrop-filter: var(--nav-blur);
    backdrop-filter: var(--nav-blur);
    border-top: 0.5px solid var(--separator);
    padding-bottom: env(safe-area-inset-bottom);
}
.tab-item {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 2px; height: var(--tab-h);
    color: var(--label-2); font-size: 10px; font-weight: 500;
    -webkit-tap-highlight-color: transparent;
}
.tab-item svg { width: 26px; height: 26px; }
.tab-item.active { color: var(--tint); }

/* Auf großen Screens: Tabs verstecken, Nav oben nutzen */
@media (min-width: 768px) {
    .app { padding-bottom: 0; }
    .tab-bar { display: none; }
}
@media (max-width: 767px) {
    .nav-links { display: none; }
    .nav-logout { margin-left: auto; }
}

/* ---------- Utilities ----------------------------------------------------- */

.stack { display: flex; flex-direction: column; gap: 12px; }
.muted { color: var(--label-2); }
.grow { flex: 1; }
.mono { font-variant-numeric: tabular-nums; }

/* Blazor-Fehlerbanner dezent im Dark/Light-Look */
#blazor-error-ui {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;
    display: none; padding: 12px 20px;
    background: var(--red); color: #fff; font-size: 14px;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.2);
}
#blazor-error-ui .reload { color: #fff; text-decoration: underline; }
#blazor-error-ui .dismiss { cursor: pointer; float: right; }
