/* Mobile and tablet specific styles */
/* Enhanced mobile styles for regular controls */
@media (max-width: 768px), 
       (hover: none) and (pointer: coarse) and (min-width: 320px) {
    /* Prevent text selection on tap */
    * {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -khtml-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
    
    /* Make all inputs and buttons more touch-friendly */
    button, select, input, .adsr-envelope-container {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
    }
    
    /* Override any conflicting styles from main CSS */
    body, html {
        overflow-x: hidden;
        touch-action: manipulation;
        -webkit-overflow-scrolling: touch;
    }

    /* Enhanced controls for mobile - only when mobile-enhanced class is present */
    body.mobile-enhanced .controls {
        /* Better positioning for mobile - centered with proper spacing */
        position: fixed !important;
        top: 20px !important;
        left: 20px !important;
        right: 20px !important;
        bottom: auto !important;
        width: calc(100vw - 40px) !important;
        max-width: calc(100vw - 40px) !important;
        max-height: calc(100vh - 40px) !important;
        border-radius: 12px !important;
        padding: 20px 15px 25px 15px !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        backdrop-filter: blur(15px) !important;
        background: rgba(13, 17, 23, 0.95) !important;
    }

    /* Enhanced close button for mobile - smaller and properly positioned */
    body.mobile-enhanced .controls-close-btn {
        width: 32px !important;
        height: 32px !important;
        font-size: 16px !important;
        top: 12px !important;
        right: 12px !important;
        z-index: 1000 !important;
    }
}

/* Responsive width and navigation based on viewport width */
@media (max-width: 768px) {
    /* Override desktop width for small viewports - make it responsive but keep at top */
    body:not(.mobile-enhanced) .controls {
        position: absolute !important;
        top: 20px !important;
        left: 20px !important;
        bottom: auto !important;
        right: auto !important;
        width: calc(100vw - 40px) !important;
        max-width: calc(100vw - 40px) !important;
        min-width: 320px !important;
        border-radius: 10px !important;
        transform: translateY(0) !important;
        overflow-y: auto !important;
        box-sizing: border-box !important;
    }

    /* Ensure proper header layout in dropdown mode */
    .controls .controls-tabs {
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 12px !important;
        margin-bottom: 12px !important;
        padding-right: 50px !important; /* Space for X button */
        flex-wrap: nowrap !important;
    }
    
    /* Ensure Info tab has proper spacing and doesn't overlap with close button */
    .controls .tab-content.active {
        margin-top: 10px !important;
        padding-right: 10px !important;
    }

    /* Play button styling in dropdown mode */
    .controls .music-icon-button {
        flex-shrink: 0 !important;
        width: 44px !important;
        height: 44px !important;
        font-size: 18px !important;
        margin: 0 !important;
    }

    /* Show dropdown, hide tab buttons */
    .controls .tab-dropdown {
        display: block !important;
        flex: 1 !important;
        max-width: none !important;
        margin: 0 !important;
    }

    .controls .tab-dropdown select {
        width: 100% !important;
        min-height: 44px !important;
        padding: 10px 15px !important;
        font-size: 16px !important;
        border-radius: 8px !important;
        background: rgba(88, 166, 255, 0.2) !important;
        border: 2px solid #58a6ff !important;
        color: white !important;
        text-align: center !important;
        box-sizing: border-box !important;
    }

    .controls .tab-buttons {
        display: none !important;
    }

    /* Scale down chord buttons and other elements proportionally */
    .chord-btn {
        padding: 0.3em 0.8em !important;
        font-size: 0.9em !important;
        margin: 0 0.1em !important;
    }

    .chord-row {
        padding: 0.2em 0.5em !important;
        margin-bottom: 0.3em !important;
    }

    .loop-btn {
        width: 1.5em !important;
        height: 1.5em !important;
        font-size: 0.9em !important;
    }

    .compact-selector {
        font-size: 0.9em !important;
        padding: 0.1em 0.5em !important;
        min-width: 60px !important;
    }

    .activate-chord-btn {
        width: 1.8em !important;
        height: 1.8em !important;
        font-size: 1.1em !important;
    }

    .current-chord-display {
        font-size: 1em !important;
    }

    /* Scale dial containers */
    .dial-container {
        margin-right: 8px !important;
        margin-bottom: 8px !important;
        width: 70px !important;
    }

    .dial {
        width: 50px !important;
        height: 50px !important;
    }

    .dial-value {
        width: 32px !important;
        height: 32px !important;
        top: 9px !important;
        left: 9px !important;
        font-size: 10px !important;
    }

    .dial-indicator {
        height: 18px !important;
        top: 6px !important;
    }

    .dial-label {
        font-size: 11px !important;
        width: 60px !important;
    }

    /* Scale mode buttons */
    .mode-button {
        padding: 6px 12px !important;
        font-size: 13px !important;
        margin: 3px !important;
    }

    /* Scale tab content */
    .tab-content h3 {
        font-size: 1.1em !important;
        margin-top: 0 !important;
        margin-bottom: 10px !important;
    }

    .control-group {
        margin: 8px 0 !important;
    }

    .control-group label {
        width: 100px !important;
        font-size: 13px !important;
    }

    .control-group input, .control-group select {
        font-size: 13px !important;
        padding: 4px !important;
    }

    /* Mobile Drum Machine Styling */
    .drum-machine {
        padding: 10px !important;
    }

    .drum-volumes {
        gap: 8px !important;
        margin-bottom: 15px !important;
        padding-bottom: 10px !important;
    }

    .drum-vol-control {
        gap: 3px !important;
    }

    .drum-vol-control label {
        font-size: 10px !important;
        min-width: 35px !important;
    }

    .drum-volume-slider {
        width: 50px !important;
        height: 3px !important;
    }

    .drum-volume-slider::-webkit-slider-thumb {
        width: 10px !important;
        height: 10px !important;
    }

    .drum-volume-slider::-moz-range-thumb {
        width: 10px !important;
        height: 10px !important;
    }

    .sequencer-grid {
        gap: 6px !important;
    }

    .drum-row {
        gap: 6px !important;
        padding: 6px !important;
    }

    .drum-label {
        font-size: 10px !important;
        min-width: 40px !important;
    }

    .steps-container {
        gap: 1px !important;
    }

    .step-button {
        width: 8px !important;
        height: 10px !important;
        border-radius: 2px !important;
    }

    .pattern-controls {
        margin-top: 10px !important;
        padding-top: 10px !important;
        gap: 8px !important;
    }

    .pattern-btn {
        padding: 6px 12px !important;
        font-size: 11px !important;
    }
}

@media (min-width: 769px) {
    /* Show tab buttons, hide dropdown for larger viewports */
    .controls .tab-dropdown {
        display: none !important;
    }

    .controls .tab-buttons {
        display: flex !important;
    }

    .controls .controls-tabs {
        display: flex !important;
        gap: 8px !important;
        margin-bottom: 12px !important;
    }
}
