/* Mobile Optimization for Therapist Notes V3 */

/* Base Mobile Styles */
@media (max-width: 768px) {
    
    /* Header Optimization */
    .header {
        padding: 10px 15px;
        flex-wrap: wrap;
    }
    
    .header h1 {
        font-size: 1.2em;
        margin: 0;
    }
    
    .header-right {
        gap: 8px;
    }
    
    .icon-btn {
        min-width: 40px;
        height: 40px;
        font-size: 16px;
        padding: 8px;
    }
    
    /* Navigation Tabs */
    .nav-tabs {
        overflow-x: auto;
        white-space: nowrap;
        padding: 0 10px;
        -webkit-overflow-scrolling: touch;
    }
    
    .nav-tab {
        min-width: 80px;
        padding: 8px 12px;
        font-size: 14px;
        flex-shrink: 0;
    }
    
    /* Main Container */
    .main-container {
        padding: 10px;
    }
    
    /* Form Elements */
    .form-group {
        margin-bottom: 15px;
    }
    
    .form-group label {
        font-size: 14px;
        margin-bottom: 5px;
    }
    
    input[type="text"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px;
        border-radius: 8px;
    }
    
    textarea {
        min-height: 120px;
        resize: vertical;
    }
    
    /* Button Optimization */
    .btn,
    .btn-primary,
    .btn-secondary,
    .btn-outline {
        padding: 12px 16px;
        font-size: 14px;
        min-height: 44px; /* Touch target size */
        border-radius: 8px;
        margin: 4px 2px;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 10px;
        margin-top: 20px;
        position: relative;
        z-index: 100;
        background: white;
        padding: 15px 0;
    }
    
    .form-actions button,
    .form-actions .btn-primary,
    .form-actions .btn-secondary,
    .form-actions .btn-outline {
        width: 100%;
        margin: 0;
        box-sizing: border-box;
    }
    
    /* AI Output Mobile */
    .ai-output {
        margin-bottom: 30px;
        padding-bottom: 20px;
        overflow: visible;
        position: relative;
        z-index: 1;
    }
    
    /* Voice Controls Mobile */
    .voice-controls {
        flex-direction: column;
        gap: 10px;
        padding: 15px;
    }
    
    .voice-btn {
        width: 100%;
        min-height: 50px;
        font-size: 16px;
        padding: 15px;
        border-radius: 12px;
    }
    
    .voice-btn.recording {
        animation: pulse-mobile 1.5s infinite;
    }
    
    @keyframes pulse-mobile {
        0% { transform: scale(1); }
        50% { transform: scale(1.02); }
        100% { transform: scale(1); }
    }
    
    /* Client Selection Mobile */
    .client-autocomplete-container {
        position: relative;
    }
    
    #client-autocomplete {
        width: 100%;
        font-size: 16px;
        padding: 12px;
        border-radius: 8px;
    }
    
    .client-dropdown {
        max-height: 200px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .client-item {
        padding: 12px;
        border-bottom: 1px solid #eee;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .show-all-btn {
        width: 100%;
        margin-top: 8px;
        padding: 10px;
        font-size: 14px;
    }
    
    /* AI Assistant Mobile */
    .ai-controls {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-bottom: 15px;
    }
    
    .ai-btn {
        padding: 10px 8px;
        font-size: 12px;
        min-height: 44px;
        border-radius: 8px;
        text-align: center;
    }
    
    #ai-output {
        font-size: 14px;
        padding: 15px;
        max-height: 300px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Notes List Mobile */
    .notes-list {
        gap: 10px;
    }
    
    .note-item {
        padding: 15px;
        border-radius: 8px;
        margin-bottom: 10px;
    }
    
    .note-actions {
        flex-direction: column;
        gap: 8px;
        margin-top: 10px;
    }
    
    .note-actions .btn {
        width: 100%;
        padding: 8px;
        font-size: 12px;
    }
    
    /* Clients List Mobile */
    .clients-list {
        gap: 10px;
    }
    
    .client-card {
        padding: 15px;
        border-radius: 8px;
        margin-bottom: 10px;
    }
    
    .client-actions {
        flex-direction: column;
        gap: 8px;
        margin-top: 10px;
    }
    
    .client-actions .btn {
        width: 100%;
        padding: 8px;
        font-size: 12px;
    }
    
    /* Analytics Mobile */
    .analytics-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .analytics-card {
        padding: 15px;
        border-radius: 8px;
    }
    
    .chart-container {
        height: 250px;
        margin-top: 15px;
    }
    
    /* Modal Mobile */
    .modal-content {
        width: 95%;
        max-width: none;
        margin: 20px auto;
        max-height: 90vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .modal-header {
        padding: 15px;
        flex-wrap: wrap;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    /* Settings Mobile */
    .settings-section {
        margin-bottom: 20px;
        padding: 15px;
        border-radius: 8px;
    }
    
    .setting-item {
        margin-bottom: 15px;
    }
    
    .setting-item label {
        font-size: 14px;
        margin-bottom: 5px;
    }
    
    /* Premium Features Mobile */
    .premium-feature::after {
        font-size: 7px;
        padding: 1px 4px;
        top: -4px;
        right: -6px;
    }
    
    /* Notifications Mobile */
    .notification {
        left: 10px;
        right: 10px;
        top: 10px;
        max-width: none;
        font-size: 14px;
        padding: 10px 15px;
        border-radius: 8px;
    }
    
    /* Loading Screen Mobile */
    .loading-screen {
        padding: 20px;
    }
    
    .loading-content h2 {
        font-size: 1.5em;
        margin-bottom: 15px;
    }
    
    .loading-spinner {
        width: 40px;
        height: 40px;
    }
}

/* Small Mobile (iPhone SE, etc.) */
@media (max-width: 480px) {
    
    .header h1 {
        font-size: 1.1em;
    }
    
    .nav-tab {
        min-width: 70px;
        padding: 6px 8px;
        font-size: 12px;
    }
    
    .ai-controls {
        grid-template-columns: 1fr;
    }
    
    .ai-btn {
        width: 100%;
    }
    
    .voice-btn {
        font-size: 14px;
        padding: 12px;
    }
    
    .modal-content {
        width: 98%;
        margin: 10px auto;
    }
    
    .btn {
        font-size: 13px;
        padding: 10px 12px;
    }
}

/* Landscape Mobile */
@media (max-width: 768px) and (orientation: landscape) {
    
    .modal-content {
        max-height: 85vh;
    }
    
    .voice-controls {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .voice-btn {
        flex: 1;
        min-width: 200px;
    }
    
    .ai-controls {
        grid-template-columns: 1fr 1fr;
    }
}

/* Touch Improvements */
@media (hover: none) and (pointer: coarse) {
    
    /* Remove hover effects on touch devices */
    .btn:hover,
    .nav-tab:hover,
    .note-item:hover,
    .client-card:hover {
        transform: none;
    }
    
    /* Add touch feedback */
    .btn:active,
    .nav-tab:active,
    .note-item:active,
    .client-card:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
    
    /* Larger touch targets */
    .icon-btn,
    .close-btn {
        min-width: 44px;
        min-height: 44px;
    }
    
    /* Prevent text selection on buttons */
    .btn,
    .nav-tab,
    .icon-btn {
        -webkit-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
    }
}

/* Dark Mode Mobile Adjustments */
@media (max-width: 768px) and (prefers-color-scheme: dark) {
    
    .modal-content {
        background: #2a2a2a;
        border: 1px solid #444;
    }
    
    .notification {
        box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    }
    
    input[type="text"],
    input[type="date"],
    select,
    textarea {
        background: #333;
        border-color: #555;
        color: #fff;
    }
}

/* Mobile-specific enhancements */
.mobile-device {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

/* Scroll indicators for navigation */
.scroll-indicator {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.5);
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    z-index: 10;
    transition: opacity 0.3s ease;
}

.scroll-indicator.left {
    left: 5px;
}

.scroll-indicator.right {
    right: 5px;
}

.scroll-indicator:active {
    background: rgba(0,0,0,0.7);
}

/* Mobile menu toggle */
.mobile-menu-toggle {
    display: none;
}

@media (max-width: 480px) {
    .mobile-menu-toggle {
        display: block;
    }
    
    .header-right {
        position: relative;
    }
    
    .header-right:not(.mobile-menu-open) .icon-btn:not(.mobile-menu-toggle) {
        display: none;
    }
    
    .header-right.mobile-menu-open {
        position: absolute;
        top: 100%;
        right: 0;
        background: white;
        border: 1px solid #ddd;
        border-radius: 8px;
        padding: 10px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.1);
        z-index: 1000;
    }
    
    .header-right.mobile-menu-open .icon-btn {
        display: block;
        width: 100%;
        margin: 5px 0;
        text-align: left;
        padding: 10px;
        border-radius: 4px;
    }
}

/* Keyboard open adjustments */
.keyboard-open .main-container {
    transition: all 0.3s ease;
}

.keyboard-open .modal-content {
    max-height: 50vh !important;
}

/* Mobile toast notifications */
.mobile-toast {
    pointer-events: none;
    white-space: nowrap;
    max-width: 80%;
    text-align: center;
}

/* Voice recording mobile enhancements */
@media (max-width: 768px) {
    .voice-btn.recording {
        box-shadow: 0 0 20px rgba(255, 0, 0, 0.3);
        border: 2px solid #ff4444;
    }
    
    .voice-transcript {
        font-size: 14px;
        line-height: 1.4;
        padding: 10px;
    }
}

/* Improved touch targets */
@media (hover: none) and (pointer: coarse) {
    .client-item,
    .note-item,
    .client-card {
        min-height: 48px;
        padding: 12px;
    }
    
    .note-actions .btn,
    .client-actions .btn {
        min-height: 40px;
        padding: 8px 12px;
    }
}
