/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    color: #ffffff;
    overflow: hidden;
    user-select: none;
}

/* Main container with responsive height */
.sequencer-container {
    width: 100%;
    height: 100vh;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Check if running in iframe and adjust height */
@media (max-height: 500px) {
    .sequencer-container {
        height: 450px;
    }
}

/* Transport controls section */
.transport-section {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    backdrop-filter: blur(10px);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.transport-btn {
    background: linear-gradient(145deg, #2d3748, #4a5568);
    border: none;
    border-radius: 6px;
    color: white;
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    min-height: 36px;
    min-width: 36px;
}

.transport-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
    background: linear-gradient(145deg, #4a5568, #2d3748);
}

.transport-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.play-btn.playing {
    background: linear-gradient(145deg, #38a169, #2f855a);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.tempo-control, .swing-control {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Added styles for master filter controls */
.master-filter-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.filter-control {
    display: flex;
    align-items: center;
    gap: 4px;
}

.control-label {
    font-size: 11px;
    font-weight: bold;
    min-width: 30px;
}

.slider {
    width: 60px;
    height: 4px;
    background: #4a5568;
    outline: none;
    border-radius: 2px;
    cursor: pointer;
}

.slider::-webkit-slider-thumb {
    appearance: none;
    width: 12px;
    height: 12px;
    background: #63b3ed;
    border-radius: 50%;
    cursor: pointer;
}

.slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: #63b3ed;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* Updated cutoff and resonance slider colors for master controls */
.cutoff-slider::-webkit-slider-thumb {
    background: #68d391;
}

.resonance-slider::-webkit-slider-thumb {
    background: #f687b3;
}

.cutoff-slider::-moz-range-thumb {
    background: #68d391;
}

.resonance-slider::-moz-range-thumb {
    background: #f687b3;
}

/* Step indicator - Fixed grid layout for proper alignment */
.step-indicator {
    flex-shrink: 0;
}

.step-numbers {
    display: grid;
    grid-template-columns: 60px repeat(16, 1fr) 80px; /* Matches track row layout */
    gap: 2px;
    padding: 0 8px;
}

/* Added spacer elements for proper alignment */
.step-spacer {
    /* Empty spacer elements to align with track labels and controls */
}

.step-num {
    text-align: center;
    font-size: 10px;
    font-weight: bold;
    color: #a0aec0;
    padding: 2px;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.step-num.active {
    background: #63b3ed;
    color: #1a202c;
    transform: scale(1.1);
}

/* Main sequencer grid */
.sequencer-grid {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow-y: auto;
}

.track-row {
    display: grid;
    grid-template-columns: 60px 1fr 80px; /* Reduced width for track controls */
    gap: 4px;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 8px;
    border-radius: 6px;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}

.track-row:hover {
    background: rgba(255, 255, 255, 0.1);
    border-left-color: #63b3ed;
}

/* Added special styling for bass track */
.bass-track {
    border-left-color: #9f7aea;
    background: rgba(159, 122, 234, 0.1);
}

.bass-track:hover {
    border-left-color: #b794f6;
    background: rgba(159, 122, 234, 0.15);
}

.track-label {
    font-size: 11px;
    font-weight: bold;
    text-align: center;
    color: #e2e8f0;
    cursor: help;
}

.step-buttons {
    display: grid;
    grid-template-columns: repeat(16, 1fr);
    gap: 2px;
}

.step-btn {
    aspect-ratio: 1;
    background: linear-gradient(145deg, #2d3748, #4a5568);
    border: 1px solid #4a5568;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    min-height: 24px;
}

.step-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.step-btn.active {
    background: linear-gradient(145deg, #f6ad55, #ed8936);
    border-color: #ed8936;
    box-shadow: 0 0 8px rgba(246, 173, 85, 0.5);
}

/* Special styling for bass track step buttons */
.bass-track .step-btn.active {
    background: linear-gradient(145deg, #b794f6, #9f7aea);
    border-color: #9f7aea;
    box-shadow: 0 0 8px rgba(183, 148, 246, 0.5);
}

.step-btn.playing {
    animation: stepPulse 0.1s ease;
}

@keyframes stepPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Simplified track controls - only volume slider */
.track-controls {
    display: flex;
    align-items: center;
    justify-content: center;
}

.volume-slider {
    width: 100%;
    height: 3px;
}

/* Preset section */
.preset-section {
    display: flex;
    gap: 4px;
    padding: 4px 8px;
    flex-shrink: 0;
}

.preset-btn {
    flex: 1;
    background: linear-gradient(145deg, #553c9a, #6b46c1);
    border: none;
    border-radius: 6px;
    color: white;
    padding: 6px 8px;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 28px;
}

.preset-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(107, 70, 193, 0.4);
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s ease;
    max-width: 200px;
    text-align: center;
}

.tooltip.show {
    opacity: 1;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .sequencer-container {
        padding: 4px;
        gap: 4px;
    }
    
    .transport-section {
        flex-wrap: wrap;
        gap: 4px;
        padding: 4px;
    }
    
    .transport-btn {
        padding: 6px 8px;
        font-size: 12px;
        min-height: 32px;
        min-width: 32px;
    }
    
    .step-btn {
        min-height: 20px;
    }
    
    .track-label {
        font-size: 10px;
    }
    
    .preset-btn {
        font-size: 10px;
        padding: 4px 6px;
    }

    /* Adjust master filter controls for mobile */
    .master-filter-controls {
        flex-direction: column;
        gap: 2px;
        padding: 2px 4px;
    }

    .filter-control {
        gap: 2px;
    }
}

/* High contrast mode for accessibility */
@media (prefers-contrast: high) {
    .step-btn.active {
        background: #ffff00;
        color: #000000;
    }
    
    .step-num.active {
        background: #ffff00;
        color: #000000;
    }
}