/* =========================================================================
   TEAMWORKK - RESPONSIVE STYLES (Mobile-First)
   Version: 1.3.0 - Fix für 256px padding-left Problem
   ========================================================================= */

/* =========================================================================
   GLOBAL
   ========================================================================= */
* {
    box-sizing: border-box;
}

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

/* =========================================================================
   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: auto !important;
        margin-right: auto !important;
    }
    
    /* Dashboard Cards - Kompaktere Darstellung */
    .dashboard-card,
    .bg-white,
    [class*="bg-"]:not(.login-page-background) {
        padding: 12px !important;
        margin-bottom: 12px !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100%;
        max-width: 100%;
    }
    
    /* Task Cards */
    .task-card {
        padding: 10px !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 */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
    }
    
    table {
        min-width: 600px;
        font-size: 13px;
    }
    
    /* Modals - Fullscreen auf Mobile */
    .modal-content {
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        height: 100vh !important;
        border-radius: 0 !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 14px !important;
        width: 100%;
    }
    
    /* Collapsible Sections - Touch-optimiert */
    .collapsible-trigger {
        padding: 14px 12px !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 !important;
    }
    
    .p-4 {
        padding: 10px !important;
    }
    
    .px-4 {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
    
    .px-6 {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
    
    .px-8 {
        padding-left: 12px !important;
        padding-right: 12px !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;
    }
}
