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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #2c1810, #8B4513);
    color: #333;
    overflow-x: hidden;
}

/* Main container - responsive height based on environment */
.main-container {
    width: 100%;
    height: 450px; /* Default iframe height */
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Detect if not in iframe and adjust height */
@media (min-height: 500px) {
    .main-container {
        height: 90vh;
        gap: 12px;
        padding: 15px;
    }
}

/* Control Panel */
.control-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    flex-wrap: wrap;
    gap: 8px;
}

.tempo-control {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

/* Added drone control styling */
.drone-control {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.drone-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

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

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: #8B4513;
    border-radius: 50%;
    cursor: pointer;
}

.mode-buttons {
    display: flex;
    gap: 4px;
}

.mode-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    background: #e9ecef;
    color: #495057;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.mode-btn.active {
    background: #8B4513;
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.mode-btn:hover {
    background: #6c757d;
    color: white;
    transform: translateY(-1px);
}

.playback-controls {
    display: flex;
    gap: 6px;
}

.control-btn {
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    background: #28a745;
    color: white;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
    min-height: 36px;
    white-space: nowrap;
}

.control-btn:hover {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.control-btn:active {
    transform: translateY(0);
}

/* Rebana Section */
.rebana-section {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 8px;
    padding: 15px;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.1);
}

.rebana-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.rebana-drum {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle, #8B4513, #654321);
    border: 4px solid #4a2c17;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
    position: relative;
}

.rebana-drum:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.4);
}

.rebana-drum.active {
    transform: scale(0.95);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.drum-surface {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 30% 30%, #a0522d, #8B4513);
}

.drum-center {
    color: white;
    font-weight: bold;
    font-size: 14px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

/* Updated Rhythm Pattern - Corrected 4/4 bar structure */
.rhythm-pattern {
    text-align: center;
}

.pattern-title {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 8px;
    color: #495057;
}

.pattern-beats {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.bar {
    display: flex;
    gap: 2px;
    padding: 4px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.5);
}

.beat {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 12px;
    transition: all 0.3s ease;
    border-radius: 3px;
}

/* Note duration styling */
.beat.crotchet {
    width: 32px;
    height: 32px;
    font-size: 14px;
}

.beat.quaver {
    width: 24px;
    height: 24px;
    font-size: 12px;
}

.beat.semiquaver {
    width: 18px;
    height: 18px;
    font-size: 10px;
}

.beat.tak {
    background: #28a745;
    color: white;
}

.beat.kah {
    background: #dc3545;
    color: white;
}

.beat.active {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

.pattern-notation {
    font-size: 14px;
    font-weight: bold;
    color: #8B4513;
    letter-spacing: 1px;
    font-family: monospace;
}

/* Lyrics Section */
.lyrics-section {
    flex: 1.2;
    background: #fff;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
}

.lyrics-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.lyric-line {
    padding: 10px;
    border-radius: 6px;
    background: #f8f9fa;
    border-left: 4px solid #8B4513;
    transition: all 0.3s ease;
    position: relative;
}

.lyric-line:hover {
    background: #e9ecef;
    transform: translateX(2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.lyric-line.active {
    background: #fff3cd;
    border-left-color: #ffc107;
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.3);
}

.malay-text {
    font-size: 16px;
    font-weight: 600;
    color: #2c1810;
    margin-bottom: 4px;
}

.phonetic-guide {
    font-size: 12px;
    color: #6c757d;
    font-style: italic;
    margin-bottom: 8px;
    cursor: help;
}

.practice-line-btn {
    padding: 4px 8px;
    border: none;
    border-radius: 3px;
    background: #17a2b8;
    color: white;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.3s ease;
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
}

.practice-line-btn:hover {
    background: #138496;
    transform: translateY(-50%) scale(1.05);
}

/* Bottom Section */
.bottom-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 6px;
    gap: 15px;
}

.progress-tracker {
    display: flex;
    gap: 15px;
    flex: 1;
}

.progress-item {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.progress-label {
    font-size: 12px;
    font-weight: 600;
    color: #495057;
    white-space: nowrap;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #28a745, #20c997);
    width: 0%;
    transition: width 0.5s ease;
}

.cultural-context {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: help;
    padding: 6px 10px;
    border-radius: 4px;
    background: rgba(139, 69, 19, 0.1);
    transition: all 0.3s ease;
}

.cultural-context:hover {
    background: rgba(139, 69, 19, 0.2);
    transform: scale(1.02);
}

.context-icon {
    font-size: 16px;
}

/* Recording Status */
.recording-status {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(220, 53, 69, 0.95);
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

.recording-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: bold;
}

/* Metronome */
.metronome {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 60px;
    background: #343a40;
    border-radius: 4px;
    display: none;
    z-index: 100;
}

.metronome.active {
    display: block;
}

.metronome-pendulum {
    width: 2px;
    height: 50px;
    background: #ffc107;
    margin: 5px auto;
    transform-origin: top center;
    transition: transform 0.1s ease;
}

.metronome-pendulum.tick {
    transform: rotate(15deg);
}

.metronome-pendulum.tock {
    transform: rotate(-15deg);
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .main-container {
        padding: 8px;
        gap: 6px;
    }
    
    .control-panel {
        flex-direction: column;
        gap: 6px;
        padding: 8px;
    }
    
    .mode-buttons, .playback-controls {
        width: 100%;
        justify-content: center;
    }
    
    .rebana-drum {
        width: 100px;
        height: 100px;
    }
    
    .pattern-beats {
        flex-wrap: wrap;
        gap: 3px;
    }
    
    .bar {
        gap: 1px;
        padding: 2px;
    }
    
    .beat.crotchet {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
    
    .beat.quaver {
        width: 20px;
        height: 20px;
        font-size: 10px;
    }
    
    .beat.semiquaver {
        width: 16px;
        height: 16px;
        font-size: 8px;
    }
    
    .malay-text {
        font-size: 14px;
    }
    
    .progress-tracker {
        flex-direction: column;
        gap: 8px;
    }
    
    .bottom-section {
        flex-direction: column;
        gap: 10px;
    }
}

/* Touch-friendly interactions */
@media (hover: none) and (pointer: coarse) {
    .control-btn, .mode-btn, .practice-line-btn {
        min-height: 44px;
        padding: 12px 16px;
    }
    
    .rebana-drum {
        width: 140px;
        height: 140px;
    }
    
    .beat.crotchet {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .beat.quaver {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .beat.semiquaver {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
}

/* Accessibility improvements */
.control-btn:focus, .mode-btn:focus, .practice-line-btn:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.rebana-drum:focus {
    outline: 3px solid #007bff;
    outline-offset: 3px;
}

/* Animation keyframes */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.rebana-drum.playing {
    animation: pulse 0.2s ease-in-out;
}

/* Tooltip styles */
[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
}