/**
 * css/mobile.css – VOLLSTÄNDIGE VERSION
 * Mobile-spezifische Styles für Flohmarkt-Karte.de
 * Inkl. iPhone 16 Pro Fix (Dynamic Island, safe-area, 16px input)
 */

/* =============================================
   TABLET (max 1024px)
   ============================================= */

@media (max-width: 1024px) {
    .nav-container {
        grid-template-columns: auto auto;
        gap: 1rem;
        min-height: 70px;
        position: relative;
    }

    .header-auth {
        display: none;
    }

    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        font-size: 1.5rem;
        color: var(--text-primary);
        cursor: pointer;
        padding: 0.5rem;
        border-radius: var(--border-radius-sm);
        transition: var(--transition);
        min-width: 44px;
        min-height: 44px;
    }

    .mobile-menu-btn:hover,
    .mobile-menu-btn:focus {
        background: var(--bg-light);
        color: var(--primary-color);
    }
}

/* =============================================
   MOBILE SIDEBAR – iPhone 16 Pro optimiert
   ============================================= */

@media (max-width: 768px) {

    /* Sidebar von rechts */
    .mobile-sidebar {
        position: fixed;
        top: 0;
        right: -100%;
        width: min(300px, 85vw);
        height: 100%;
        height: 100dvh;
        background: var(--bg-white);
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
        z-index: 1100;
        transition: right 0.3s ease;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        display: flex;
        flex-direction: column;
        /* Safe Area für Dynamic Island / Notch */
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .mobile-sidebar.open {
        right: 0;
    }

    /* Sidebar Header (roter Streifen) */
    .sidebar-header {
        background: var(--primary-color);
        color: var(--text-white);
        padding: 1rem 1.25rem;
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-shrink: 0;
        min-height: 56px;
        overflow: hidden;         /* X kann nicht herausragen */
    }

    .sidebar-header .logo-text {
        font-size: 1.1rem;
        font-weight: 700;
        color: white;
    }

    .sidebar-close {
        background: rgba(255, 255, 255, 0.15);
        border: none;
        color: white;
        font-size: 1.25rem;
        cursor: pointer;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.2s;
        flex-shrink: 0;
        margin-right: 0;          /* kein negativer Overflow */
        position: relative;       /* bleibt im Sidebar-Bereich */
        right: 0;
    }

    .sidebar-close:hover,
    .sidebar-close:focus {
        background: rgba(255, 255, 255, 0.3);
    }

    /* Sidebar Inhalt */
    .sidebar-content {
        flex: 1;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
    }

    /* Login-Bereich in der Sidebar */
    .mobile-login-section {
        padding: 1.25rem;
        background: var(--bg-light);
        border-bottom: 1px solid var(--border-light);
        flex-shrink: 0;
    }

    .mobile-login-title {
        font-size: 0.95rem;
        font-weight: 600;
        color: var(--text-primary);
        margin: 0 0 0.875rem 0;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .mobile-login-form {
        display: flex;
        flex-direction: column;
        gap: 0.625rem;
    }

    .mobile-login-form input {
        padding: 0.75rem 1rem;
        border: 1.5px solid var(--border-color);
        border-radius: var(--border-radius);
        font-size: 1rem;           /* 16px – verhindert iOS Auto-Zoom */
        background: var(--bg-white);
        color: var(--text-primary);
        width: 100%;
        box-sizing: border-box;
        transition: border-color 0.2s;
        -webkit-appearance: none;
    }

    .mobile-login-form input:focus {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
        outline: none;
    }

    .mobile-login-form .btn {
        padding: 0.8rem 1rem;
        background: var(--primary-color);
        color: white;
        border: none;
        border-radius: var(--border-radius);
        font-size: 1rem;
        font-weight: 600;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        transition: background 0.2s;
        -webkit-appearance: none;
    }

    .mobile-login-form .btn:active {
        background: var(--primary-dark);
    }

    /* Alert in der Sidebar */
    .mobile-alert {
        margin-top: 0.75rem;
        padding: 0.75rem 1rem;
        border-radius: var(--border-radius);
        font-size: 0.875rem;
        line-height: 1.4;
        display: none;
    }

    .mobile-alert.show    { display: block; }

    .mobile-alert.success {
        background: rgba(39, 174, 96, 0.1);
        color: var(--success-color);
        border: 1px solid rgba(39, 174, 96, 0.3);
    }

    .mobile-alert.error {
        background: rgba(231, 76, 60, 0.1);
        color: var(--danger-color);
        border: 1px solid rgba(231, 76, 60, 0.3);
    }

    /* Navigationslinks */
    .mobile-nav-menu {
        list-style: none;
        padding: 0;
        margin: 0;
        flex: 1;
    }

    .mobile-nav-menu li {
        border-bottom: 1px solid var(--border-light);
    }

    .mobile-nav-menu a {
        display: flex;
        align-items: center;
        gap: 0.875rem;
        padding: 1rem 1.25rem;
        text-decoration: none;
        color: var(--text-primary);
        font-size: 1rem;
        font-weight: 500;
        transition: background 0.15s, color 0.15s;
        min-height: 52px;
    }

    .mobile-nav-menu a:hover,
    .mobile-nav-menu a:focus {
        background: var(--bg-light);
        color: var(--primary-color);
    }

    .mobile-nav-menu a:active {
        background: rgba(231, 76, 60, 0.08);
    }

    .mobile-nav-menu i {
        width: 20px;
        text-align: center;
        color: var(--text-secondary);
        font-size: 0.95rem;
        flex-shrink: 0;
    }

    /* Overlay hinter Sidebar */
    .mobile-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1099;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-overlay.open {
        opacity: 1;
        visibility: visible;
    }

    /* Header-Auth und Desktop-Nav ausblenden */
    .header-auth    { display: none !important; }
    .nav-menu       { display: none !important; }

    /* Header-Alert auf Mobile deaktivieren */
    .header-alert   { display: none !important; }

    /* Hamburger Button */
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        font-size: 1.5rem;
        color: var(--text-primary);
        cursor: pointer;
        padding: 0.5rem;
        border-radius: var(--border-radius-sm);
        min-width: 44px;
        min-height: 44px;
        transition: background 0.2s, color 0.2s;
    }

    .mobile-menu-btn:hover,
    .mobile-menu-btn:focus {
        background: var(--bg-light);
        color: var(--primary-color);
    }

    /* ── Seiteninhalt ── */
    .hero-content {
        grid-template-columns: 1fr;
        gap: 2rem;
        text-align: center;
        padding: 0 1rem;
    }

    .hero-text h1 {
        font-size: 2.2rem;
        line-height: 1.2;
    }

    .hero-text .subtitle {
        font-size: 1rem;
    }

    .features-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .feature-card {
        padding: 2rem;
    }

    .demo-container {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .demo-overlay {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        margin-top: 1rem;
        pointer-events: auto;
    }

    .demo-map {
        height: 300px;
    }

    .contact-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 2rem;
        text-align: center;
    }

    .pricing-card.featured {
        transform: none;
    }

    .notice-main {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        text-align: center;
        padding: 1.5rem;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .registration-form {
        padding: 2rem;
    }

    .registration-header {
        padding: 1.5rem;
    }

    .section-header h2 {
        font-size: 2rem;
    }

    .container {
        padding: 0 1rem;
    }

    /* Form-Alerts */
    .form-alert {
        font-size: 0.9rem;
        padding: 0.875rem;
    }
}

/* =============================================
   KLEINE SMARTPHONES (max 480px)
   ============================================= */

@media (max-width: 480px) {
    .nav-container {
        padding: 0 1rem;
    }

    .hero {
        padding: 100px 0 40px;
    }

    .hero-text h1 {
        font-size: 1.8rem;
    }

    .hero-text .subtitle {
        font-size: 0.95rem;
    }

    .section-header h2 {
        font-size: 1.75rem;
    }

    .feature-card {
        padding: 1.5rem;
    }

    .demo-map {
        height: 250px;
    }

    .mobile-sidebar {
        width: 100vw;              /* Auf sehr kleinen Screens volle Breite */
    }

    .mobile-login-section {
        padding: 1rem;
    }

    .registration-form {
        padding: 1.5rem;
    }

    .registration-footer {
        padding: 1rem 1.5rem;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 0.75rem;
        font-size: 1rem;           /* verhindert iOS Auto-Zoom überall */
    }

    .btn-register {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }

    .notice-main {
        padding: 1rem;
    }
}

/* =============================================
   TABLET PORTRAIT (769px – 1024px)
   ============================================= */

@media (min-width: 769px) and (max-width: 1024px) {
    .nav-container {
        grid-template-columns: auto 1fr auto;
        gap: 1rem;
        min-height: 70px;
    }

    .header-auth {
        display: block;
        justify-self: end;
        min-width: 320px;
        width: 320px;
    }

    .header-login-fields {
        gap: 0.4rem;
    }

    .header-login-fields input {
        width: 110px;
        min-width: 110px;
        max-width: 110px;
        font-size: 0.85rem;
        padding: 0.4rem 0.6rem;
    }

    .btn-header-login {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
        min-width: 90px;
    }

    .btn-header-login .btn-text {
        display: none;
    }

    .mobile-menu-btn {
        display: none;
    }

    .nav-menu {
        display: flex;
        gap: 1.5rem;
    }

    .nav-menu a {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }

    .header-alert {
        right: 1rem;
        left: auto;
        min-width: 280px;
        max-width: 350px;
    }

    .hero {
        padding: 110px 0 50px;
    }

    .hero-content {
        grid-template-columns: 1fr 1fr;
        gap: 3rem;
    }

    .hero-text h1 {
        font-size: 2.8rem;
    }

    .demo-card {
        max-width: 350px;
    }

    .demo-map-mini {
        height: 220px;
    }

    .features-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }

    .demo-container {
        grid-template-columns: 1fr 350px;
        gap: 2.5rem;
    }

    .demo-map {
        height: 350px;
    }

    .contact-content {
        grid-template-columns: 1fr 1fr;
        gap: 3rem;
    }

    .footer-content {
        grid-template-columns: 2fr 1fr 1fr;
        gap: 1.5rem;
    }

    .registration-container-simple {
        max-width: 550px;
    }

    .registration-form {
        padding: 2.25rem;
    }
}

/* Tablet Portrait kompakter (769–900px) */
@media (min-width: 769px) and (max-width: 900px) {
    .nav-menu {
        gap: 1rem;
    }

    .nav-menu a {
        padding: 0.3rem 0.6rem;
        font-size: 0.85rem;
    }

    .header-auth {
        min-width: 300px;
        width: 300px;
    }

    .header-login-fields input {
        width: 95px;
        min-width: 95px;
        max-width: 95px;
    }

    .btn-header-login {
        min-width: 80px;
    }
}

/* Tablet Landscape (901–1024px) */
@media (min-width: 901px) and (max-width: 1024px) {
    .header-auth {
        min-width: 340px;
        width: 340px;
    }

    .header-login-fields input {
        width: 115px;
        min-width: 115px;
        max-width: 115px;
    }

    .nav-menu {
        gap: 1.8rem;
    }

    .btn-header-login {
        min-width: 95px;
    }
}

/* iPad Mini */
@media (min-width: 769px) and (max-width: 820px) {
    .nav-container {
        padding: 0 1.5rem;
    }

    .logo {
        font-size: 1.3rem;
    }

    .logo i {
        font-size: 1.5rem;
    }
}

/* =============================================
   COOKIE INFO BUTTON
   ============================================= */

.cookie-info-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: var(--text-primary);
    color: white;
    border: none;
    padding: 0;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-family: inherit;
    line-height: 1;
}

.cookie-info-btn.show {
    display: flex !important;
}

.cookie-info-btn:hover,
.cookie-info-btn:focus {
    background: #34495e;
    transform: scale(1.1);
}

.cookie-info-btn:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

.cookie-info-btn > * {
    margin: 0;
    padding: 0;
    line-height: 1;
}

@media (max-width: 768px) {
    .cookie-info-btn {
        bottom: 15px;
        left: 15px;
        width: 45px;
        height: 45px;
        font-size: 1rem;
    }
}

/* =============================================
   ACCESSIBILITY & REDUCED MOTION
   ============================================= */

@media (prefers-contrast: high) and (max-width: 768px) {
    .mobile-sidebar {
        border: 2px solid var(--text-primary);
    }

    .mobile-login-form input {
        border-width: 2px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mobile-sidebar,
    .mobile-overlay,
    .mobile-login-form .btn,
    .cookie-info-btn {
        transition: none;
        animation: none;
    }

    .cookie-info-btn:hover {
        transform: none;
    }
}