/* ============================================================
   TarnShift – Mobile CSS v2
   Responsive Design + Bottom Navigation + Touch-Optimierung
   ============================================================ */

/* ---------- MOBILE BOTTOM NAV ---------- */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 500;
    background: rgba(10, 10, 15, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(139,92,246,0.2);
    padding: 0 0.25rem;
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
}

.mobile-bottom-nav .bn-items {
    display: flex;
    justify-content: space-around;
    align-items: center;
    max-width: 500px;
    margin: 0 auto;
}

.mobile-bottom-nav .bn-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px 6px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.6rem;
    font-weight: 500;
    transition: all 0.15s;
    position: relative;
    min-width: 48px;
    min-height: 44px; /* Touch target */
}

.mobile-bottom-nav .bn-item .bn-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.mobile-bottom-nav .bn-item.active {
    color: var(--accent-primary, #8b5cf6);
}

.mobile-bottom-nav .bn-item.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 2px;
    background: var(--accent-primary, #8b5cf6);
    border-radius: 0 0 2px 2px;
}

.mobile-bottom-nav .bn-item .bn-badge {
    position: absolute;
    top: 2px;
    right: calc(50% - 16px);
    background: #ef4444;
    color: white;
    font-size: 0.55rem;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 8px;
    min-width: 14px;
    text-align: center;
    line-height: 1.2;
}

/* ---------- PWA INSTALL HINT ---------- */
.pwa-install-hint {
    background: linear-gradient(135deg, rgba(139,92,246,0.15), rgba(99,102,241,0.1));
    border: 1px solid rgba(139,92,246,0.3);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin: 1rem 0;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}
.pwa-install-hint strong { color: var(--text-primary); }
.pwa-install-hint .install-btn {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.5rem 1.25rem;
    background: var(--accent-primary, #8b5cf6);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}
.pwa-install-hint .install-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139,92,246,0.4);
}

/* ---------- RESPONSIVE BREAKPOINTS ---------- */

@media (max-width: 768px) {
    /* Show bottom nav */
    .mobile-bottom-nav { display: block; }

    /* Add bottom padding for fixed nav */
    body { padding-bottom: 72px; }

    /* Hide desktop navbar links on mobile */
    .navbar .nav-links { display: none; }
    .navbar { height: 48px; padding: 0 0.75rem; }

    /* Portal nav: mobile = nur Logo + Logout */
    .portal-nav {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
        overflow: visible;
    }
    .portal-nav a.pn { display: none !important; }
    .portal-nav .nav-brand { display: flex !important; }

    /* Page container padding */
    .page-container { padding: 0 0.75rem 1rem; }

    /* Cards stack vertically */
    .portal-grid { grid-template-columns: 1fr; gap: 1rem; }

    /* Buttons: minimum touch target */
    .btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.9rem;
        min-height: 44px;
    }
    .btn-sm {
        padding: 0.5rem 0.875rem;
        font-size: 0.8rem;
        min-height: 38px;
    }

    /* Tables scroll */
    .table-wrapper {
        -webkit-overflow-scrolling: touch;
        overflow-x: auto;
        margin: 0 -0.75rem;
        padding: 0 0.75rem;
    }

    /* ====== ADMIN LAYOUT MOBILE ====== */
    .admin-layout { flex-direction: column; }
    .admin-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 0.5rem;
        display: flex;
        flex-wrap: nowrap;
        gap: 0.25rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        background: rgba(10,10,15,0.8);
        backdrop-filter: blur(10px);
        position: sticky;
        top: 48px;
        z-index: 40;
    }
    .admin-sidebar::-webkit-scrollbar { display: none; }
    .admin-sidebar .sidebar-section {
        padding: 6px 8px;
        font-size: 0.6rem;
        white-space: nowrap;
        flex-shrink: 0;
        display: none; /* Hide section headers on mobile */
    }
    .admin-sidebar .sidebar-link {
        display: inline-flex;
        padding: 8px 12px;
        font-size: 0.72rem;
        margin-bottom: 0;
        white-space: nowrap;
        flex-shrink: 0;
        min-height: 36px;
        align-items: center;
        border-radius: 8px;
    }
    .admin-sidebar .sidebar-link.active {
        background: var(--accent-primary, #8b5cf6);
        color: #fff;
    }
    .admin-main { padding: 0.75rem; }

    /* Admin action buttons full width */
    .admin-main .btn[onclick*="Modal"],
    .admin-main .btn[onclick*="modal"],
    .admin-main button[onclick*="new"],
    .admin-main button[onclick*="New"],
    .admin-main button[onclick*="neu"],
    .admin-main button[onclick*="Neu"] {
        width: 100%;
        justify-content: center;
    }

    /* Module grid on index */
    .module-grid { grid-template-columns: 1fr; }

    /* Notification grid */
    .notif-grid { grid-template-columns: 1fr 1fr; }

    /* Hero section compact */
    .hero-header { padding: 1.25rem 0.75rem 0.75rem; }
    .active-name { font-size: 1.1rem; }
    .hero-stats { gap: 0.75rem; }

    /* Location cards */
    .location-cards {
        grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
        gap: 0.5rem;
    }
    .loc-card-content { padding: 0.75rem 0.5rem; }
    .loc-logo-wrap { width: 36px; height: 36px; }
    .loc-name { font-size: 0.7rem; }

    /* ====== MODALS FULLSCREEN ON MOBILE ====== */
    .modal-overlay {
        align-items: flex-end !important;
    }
    .modal {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        border-radius: 16px 16px 0 0 !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
    }
    .modal-header {
        position: sticky;
        top: 0;
        z-index: 5;
        background: inherit;
        border-radius: 16px 16px 0 0;
    }

    /* Dienstplan mobile */
    .dp-woche-grid { display: none !important; }
    .dp-mobile-cards { display: block !important; }

    /* Chat mobile: sidebar = full channel list, chat = hidden until selected */
    .chat-layout {
        flex-direction: column;
        height: calc(100vh - 48px - 72px);
        overflow: hidden;
    }
    .chat-sidebar {
        width: 100%;
        height: 100%;
        max-height: none;
        overflow-y: auto;
        flex-direction: column;
        border-right: none;
        border-bottom: none;
        flex: 1;
        display: flex;
    }
    .chat-main {
        display: none !important;
        flex: 1;
        height: 100%;
    }
    /* When chat is active, hide sidebar, show main */
    .chat-layout.chat-active .chat-sidebar { display: none !important; }
    .chat-layout.chat-active .chat-main { display: flex !important; flex-direction: column; }

    /* Form inputs bigger on mobile */
    .form-input, .form-select, .form-textarea {
        font-size: 16px !important; /* Prevents iOS zoom */
        min-height: 44px;
        padding: 0.625rem 0.75rem;
    }

    /* Section headers */
    h2 { font-size: 1.15rem; }

    /* Portal card full span */
    .portal-card[style*="grid-column"] {
        grid-column: 1 / -1 !important;
    }
}

@media (max-width: 480px) {
    /* Extra small screens */
    .notif-grid { grid-template-columns: 1fr; }
    .portal-nav a.pn { font-size: 0.68rem; padding: 0.25rem 0.5rem; }
    .quick-actions { grid-template-columns: repeat(3, 1fr); }
    .hero-stat .stat-num { font-size: 1rem; }

    /* Bottom nav items smaller */
    .mobile-bottom-nav .bn-item { font-size: 0.55rem; min-width: 42px; }
    .mobile-bottom-nav .bn-item .bn-icon { font-size: 1.15rem; }
}

/* ---------- TABLET ---------- */
@media (min-width: 769px) and (max-width: 1024px) {
    .navbar { padding: 0 1.5rem; }
    .page-container { padding: 0 1.5rem 1.5rem; }
    .module-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- SAFE AREA (NOTCH) ---------- */
@supports (padding: env(safe-area-inset-bottom)) {
    .mobile-bottom-nav {
        padding-bottom: calc(env(safe-area-inset-bottom) + 4px);
    }
    @media (max-width: 768px) {
        body {
            padding-bottom: calc(72px + env(safe-area-inset-bottom));
        }
    }
}

/* ---------- ANIMATIONS ---------- */
@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
