/* Base styles and responsive layout */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

.music-player {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-top: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    color: #2c3e50;
    font-size: 2.5rem;
    margin-bottom: 10px;
}

/* Playback controls styling */
.controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
}

/* Loop controls styling */
.loop-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.loop-count {
    display: flex;
    align-items: center;
    gap: 10px;
}

.loop-count input {
    width: 60px;
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
}

/* Volume controls styling */
.volume-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 400px;
}

.volume-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.volume-item label {
    font-weight: 600;
    color: #2c3e50;
    min-width: 120px;
}

#master-volume {
    flex: 1;
    height: 6px;
    background: #ddd;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

#master-volume::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #3498db;
    border-radius: 50%;
    cursor: pointer;
}

#master-volume::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #3498db;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

#master-volume-display {
    font-weight: 600;
    color: #3498db;
    min-width: 50px;
    text-align: center;
    background-color: #ecf0f1;
    padding: 4px 8px;
    border-radius: 4px;
}

/* Track controls styling */
.track-controls {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.track-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    background-color: #f8f9fa;
}

.track-item label {
    font-weight: 600;
    color: #2c3e50;
}

.track-buttons {
    display: flex;
    gap: 8px;
}

.track-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.mute-btn {
    background-color: #95a5a6;
    color: white;
}

.mute-btn:hover {
    background-color: #7f8c8d;
}

.mute-btn.muted {
    background-color: #e74c3c;
}

.solo-btn {
    background-color: #f39c12;
    color: white;
}

.solo-btn:hover {
    background-color: #e67e22;
}

.solo-btn.soloed {
    background-color: #27ae60;
}

.playback-options {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.playback-options label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.playback-options label:hover {
    background-color: #f0f0f0;
}

.playback-options input[type="radio"] {
    margin: 0;
}

.tempo-control {
    display: flex;
    align-items: center;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.tempo-control label {
    font-weight: 600;
    color: #2c3e50;
}

#tempo-slider {
    width: 200px;
    height: 6px;
    background: #ddd;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

#tempo-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #3498db;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

#tempo-slider::-webkit-slider-thumb:hover {
    background: #2980b9;
}

#tempo-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #3498db;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    transition: background-color 0.2s ease;
}

#tempo-slider::-moz-range-thumb:hover {
    background: #2980b9;
}

#tempo-display {
    font-weight: 600;
    color: #3498db;
    min-width: 40px;
    text-align: center;
    background-color: #ecf0f1;
    padding: 4px 8px;
    border-radius: 4px;
}

.playback-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

#play-btn, #stop-btn, #autoscroll-btn {
    padding: 12px 24px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 100px;
}

#play-btn {
    background-color: #27ae60;
    color: white;
}

#play-btn:hover:not(:disabled) {
    background-color: #229954;
    transform: translateY(-2px);
}

#stop-btn {
    background-color: #e74c3c;
    color: white;
}

#stop-btn:hover:not(:disabled) {
    background-color: #c0392b;
    transform: translateY(-2px);
}

#autoscroll-btn {
    background-color: #9b59b6;
    color: white;
}

#autoscroll-btn:hover {
    background-color: #8e44ad;
    transform: translateY(-2px);
}

#autoscroll-btn.active {
    background-color: #27ae60;
}

#autoscroll-btn.active:hover {
    background-color: #229954;
}

#play-btn:disabled, #stop-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Pattern management styling */
.pattern-management {
    margin-bottom: 20px;
}

.pattern-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.pattern-controls button {
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: #3498db;
    color: white;
}

.pattern-controls button:hover {
    background-color: #2980b9;
    transform: translateY(-1px);
}

#save-project-btn {
    background-color: #27ae60;
}

#save-project-btn:hover {
    background-color: #229954;
}

#load-project-btn {
    background-color: #f39c12;
}

#load-project-btn:hover {
    background-color: #e67e22;
}

#manage-data-btn {
    background-color: #e74c3c;
}

#manage-data-btn:hover {
    background-color: #c0392b;
}

#export-data-btn {
    background-color: #16a085;
}

#export-data-btn:hover {
    background-color: #138d75;
}

#import-data-btn {
    background-color: #34495e;
}

#import-data-btn:hover {
    background-color: #2c3e50;
}

/* Pattern input areas styling */
.pattern-inputs {
    margin-bottom: 30px;
}

/* Pattern tabs styling */
.pattern-tabs {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e9ecef;
}

.tab-btn {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-bottom: none;
    padding: 10px 20px;
    border-radius: 6px 6px 0 0;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    background-color: #e9ecef;
}

.tab-btn.active {
    background-color: #3498db;
    color: white;
    border-color: #3498db;
}

/* Pattern editors styling */
.pattern-editor {
    display: none;
}

.pattern-editor.active {
    display: block;
}



/* MIDI editor styling */
.midi-container {
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 20px;
    background-color: #f8f9fa;
}

.midi-container h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #2c3e50;
}

.midi-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.midi-controls button {
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: #3498db;
    color: white;
}

.midi-controls button:hover {
    background-color: #2980b9;
    transform: translateY(-1px);
}

#midi-upload-btn {
    background-color: #16a085;
}

#midi-upload-btn:hover {
    background-color: #138d75;
}

#convert-midi-btn {
    background-color: #8e44ad;
}

#convert-midi-btn:hover {
    background-color: #7d3c98;
}

#convert-midi-btn:disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
    transform: none;
}

.midi-info {
    padding: 15px;
    background-color: #ecf0f1;
    border-radius: 4px;
    border: 1px solid #e9ecef;
}

.midi-info p {
    margin: 5px 0;
}

/* Playback visualization styling */
.playback-visualization {
    margin-bottom: 20px;
}

.visualization-container {
    display: flex;
    flex-direction: column;
    gap: 30px;
    width: 100%;
    overflow-x: hidden;
}

@media (min-width: 1400px) {
    .visualization-container {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 30px;
    }
}

.beat-visualization, .melody-visualization {
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 15px;
    background-color: #f8f9fa;
    width: 100%;
    min-width: 0;
    flex-shrink: 0;
}

.beat-visualization h4, .melody-visualization h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #2c3e50;
}

.pattern-viz {
    min-height: 100px;
    max-height: 150px;
    background-color: #ecf0f1;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    position: relative;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: #ddd transparent;
    padding: 12px;
    width: 100%;
    display: block;
    box-sizing: border-box;
    /* Ensure proper scrolling */
    -webkit-overflow-scrolling: touch;
    /* Force horizontal scrollbar when needed */
    overflow-x: scroll;
}

.viz-item {
    display: inline-block;
    background-color: #3498db;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
    margin: 2px 4px;
    vertical-align: middle;
    min-width: 60px;
    text-align: center;
    flex-shrink: 0;
    width: auto;
    position: relative;
    box-sizing: border-box;
    max-width: none;
}

.viz-item.active {
    background-color: #27ae60;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(39, 174, 96, 0.3);
}

.input-group {
    display: flex;
    flex-direction: column;
}

.input-group label {
    font-weight: 600;
    margin-bottom: 8px;
    color: #2c3e50;
    font-size: 1.1rem;
}

#beat-input, #melody-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    resize: vertical;
    min-height: 200px;
    max-height: 400px;
    overflow: auto;
    overflow-x: auto;
    overflow-y: scroll;
    background-color: #f8f9fa;
    position: relative;
    scrollbar-width: thin;
    scrollbar-color: #ddd transparent;
}

#beat-input:focus, #melody-input:focus {
    outline: none;
    border-color: #3498db;
    background-color: white;
}



/* Status box styling */
.status {
    margin-top: 20px;
}

#status-box {
    background-color: #ecf0f1;
    border: 2px solid #bdc3c7;
    border-radius: 6px;
    padding: 15px;
    text-align: center;
    font-weight: 500;
    color: #2c3e50;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Responsive design for mobile devices */
@media (max-width: 768px) {
    .music-player {
        margin: 10px;
        padding: 15px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .controls {
        gap: 15px;
    }
    
    .playback-options {
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
    
    .tempo-control {
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
    
    #tempo-slider {
        width: 100%;
        max-width: 250px;
    }
    
    .playback-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    #play-btn, #stop-btn {
        width: 100%;
        max-width: 200px;
    }
    
    .pattern-inputs {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    #beat-input, #melody-input {
        min-height: 150px;
    }
    
    .pattern-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .pattern-controls button {
        width: 100%;
        max-width: 200px;
    }
    
    .manage-dialog {
        margin: 10px;
        max-width: 95%;
    }
    
    .manage-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .item-actions {
        width: 100%;
        justify-content: flex-end;
    }
}
    
    .manage-dialog {
        margin: 10px;
        max-width: 95%;
    }
    

    
    .manage-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .item-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.8rem;
    }
    
    .music-player {
        margin: 5px;
        padding: 10px;
    }
    
    #play-btn, #stop-btn {
        padding: 10px 20px;
        font-size: 1rem;
    }
    
    .dialog-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    /* Responsive design for new features */
    @media (max-width: 768px) {
        .loop-controls {
            flex-direction: column;
            gap: 10px;
        }
        
        .volume-controls {
            max-width: 100%;
        }
        
        .track-controls {
            flex-direction: column;
            gap: 10px;
        }
        
        .pattern-tabs {
            flex-wrap: wrap;
        }
        

        
        .visualization-container {
            grid-template-columns: 1fr;
        }
        
        .grid-container {
            grid-template-columns: 1fr;
        }
}

/* Pattern hints styling */
.pattern-hints {
    margin-top: 10px;
    padding: 15px;
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    font-size: 0.85rem;
    line-height: 1.4;
    animation: slideIn 0.3s ease-out;
}

.hints-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-weight: 600;
    color: #856404;
}

.hints-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #856404;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.hints-close:hover {
    background-color: #ffeaa7;
}

.hints-list {
    color: #7d6608;
}

.hint-item {
    margin-bottom: 5px;
    padding-left: 5px;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
    
    .pattern-library-dialog {
        margin: 10px;
        max-width: 95%;
    }
    
    .library-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-container {
        max-width: none;
    }
    
    .library-grid {
        grid-template-columns: 1fr;
    }
}
}