/* =========================================================================
   TEAMWORKK - RESPONSIVE STYLES (Mobile-First)
   Version: 1.8.0 - Section-Abstände 8px auf Mobile (v875)
   ========================================================================= */

/* =========================================================================
   GLOBAL
   ========================================================================= */

/* Breiterer Content-Bereich */
.max-w-7xl {
    max-width: 98rem !important;
}

@media (min-width: 768px) {
    .md\:px-8 {
        margin-top: -10px;
    }
}

* {
    box-sizing: border-box;
}

body, html {
    overflow-x: hidden;
    width: 100%;
}

/* Upload Button - einheitliches Styling */
.upload-button {
    display: inline-block;
    background: rgb(66, 92, 151);
    color: white;
    padding: 10px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: transform 0.2s, box-shadow 0.2s;
}

.upload-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(66, 92, 151, 0.3);
}

/* =========================================================================
   SMARTPHONES PORTRAIT (< 640px)
   ========================================================================= */
@media (max-width: 640px) {
    /* KRITISCH: Sidebar-Padding entfernen auf Mobile! */
    .md\:pl-64 {
        padding-left: 0 !important;
    }
    
    /* Container - GLEICHMÄSSIGES Padding links und rechts */
    .max-w-7xl,
    main .max-w-7xl,
    .mx-auto {
        padding-left: 16px !important;
        padding-right: 16px !important;
        margin-left: -16px;
        margin-right: -16px;
    }
    
    /* Dashboard Cards - Kompaktere Darstellung - NICHT Toggles! */
    .dashboard-card,
    .bg-white:not(.w-11):not(.h-6),
    [class*="bg-"]:not(.login-page-background):not(.w-11):not(.h-6):not(.rounded-full) {
        padding: 12px !important;
        margin-bottom: 12px !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    /* =========================================================================
       MOBILE SECTION ABSTÄNDE - KOMPAKT (v875)
       ========================================================================= */
    /* Alle space-y Klassen auf 8px reduzieren */
    .space-y-4 > * + * {
        margin-top: 8px !important;
    }
    .space-y-6 > * + * {
        margin-top: 8px !important;
    }
    /* Sortable Container und Dashboard Grid */
    #sortable-tasks-container,
    #dashboard-sections-grid {
        gap: 8px !important;
    }
    #sortable-tasks-container > * + *,
    #dashboard-sections-grid > * + * {
        margin-top: 8px !important;
    }
    /* Alle Section-Container */
    [id^="section-"] {
        margin-bottom: 0 !important;
        margin-top: 0 !important;
    }
    
    /* Task Cards */
    .task-card {
        padding: 10px 0px !important;
        font-size: 13px;
        width: 100%;
    }
    
    .task-card h3,
    .task-card .text-lg {
        font-size: 14px !important;
    }
    
    .task-card .text-sm {
        font-size: 11px !important;
    }
    
    /* Buttons - Touch-freundlicher (min. 44x44px) */
    /* AUSNAHME: Runde Icon-Buttons (z.B. + Buttons) behalten ihre Form */
    .btn,
    button:not(.login-button):not(.login-lang-button):not(.login-lang-option):not(.rounded-full) {
        min-height: 44px;
        padding: 10px 16px !important;
        font-size: 14px !important;
    }
    
    /* Runde Buttons - Behalte kompakte Größe und runde Form */
    button.rounded-full {
        min-width: 44px !important;
        min-height: 44px !important;
        width: 44px !important;
        height: 44px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        flex-shrink: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* Dashboard Icon-Buttons (Sound, Language, Chat) - 3 Spalten in mobiler Ansicht */
    .dashboard-icon-buttons-wrapper {
        display: flex !important;
        gap: 8px !important;
        width: 100% !important;
    }
    
    /* Sound-Button - 33.33% Breite */
    .dashboard-icon-buttons-wrapper > #audio-permission-toggle {
        flex: 0 0 calc(33.333% - 6px) !important;
        max-width: calc(33.333% - 6px) !important;
        width: auto !important;
    }
    
    /* Language und Chat Container - je 33.33% */
    .dashboard-icon-buttons-wrapper > div.relative {
        flex: 0 0 calc(33.333% - 6px) !important;
        max-width: calc(33.333% - 6px) !important;
    }
    
    /* Buttons innerhalb bekommen volle Breite ihres Containers */
    .dashboard-icon-buttons-wrapper > div.relative button {
        width: 100% !important;
    }
    
    /* Tabellen - Horizontal scrollbar, locker und ungequetscht */
    .table-responsive,
    .overflow-x-auto {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
        margin-left: -16px;
        margin-right: -16px;
        padding-left: 16px;
        padding-right: 16px;
    }
    
    table {
        min-width: 700px;
        font-size: 13px;
        white-space: nowrap;
    }
    
    /* Tabellen-Zellen - mehr Platz */
    table th,
    table td {
        padding: 12px 16px !important;
        white-space: nowrap;
    }
    
    /* Tabellen nicht quetschen */
    table .truncate {
        max-width: none !important;
        overflow: visible !important;
        text-overflow: unset !important;
    }
    
    /* =========================================================================
       PROGRESS BARS - Saubere Darstellung auf Mobile
       ========================================================================= */
    /* Äußerer Container - volle Rundung */
    .rounded-full[class*="bg-gray-"],
    .rounded-full[class*="bg-blue-"],
    .rounded-full[class*="bg-indigo-"],
    .rounded-full[class*="bg-emerald-"] {
        border-radius: 6px !important;
    }
    
    /* Innere Füllung - nur links gerundet, rechts flach */
    .rounded-full > .rounded-full,
    .rounded-full > div[class*="bg-"] {
        border-radius: 6px 2px 2px 6px !important;
        min-width: 8px !important;
    }
    
    /* Bei 0% Füllung komplett ausblenden */
    .rounded-full > div[style*="width: 0%"],
    .rounded-full > div[style*="width:0%"] {
        display: none !important;
    }
    
    /* =========================================================================
       PWA BUTTONS - Einheitliches Blau rgb(66, 92, 151)
       ========================================================================= */
    /* Alle blauen Buttons in PWA auf einheitliche Farbe */
    .bg-blue-600,
    .bg-blue-700,
    .from-blue-600,
    .to-blue-700,
    .bg-gradient-to-r.from-blue-600,
    button[class*="bg-blue"],
    a[class*="bg-blue"] {
        background: rgb(66, 92, 151) !important;
        background-image: none !important;
    }
    
    .hover\:bg-blue-700:hover,
    .hover\:from-blue-700:hover {
        background: rgb(56, 82, 141) !important;
    }
    
    /* Modals - Fullscreen auf Mobile */
    .modal-content {
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        height: 100vh !important;
        border-radius: 0 !important;
    }
    
    /* AUSNAHME: Admin Briefing Modal - NICHT Fullscreen! */
    .admin-briefing-modal {
        margin: 12px !important;
        width: calc(100% - 24px) !important;
        max-width: calc(100vw - 24px) !important;
        height: auto !important;
        max-height: calc(100vh - 80px) !important;
        border-radius: 16px !important;
        overflow: hidden !important;
    }
    
    /* Briefing Task Items - Overflow Fix */
    .briefing-task-item {
        overflow: hidden !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    .briefing-task-item .flex-1 {
        overflow: hidden !important;
    }
    
    .briefing-task-item p {
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }
    
    /* =========================================================================
       DASHBOARD HEADER - MOBILE LAYOUT
       (Hauptstyles sind in dashboard.php)
       ========================================================================= */
    
    /* Title Größe auf Mobile */
    .twk-header-title {
        font-size: 1.5rem !important;
    }
    
    /* Sidebar - Bessere Touch-Bedienung */
    #sidebar a {
        padding: 14px 16px !important;
        font-size: 15px !important;
    }
    
    /* Forms - Größere Inputs für Touch (verhindert Auto-Zoom auf iOS) */
    input[type="text"]:not(.login-input-field),
    input[type="email"],
    input[type="password"]:not(.login-input-field),
    input[type="number"],
    input[type="date"],
    input[type="time"],
    textarea,
    select {
        font-size: 16px !important;
        min-height: 44px;
        padding: 10px 44px !important;
        width: 100%;
    }
    
    /* Collapsible Sections - Touch-optimiert */
    .collapsible-trigger {
        padding: 14px 0px !important;
        font-size: 14px !important;
    }
    
    .collapsible-trigger i {
        font-size: 16px !important;
    }
    
    /* Task List Scrollable - Höhe anpassen */
    .task-list-scrollable {
        max-height: 300px !important;
    }
    
    /* Cards Grid - Single Column */
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    
    /* Flex Layouts - Stack vertikal */
    .flex-row {
        flex-direction: column !important;
    }
    
    /* Padding/Margins reduzieren */
    .p-6 {
        padding: 12px 0px !important;
    }
    
    .p-4 {
        padding: 10px 0px !important;
    }
    
    .px-4 {
        padding-left: 0px !important;
        padding-right: 0px !important;
    }
    
    .px-6 {
        padding-left: 0px !important;
        padding-right: 0px !important;
    }
    
    .px-8 {
        padding-left: 0px !important;
        padding-right: 0px !important;
    }
    
    .py-6 {
        padding-top: 16px !important;
        padding-bottom: 16px !important;
    }
    
    /* Text Sizes - Besser lesbar */
    h1, .text-3xl {
        font-size: 24px !important;
    }
    
    h2, .text-2xl {
        font-size: 20px !important;
    }
    
    h3, .text-xl {
        font-size: 18px !important;
    }
    
    .text-lg {
        font-size: 16px !important;
    }
    
    /* Avatar - Kleinere Größe */
    .avatar,
    img[alt*="Avatar"] {
        width: 32px !important;
        height: 32px !important;
    }
    
    /* Badge - Kompakter */
    .badge,
    .bg-blue-100,
    .bg-green-100,
    .bg-yellow-100,
    .bg-red-100,
    .bg-orange-100 {
        padding: 4px 8px !important;
        font-size: 11px !important;
    }
    
    /* Chat Popup - Fullscreen auf Mobile */
    #chat-popup {
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        bottom: 0 !important;
        right: 0 !important;
        border-radius: 0 !important;
    }
    
    /* Timeline - Horizontal scrollbar */
    .timeline-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
    }
    
    .timeline-grid-container {
        min-width: 800px;
    }
}

/* =========================================================================
   SMARTPHONES LANDSCAPE (640px - 768px)
   ========================================================================= */
@media (min-width: 640px) and (max-width: 768px) {
    /* Sidebar-Padding auch hier entfernen */
    .md\:pl-64 {
        padding-left: 0 !important;
    }
    
    /* Cards - 2 Spalten Layout */
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Dashboard Cards - Mittlere Größe */
    .dashboard-card {
        padding: 16px !important;
    }
    
    /* Modals - 90% Width */
    .modal-content {
        width: 90% !important;
        max-width: 600px !important;
    }
    
    /* Container - Gleichmäßiges Padding */
    .max-w-7xl {
        padding-left: 20px !important;
        padding-right: 20px !important;
    }
}

/* =========================================================================
   TABLETS PORTRAIT (768px - 1024px)
   ========================================================================= */
@media (min-width: 768px) and (max-width: 1024px) {
    /* Sidebar-Padding reduziert auf Tablets */
    .md\:pl-64 {
        padding-left: 280px !important;
    }
    
    /* Dashboard - 2-3 Spalten */
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Sidebar - Volle Breite wenn offen */
    #sidebar {
        width: 280px;
    }
    
    /* Container - Gleichmäßiges Padding */
    .max-w-7xl {
        padding-left: 24px !important;
        padding-right: 24px !important;
    }
}

/* =========================================================================
   DESKTOP - Normales Padding
   ========================================================================= */
@media (min-width: 1024px) {
    .max-w-7xl {
        padding-left: 32px;
        padding-right: 32px;
    }
}

/* =========================================================================
   TOUCH DEVICE OPTIMIERUNGEN
   ========================================================================= */
@media (hover: none) and (pointer: coarse) {
    /* Alle interaktiven Elemente - Mindestgröße 44x44px */
    a, button, input[type="submit"], input[type="button"], .clickable {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Hover-Effekte deaktivieren auf Touch */
    *:hover {
        transform: none !important;
    }
    
    /* Active States für besseres Touch-Feedback */
    button:active,
    a:active,
    .clickable:active {
        transform: scale(0.98);
        opacity: 0.8;
    }
    
    /* Scrollbars ausblenden auf Touch Devices */
    ::-webkit-scrollbar {
        display: none;
    }
    
    * {
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
}

/* =========================================================================
   PERFORMANCE OPTIMIERUNGEN FÜR MOBILE
   ========================================================================= */
@media (max-width: 768px) {
    /* Animationen reduzieren für bessere Performance */
    *:not(.login-page-background):not(.login-color-blob):not(.login-logo-container::before):not(.login-logo-container::after) {
        animation-duration: 0.2s !important;
        transition-duration: 0.2s !important;
    }
    
    /* Blur-Effekte reduzieren */
    .backdrop-blur-lg,
    .backdrop-blur-xl {
        backdrop-filter: blur(8px) !important;
    }
    
    /* Shadows reduzieren */
    .shadow-lg,
    .shadow-xl,
    .shadow-2xl {
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1) !important;
    }
}

/* =========================================================================
   SEHR KLEINE SMARTPHONES (< 375px)
   ========================================================================= */
@media (max-width: 374px) {
    /* Alles noch kompakter */
    body {
        font-size: 13px;
    }
    
    .dashboard-card {
        padding: 10px !important;
    }
    
    h1 {
        font-size: 20px !important;
    }
    
    h2 {
        font-size: 18px !important;
    }
    
    h3 {
        font-size: 16px !important;
    }
    
    button,
    .btn {
        padding: 8px 12px !important;
        font-size: 13px !important;
    }
    
    .max-w-7xl {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
}

/* =========================================================================
   LANDSCAPE MODE OPTIMIERUNGEN
   ========================================================================= */
@media (max-height: 500px) and (orientation: landscape) {
    /* Header kompakter */
    .login-header,
    .header {
        padding: 8px 16px !important;
    }
    
    /* Modals - Max Height anpassen */
    .modal-content {
        max-height: 90vh !important;
        overflow-y: auto;
    }
    
    /* Login Box - Kleiner */
    .login-box {
        padding: 20px 25px !important;
    }
    
    .login-title {
        font-size: 18px !important;
        margin-bottom: 15px !important;
    }
}

/* =========================================================================
   ACCESSIBILITY IMPROVEMENTS
   ========================================================================= */
@media (max-width: 768px) {
    /* Focus Indicators - Größer für Touch */
    *:focus {
        outline: 3px solid rgba(59, 130, 246, 0.5) !important;
        outline-offset: 2px;
    }
    
    /* Skip Links */
    .skip-link {
        position: absolute;
        top: -40px;
        left: 0;
        background: #000;
        color: #fff;
        padding: 8px;
        z-index: 100;
    }
    
    .skip-link:focus {
        top: 0;
    }
}

/* =========================================================================
   PRINT STYLES
   ========================================================================= */
@media print {
    /* Verstecke UI-Elemente beim Drucken */
    #sidebar,
    .sidebar,
    nav,
    .nav,
    button:not(.print-button),
    .no-print {
        display: none !important;
    }
    
    /* Content auf volle Breite */
    .md\\:pl-64 {
        padding-left: 0 !important;
    }
    
    /* Schrift schwarz */
    * {
        color: #000 !important;
        background: #fff !important;
    }
}

/* =========================================================================
   CUSTOM UTILITY CLASSES FÜR MOBILE
   ========================================================================= */

/* Mobile Show/Hide */
.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }
    
    .mobile-hide {
        display: none !important;
    }
}

/* Desktop Show/Hide */
.desktop-only {
    display: block;
}

@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }
}

/* Touch-Safe Spacing */
.touch-target {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Mobile Stack */
@media (max-width: 640px) {
    .mobile-stack > * {
        width: 100% !important;
        margin-bottom: 12px;
    }
    
    .mobile-stack > *:last-child {
        margin-bottom: 0;
    }
}
