/* =====================================================================
   Filme-App — Design-System "iOS Native Light"
   Reines CSS, keine Frameworks. Mobile-first, Desktop nachrangig.
   Design-Tokens/Grundkomponenten 1:1 aus der Fitness-App übernommen, damit
   sich alle lixapps-Apps optisch vertraut anfühlen (kein gemeinsamer Code
   über die apps/-Grenze hinweg — jede App hat ihre eigene Kopie).
   ===================================================================== */

:root {
    --bg: #F2F2F7;
    --card: #FFFFFF;
    --accent: #007AFF;
    --accent-dark: #0062CC;
    --text: #000000;
    --text-2: #8E8E93;
    --sep: #C6C6C8;
    --sep-light: #E5E5EA;
    --red: #FF3B30;
    --red-bg: #FFEDED;
    --green: #34C759;
    --green-bg: #E9FBEF;
    --orange: #FF9500;
    --radius: 10px;
    --radius-lg: 16px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --header-h: 52px;
    --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: contain;
}

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

#editCategoryCard, #editMovieCard, #movieManagementList, #categoryManagementList,
#editTagCard, #tagManagementList, #editUserCard, #editInviteCard, #userManagementList {
    scroll-margin-top: calc(var(--header-h) + var(--safe-top) + 12px);
}

/* --- App-Header (kein Burger-Menü — s. Anforderung: normale Nutzer sehen
   keine Navigation außer Einstellungen/Abmelden) ------------------------- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 8px;
    height: calc(var(--header-h) + var(--safe-top));
    padding: var(--safe-top) 12px 0;
    background: rgba(242, 242, 247, 0.92);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--sep-light);
}
.app-header-title { flex: 1; font-size: 17px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-header-right { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.app-header-user { font-size: 13px; color: var(--text-2); margin-right: 4px; }

/* --- Main / Layout --------------------------------------------------------- */
.app-main {
    padding: 16px 16px calc(24px + var(--safe-bottom));
    max-width: 640px;
    margin: 0 auto;
}

/* --- Section-Header --------------------------------------------------------- */
.section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin: 20px 0 10px;
}
.section-header:first-child { margin-top: 4px; }
.section-title { font-size: 20px; font-weight: 700; }
.section-subtitle { font-size: 13px; color: var(--text-2); margin-top: 2px; }

/* --- Karten --------------------------------------------------------------- */
.card { background: var(--card); border-radius: var(--radius-lg); padding: 16px; margin-bottom: 12px; }

/* --- Suche + Filter-Chips (Startseite) -------------------------------------- */
.list-search-input {
    display: block;
    width: 100%;
    font-size: 16px; /* verhindert Auto-Zoom bei Fokus auf iOS Safari */
    padding: 12px 14px;
    border: 1px solid var(--sep);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--text);
    appearance: none;
    -webkit-appearance: none;
    margin-bottom: 10px;
}
.list-search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15); }

.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filter-chip {
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 7px 14px;
    border: none;
    border-radius: 999px;
    background: var(--card);
    color: var(--text-2);
    cursor: pointer;
}
.filter-chip.is-active { background: var(--accent); color: #fff; }

/* --- Filmliste --------------------------------------------------------- */
.list { background: var(--card); border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 12px; }
.list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 13px 16px;
    min-height: 44px;
    border-bottom: 1px solid var(--sep-light);
}
.list-row:last-child { border-bottom: none; }
.list > form .list-row { border-bottom: 1px solid var(--sep-light); }
.list > form:last-child .list-row { border-bottom: none; }
.list-row-title { font-size: 16px; font-weight: 500; }
.list-row-subtitle { font-size: 13px; color: var(--text-2); margin-top: 1px; }
.list-row-actions { display: flex; gap: 8px; flex-shrink: 0; }
.list-empty { padding: 32px 16px; text-align: center; color: var(--text-2); font-size: 14px; }

.movie-row-title { font-size: 17px; font-weight: 700; }
.movie-row-meta { font-size: 13px; color: var(--text-2); margin-top: 3px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.movie-row-duration { font-variant-numeric: tabular-nums; }

.badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 100px;
    vertical-align: middle;
}
.badge-success { background: var(--green-bg); color: #248A3D; }
.badge-pending { background: rgba(255, 149, 0, 0.15); color: var(--orange); }
.badge-admin { background: rgba(0, 122, 255, 0.12); color: var(--accent); }
.badge-4k { background: #1C1C1E; color: #fff; }
.badge-3d { background: rgba(0, 122, 255, 0.12); color: var(--accent); }
.badge-tag { background: rgba(0, 122, 255, 0.12); color: var(--accent); }

/* --- Checkbox-Zeile (Filter-Auswahl im Film-Formular) ----------------------- */
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    padding: 6px 0;
    color: var(--text);
}

/* --- Buttons --------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 20px;
    border-radius: var(--radius);
    border: none;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { background: var(--accent-dark); }
.btn-secondary { background: rgba(0, 122, 255, 0.1); color: var(--accent); }
.btn-secondary:active { background: rgba(0, 122, 255, 0.2); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-danger:active { background: #FFDADA; }
.btn-plain { background: none; color: var(--accent); padding: 0 8px; min-height: 36px; font-weight: 500; }
.btn-icon { width: 36px; height: 36px; min-height: 0; padding: 0; border-radius: 8px; }
.btn:disabled { opacity: 0.4; }

/* --- Formulare --------------------------------------------------------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
.field input[type="text"],
.field input[type="number"],
.field input[type="password"],
.field input[type="email"],
.field select {
    width: 100%;
    font-size: 16px;
    padding: 12px 14px;
    border: 1px solid var(--sep);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--text);
    appearance: none;
    -webkit-appearance: none;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15); }
.field-hint { font-size: 12px; color: var(--text-2); margin-top: 4px; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

/* --- Toggle-Schalter --------------------------------------------------- */
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex-shrink: 0; }
.switch input[type="checkbox"] { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track { position: absolute; inset: 0; background: var(--sep-light); border-radius: 100px; transition: background 0.2s ease; pointer-events: none; }
.switch-track::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::before { transform: translateX(18px); }

/* --- Flash / Toast --------------------------------------------------------- */
.flash { padding: 12px 14px; border-radius: var(--radius); font-size: 14px; margin-bottom: 14px; }
.flash-error { background: var(--red-bg); color: var(--red); }
.flash-success { background: var(--green-bg); color: #248A3D; }
.flash-info { background: rgba(0, 122, 255, 0.1); color: var(--accent-dark); }

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(24px + var(--safe-bottom));
    transform: translate(-50%, 20px);
    background: rgba(28, 28, 30, 0.92);
    color: #fff;
    padding: 12px 20px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 50;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* --- Login-Formular ------------------------------------------------------ */
.login-body { background: var(--bg); }
.login-wrap { max-width: 360px; margin: 0 auto; padding: calc(var(--safe-top) + 64px) 20px 40px; text-align: center; }
.login-logo { font-size: 44px; margin-bottom: 8px; }
.login-title { font-size: 26px; font-weight: 700; }
.login-subtitle { font-size: 14px; color: var(--text-2); margin-top: 4px; margin-bottom: 24px; }
.login-form { text-align: left; }
.login-form label { display: block; font-size: 13px; color: var(--text-2); margin: 14px 0 6px; font-weight: 500; }
.login-form input { width: 100%; font-size: 16px; padding: 13px 14px; border: 1px solid var(--sep); border-radius: var(--radius); background: var(--card); }
.login-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15); }
.login-form .btn { margin-top: 22px; }
.login-invite-link { display: block; margin-top: 14px; font-size: 12px; color: var(--text-2); text-align: center; text-decoration: none; }
.login-invite-link:hover { color: var(--accent); text-decoration: underline; }

.select-on-click { cursor: pointer; }

/* --- Utility --------------------------------------------------------------- */
.text-secondary { color: var(--text-2); }
.text-center { text-align: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }

/* --- Desktop (nachrangig, aber vorhanden) --------------------------------- */
@media (min-width: 768px) {
    .app-main { padding: 24px 16px 40px; }
    .card, .list { margin-bottom: 16px; }
}
