/* Global Styles - Für alle Seiten */

:root {
    /* Farben */
    --primary-red: #CC0000;
    --bright-red: #FF0000;
    --dark-red: #990000;
    --orange: #FF6B00;
    --accent-orange: #FF6B00;

    --dark-bg: #0a0a0a;
    --bg-dark: #0a0a0a;
    --bg-darker: #050505;
    --card-bg: #1a1a1a;
    --card-bg-hover: #222222;
    --border-color: #333;
    --glass-bg: rgba(26, 26, 26, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);

    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-muted: #666;

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    --spacing-xxl: 4rem;

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow-red: 0 0 20px rgba(204, 0, 0, 0.3);

    /* Z-Index */
    --z-nav: 100;
    --z-modal: 1100;
    --z-tooltip: 10000;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--dark-bg);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

/* Section */
.section {
    padding: var(--spacing-xxl) 0;
}

/* Sidebar width variable */
:root { --sidebar-w: 240px; }

/* Body offset for sidebar */
body {
    padding-left: var(--sidebar-w);
}

/* ==================== GLOBAL SIDEBAR NAV ==================== */

/* Overlay (mobile only) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(2px);
    z-index: 999;
}
.sidebar-overlay.active { display: block; }

/* Outer nav element - the sidebar itself on desktop */
.global-nav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: rgba(12, 8, 8, 0.98);
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--border-color);
    z-index: var(--z-nav);
    display: flex;
    flex-direction: column;
}

/* Mobile top bar - hidden on desktop */
.sidebar-mobile-bar {
    display: none;
}

/* The scrollable sidebar panel */
.sidebar-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
}
.sidebar-panel::-webkit-scrollbar { display: none; }

/* Brand inside sidebar (desktop) */
.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.1rem;
    transition: var(--transition-fast);
}
.nav-brand:hover { color: var(--primary-red); }
.nav-brand img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.sidebar-brand {
    padding: 1.5rem 1.25rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    margin-bottom: 0.5rem;
}

/* Nav links container */
.sidebar-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0.5rem 0.75rem;
}

/* Individual nav links */
.nav-link {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.7rem 0.875rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    border-radius: 10px;
    transition: var(--transition-fast);
    position: relative;
}
.nav-link i {
    font-size: 0.95rem;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}
.nav-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}
.nav-link.active {
    color: var(--primary-red);
    background: rgba(204, 0, 0, 0.12);
    font-weight: 600;
}
.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 22%;
    bottom: 22%;
    width: 3px;
    background: var(--primary-red);
    border-radius: 0 3px 3px 0;
}
.nav-link.active::after { display: none; }

/* Auth section at bottom of sidebar */
.sidebar-auth {
    padding: 0.875rem 0.75rem;
    border-top: 1px solid rgba(255,255,255,0.06);
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.auth-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Account dropdown opens upward in sidebar */
.sidebar-auth #accountButton {
    position: relative;
}
.sidebar-auth .account-menu {
    bottom: calc(100% + 0.5rem);
    top: auto;
    left: 0;
    right: auto;
    min-width: 210px;
}

/* Mobile hamburger toggle */
.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: rgba(204, 0, 0, 0.15);
    border: 1px solid rgba(204, 0, 0, 0.35);
    border-radius: 8px;
    cursor: pointer;
    padding: 8px 10px;
}
.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition-fast);
}
.nav-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.nav-toggle.active span:nth-child(2) { opacity: 0; }
.nav-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(4px, -4px); }

/* ── Mobile (≤ 900px) ─────────────────────────────────────── */
@media (max-width: 900px) {
    :root { --sidebar-w: 0px; }

    body { padding-left: 0; padding-top: 60px; }

    /* Nav container becomes static so children can re-position themselves */
    .global-nav {
        position: static;
        width: auto;
        background: transparent;
        border-right: none;
        display: block;
        backdrop-filter: none;
    }

    /* Mobile top bar */
    .sidebar-mobile-bar {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: rgba(12, 8, 8, 0.98);
        backdrop-filter: blur(12px);
        border-bottom: 1px solid var(--border-color);
        z-index: 1001;
        align-items: center;
        justify-content: space-between;
        padding: 0 1rem;
    }
    .sidebar-mobile-bar .nav-brand { font-size: 1.05rem; }
    .sidebar-mobile-bar .nav-brand img { width: 32px; height: 32px; }

    /* Sidebar drawer */
    .sidebar-panel {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1002;
        background: rgba(12, 8, 8, 0.99);
        border-right: 1px solid var(--border-color);
    }
    .sidebar-panel.active { transform: translateX(0); }

    /* Show brand inside the drawer on mobile too */
    .sidebar-brand { display: flex; }

    /* Nav toggle visible on mobile */
    .nav-toggle { display: flex; }

    /* Auth buttons horizontal on mobile sidebar */
    .auth-buttons { flex-direction: row; }
    .sidebar-auth .account-menu {
        bottom: calc(100% + 0.5rem);
        top: auto;
        left: 0;
    }
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.75rem;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition-normal);
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-red), var(--bright-red));
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow-red);
}

.btn-secondary {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--card-bg-hover);
    border-color: var(--primary-red);
    color: var(--primary-red);
}

.btn-cta {
    background: white;
    color: var(--dark-bg);
    box-shadow: var(--shadow-md);
}

.btn-cta:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Footer */
.global-footer {
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    padding: var(--spacing-xxl) 0 var(--spacing-lg);
    margin-top: var(--spacing-xxl);
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-xl);
    margin-bottom: var(--spacing-lg);
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.footer-brand img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
}

.footer-brand h4 {
    font-size: 1.25rem;
    color: var(--primary-red);
}

.footer-col h5 {
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
    font-size: 1.1rem;
}

.footer-col p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.8;
}

.footer-links {
    list-style: none;
}

.footer-links li {
    margin-bottom: 0.5rem;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition-fast);
    font-size: 0.95rem;
}

.footer-links a:hover {
    color: var(--primary-red);
    padding-left: 5px;
}

.footer-socials {
    display: flex;
    gap: var(--spacing-sm);
}

.footer-socials a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 45px;
    height: 45px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    color: var(--text-secondary);
    transition: var(--transition-fast);
    font-size: 1.25rem;
}

.footer-socials a:hover {
    background: var(--primary-red);
    color: white;
    transform: translateY(-3px);
}

.footer-bottom {
    text-align: center;
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Loading Spinner */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xxl);
    gap: var(--spacing-md);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(204, 0, 0, 0.2);
    border-top-color: var(--primary-red);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-container p {
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 992px) {
    .footer-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }
}

@media (max-width: 768px) {
    html {
        font-size: 14px;
    }

    .section {
        padding: var(--spacing-xl) 0;
    }

    .btn {
        padding: 0.75rem 1.5rem;
        font-size: 0.95rem;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--dark-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-red);
}

/* Selection */
::selection {
    background: var(--primary-red);
    color: white;
}

/* ==================== AUTH SYSTEM ==================== */

/* Nav Auth Container (sidebar context) */
.nav-auth {
    display: flex;
    flex-direction: column;
}

/* Hide auth buttons until JS determines auth state - prevents flash */
#authButtons,
#accountButton {
    opacity: 0;
    transition: opacity 0.25s ease;
}

/* Once auth state is resolved, reveal with fade */
.nav-auth.auth-ready #authButtons,
.nav-auth.auth-ready #accountButton {
    opacity: 1;
}

/* Auth Buttons */
.btn-login,
.btn-register,
.btn-account {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    font-family: inherit;
}

.btn-login {
    background: transparent;
    border: 1px solid var(--primary-red);
    color: var(--primary-red);
}

.btn-login:hover {
    background: var(--primary-red);
    color: white;
}

.btn-register {
    background: var(--primary-red);
    color: white;
}

.btn-register:hover {
    background: var(--dark-red);
}

.btn-account {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    position: relative;
}

.btn-account:hover {
    background: var(--card-bg-hover);
    border-color: var(--primary-red);
}

/* Account Menu */
.account-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem 0;
    min-width: 200px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.account-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.account-menu a,
.account-menu button {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    font-size: 0.9rem;
}

.account-menu a:hover,
.account-menu button:hover {
    background: var(--primary-red);
    color: white;
}

.account-menu i {
    width: 1.2rem;
    text-align: center;
}

/* Auth Modals */
.auth-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: var(--z-modal);
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-modal.active {
    display: flex;
}

.auth-modal-content {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    max-width: 450px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.auth-modal-close:hover {
    background: var(--primary-red);
    color: white;
}

.auth-modal-content h2 {
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
}

.auth-modal-content h2 i {
    color: var(--primary-red);
}

.auth-modal .form-group {
    margin-bottom: 1.25rem;
}

.auth-modal .form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.auth-modal .form-group input {
    width: 100%;
    padding: 0.75rem;
    background: var(--dark-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
    font-family: inherit;
}

.auth-modal .form-group input:focus {
    outline: none;
    border-color: var(--primary-red);
    box-shadow: 0 0 0 3px rgba(204, 0, 0, 0.1);
}

.auth-modal .form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.btn-submit {
    width: 100%;
    padding: 0.875rem;
    background: var(--primary-red);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 1rem;
}

.btn-submit:hover {
    background: var(--dark-red);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(204, 0, 0, 0.3);
}

.auth-switch {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.auth-switch a {
    color: var(--primary-red);
    text-decoration: none;
    font-weight: 500;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* Passwort-Stärkeanzeige (Register-/Settings-Formular) */
.password-strength-meter {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.3rem;
    align-items: center;
}

.password-strength-meter .bars {
    flex: 1;
    display: flex;
    gap: 0.2rem;
}

.password-strength-meter .bar {
    height: 4px;
    flex: 1;
    background: var(--border-color);
    border-radius: 2px;
    transition: background 0.3s ease;
}

.password-strength-meter .label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.password-requirements {
    margin-top: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    list-style: none;
    padding: 0;
}

.password-requirements li {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.password-requirements li.met {
    color: #4caf50;
}

.password-requirements li i {
    width: 1em;
}

/* Trenner + Social-Login-Buttons in den Auth-Modals */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.25rem 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.google-signin-container {
    display: flex;
    justify-content: center;
    min-height: 40px;
}

/* Auth buttons full-width in sidebar */
.btn-login,
.btn-register,
.btn-account {
    width: 100%;
    justify-content: center;
}

@media (max-width: 900px) {
    .auth-modal-content {
        padding: 1.5rem;
        max-width: 100%;
    }
}

/* ==================== UI-FEINSCHLIFF ==================== */

/* Sichtbarer Fokus-Ring für Tastatur-Navigation (nur :focus-visible,
   damit Maus-Klicks keinen Ring hinterlassen) */
:focus-visible {
    outline: 2px solid var(--primary-red);
    outline-offset: 2px;
    border-radius: 4px;
}
.auth-modal .form-group input:focus-visible {
    outline: none; /* Inputs haben bereits eigenen Fokus-Stil */
}

/* Buttons: taktiles Feedback beim Klicken */
.btn:active,
.btn-login:active,
.btn-register:active,
.btn-account:active,
.btn-submit:active {
    transform: scale(0.97);
}

/* Ausgewogenere Zeilenumbrüche in Überschriften (progressive enhancement) */
h1, h2, h3 {
    text-wrap: balance;
}

/* Formular-Elemente in Markenfarbe (Checkboxen, Radios, Progress) */
:root {
    accent-color: var(--primary-red);
}

/* Kein Layout-Springen durch auftauchende Scrollbar */
html {
    scrollbar-gutter: stable;
}

/* Weiche Hover-Anhebung für Karten - einheitlich auf allen Seiten */
.blog-card,
.news-card {
    transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
}
.blog-card:hover,
.news-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg), 0 0 24px rgba(204, 0, 0, 0.12);
}

/* Bilder nie über ihren Container hinauslaufen lassen */
img {
    max-width: 100%;
}

/* Reduzierte Bewegung respektieren - deaktiviert dekorative Animationen */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
