/* Responsive Design Fixes for TherapywAIse */

/* Fix ARIA panel width on smaller screens */
@media (max-width: 1024px) {
    .aria-panel {
        width: 300px;
    }
}

@media (max-width: 768px) {
    .aria-panel {
        position: fixed;
        right: -100%;
        width: 100%;
        max-width: 350px;
        height: 100%;
        transition: right 0.3s ease;
        z-index: 1100;
    }
    
    .aria-panel.active {
        right: 0;
    }
    
    /* MAYA toolbar responsive */
    .maya-toolbar {
        min-width: unset;
        width: 100%;
        font-size: 12px;
        padding: 12px 16px;
    }
    
    /* Push pins responsive */
    .maya-push-pins {
        width: 100%;
        max-width: 320px;
        position: fixed;
        right: 10px;
        bottom: 10px;
        z-index: 1000;
    }
}

/* Fix sidebar on mobile */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        width: 280px;
        height: 100%;
        z-index: 1200;
        transition: left 0.3s ease;
    }
    
    .sidebar.active {
        left: 0;
    }
    
    /* Add mobile menu toggle button */
    .mobile-menu-toggle {
        display: block;
        position: fixed;
        left: 10px;
        top: 70px;
        z-index: 1300;
        background: var(--theme-primary, #667eea);
        color: white;
        border: none;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        cursor: pointer;
        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    }
}

/* Hide mobile toggle on desktop */
@media (min-width: 769px) {
    .mobile-menu-toggle {
        display: none;
    }
}

/* Fix fixed widths for better responsiveness */
.auth-modal,
.assessment-selector-modal,
.assessment-form-modal,
.allergy-form-modal {
    width: 90%;
    max-width: 600px;
}

@media (max-width: 480px) {
    .auth-modal,
    .assessment-selector-modal,
    .assessment-form-modal,
    .allergy-form-modal {
        width: 95%;
        margin: 10px;
    }
}

/* Fix discipline tabs on mobile */
@media (max-width: 768px) {
    .discipline-tabs {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
        padding-bottom: 2px;
    }
    
    .discipline-tab {
        flex: 0 0 auto;
        min-width: 120px;
        font-size: 0.85em;
        padding: 10px 16px;
    }
    
    /* Add scroll indicators */
    .discipline-tabs::before,
    .discipline-tabs::after {
        content: '';
        position: sticky;
        width: 20px;
        height: 100%;
        pointer-events: none;
        z-index: 1;
    }
    
    .discipline-tabs::before {
        left: 0;
        background: linear-gradient(to right, white, transparent);
    }
    
    .discipline-tabs::after {
        right: 0;
        background: linear-gradient(to left, white, transparent);
    }
}

/* Fix editor toolbar on mobile */
@media (max-width: 768px) {
    .editor-toolbar {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .toolbar-left,
    .toolbar-right {
        width: 100%;
        justify-content: space-between;
    }
}

/* Fix documentation editor on mobile */
@media (max-width: 768px) {
    .documentation-editor {
        min-height: 300px;
        font-size: 1em;
        padding: 15px;
    }
}

/* Fix buttons on mobile */
@media (max-width: 480px) {
    .btn {
        padding: 10px 16px;
        font-size: 0.9em;
    }
    
    .btn-group {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    .btn-group .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Z-index hierarchy fix */
.menu-bar { z-index: 1000; }
.sidebar { z-index: 1100; }
.sidebar.active { z-index: 1200; }
.mobile-menu-toggle { z-index: 1300; }
.maya-push-pins { z-index: 2000; }
.aria-panel { z-index: 2100; }

/* Overlay z-index hierarchy */
.assessment-selector-overlay { z-index: 9000; }
.assessment-form-overlay { z-index: 9100; }
.allergy-form-overlay { z-index: 9200; }
.maya-note-popup { z-index: 9300; }
.auth-overlay { z-index: 10000; /* Highest priority */ }

/* Fix viewport height on mobile browsers */
@supports (-webkit-touch-callout: none) {
    .app-container {
        height: -webkit-fill-available;
    }
}

/* Improve touch targets */
@media (hover: none) and (pointer: coarse) {
    button,
    .btn,
    .filter-btn,
    .discipline-tab,
    .patient-card {
        min-height: 44px;
        min-width: 44px;
    }
    
    .pin-close,
    .pin-apply,
    .pin-more,
    .pin-feedback {
        width: 36px;
        height: 36px;
    }
}