/* Metronome Page Styles */
.metronome-page {
    background: var(--bg);
    min-height: 100vh;
}

.metronome-page .card {
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    background: var(--card);
    border: 1px solid rgba(255,255,255,0.08);
}

.metronome-page .card-header {
    background: linear-gradient(135deg, var(--brand1), var(--brand2));
    border: none;
    color: white;
}

/* === PRESETS SECTION === */
.presets-section {
    background: linear-gradient(135deg, rgba(255,127,80,0.05), rgba(255,77,77,0.05));
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 2px solid rgba(255,127,80,0.1);
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
    margin-top: 1rem;
}

.preset-card {
    background: var(--card);
    border: 2px solid rgba(255,255,255,0.1);
    border-radius: var(--border-radius);
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    overflow: hidden;
}

.preset-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 127, 80, 0.1), transparent);
    transition: left 0.5s ease;
}

.preset-card:hover::before {
    left: 100%;
}

.preset-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255,127,80,0.3);
    box-shadow: 0 8px 25px rgba(255, 127, 80, 0.2);
}

.preset-card.active {
    border-color: var(--brand1);
    background: linear-gradient(135deg, rgba(255,127,80,0.1), rgba(255,77,77,0.1));
    box-shadow: 0 4px 15px rgba(255, 127, 80, 0.3);
}

.preset-card.default-preset {
    border-color: rgba(0, 123, 255, 0.3);
}

.preset-card.default-preset.active {
    border-color: var(--info-color);
    background: linear-gradient(135deg, rgba(0, 123, 255, 0.1), rgba(108, 117, 125, 0.1));
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.2);
}

.preset-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand1), var(--brand2));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.default-preset .preset-icon {
    background: linear-gradient(135deg, var(--info-color), var(--primary-color));
}

.preset-info {
    flex: 1;
    min-width: 0;
}

.preset-name {
    font-weight: 600;
    color: var(--text);
    font-size: 1rem;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preset-details {
    font-size: 0.875rem;
    color: var(--muted);
    line-height: 1.3;
}

.preset-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.preset-card:hover .preset-actions {
    opacity: 1;
}

.preset-actions .btn {
    padding: 4px 8px;
    font-size: 0.75rem;
    border-radius: 4px;
}

.preset-empty-state {
    background: rgba(255,255,255,0.05);
    border: 2px dashed rgba(255,255,255,0.2);
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.preset-empty-state:hover {
    border-color: rgba(255,127,80,0.3);
    background: rgba(255,127,80,0.05);
}

.preset-empty-state i {
    font-size: 2rem;
    margin-bottom: 8px;
    display: block;
}

/* === KEY VISUALS SECTION === */
.metronome-visuals-section {
    background: linear-gradient(135deg, rgba(255,127,80,0.03), rgba(255,77,77,0.03));
    border-radius: var(--border-radius-lg);
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid rgba(255,127,80,0.1);
}

/* BPM Display with integrated slider */
.bpm-control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.bpm-display {
    background: linear-gradient(135deg, var(--brand1), var(--brand2));
    border-radius: 50%;
    width: 120px;
    height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.bpm-display::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.1), transparent);
    transform: rotate(45deg);
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { transform: rotate(45deg) translateX(-100%); }
    50% { transform: rotate(45deg) translateX(100%); }
}

.bpm-value {
    font-size: 2.5rem;
    font-weight: 900;
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    line-height: 1;
    position: relative;
    z-index: 1;
}

.bpm-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: rgba(255,255,255,0.9);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    position: relative;
    z-index: 1;
}

.bpm-slider-container {
    width: 100%;
    max-width: 300px;
}

/* Enhanced Tempo Name Display */
.tempo-name-display {
    background: linear-gradient(135deg, rgba(255,127,80,0.2), rgba(255,77,77,0.2));
    border: 2px solid rgba(255,127,80,0.3);
    border-radius: 50px;
    padding: 12px 30px;
    display: inline-block;
    backdrop-filter: blur(10px);
    animation: gentle-pulse 3s infinite;
    transition: all 0.3s ease;
}

.tempo-name-display:hover {
    transform: scale(1.05);
    border-color: rgba(255,127,80,0.5);
    background: linear-gradient(135deg, rgba(255,127,80,0.3), rgba(255,77,77,0.3));
}

@keyframes gentle-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.tempo-name {
    color: var(--text);
    font-size: 1.5rem;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.5s ease-in-out;
}

/* Enhanced Visual Metronome */
.metronome-visual {
    margin: 30px 0;
}

.beat-counter {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--text);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.1s ease;
    margin-bottom: 1.5rem;
}

.current-beat {
    color: var(--brand1);
    font-size: 3rem;
    text-shadow: 0 0 15px rgba(255, 127, 80, 0.4);
    transition: all 0.1s ease;
}

.beat-separator {
    color: var(--muted);
    margin: 0 15px;
    font-size: 2rem;
}

.total-beats {
    color: var(--muted);
    font-size: 2rem;
}

.beat-indicator {
    display: inline-block;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand1), var(--brand2));
    position: relative;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
    animation: none;
    margin: 0 auto;
}

.beat-indicator:hover {
    transform: scale(1.05);
    box-shadow: 0 15px 40px rgba(255, 127, 80, 0.3);
}

.beat-indicator.active {
    animation: beatPulse var(--beat-duration, 1s) infinite;
    box-shadow: 0 10px 30px rgba(255, 127, 80, 0.4);
}

.beat-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    transition: all 0.1s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.beat-circle.first-beat {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    box-shadow: 0 0 25px rgba(255, 107, 107, 0.8), inset 0 2px 4px rgba(0, 0, 0, 0.1);
    animation: firstBeatPulse 0.2s ease-in-out;
}

.beat-indicator.active .beat-circle {
    animation: beatScale var(--beat-duration, 1s) infinite;
}

/* Control Buttons */
.control-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

/* === ADVANCED SETTINGS SECTION === */
.advanced-settings-section {
    background: var(--card);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    border: 1px solid rgba(255,255,255,0.05);
}

.advanced-settings-content {
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* BPM Slider */
.bpm-slider {
    height: 12px;
    border-radius: 6px;
    background: rgba(255,255,255,0.1);
    outline: none;
    transition: all 0.2s ease;
    appearance: none;
}

.bpm-slider:hover {
    background: rgba(255,255,255,0.15);
}

.bpm-slider::-webkit-slider-thumb {
    appearance: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand1), var(--brand2));
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}

.bpm-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 6px 20px rgba(255, 127, 80, 0.5);
}

.bpm-slider::-moz-range-thumb {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand1), var(--brand2));
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}

/* Beats Selector */
.beats-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.beat-btn {
    min-width: 48px;
    height: 48px;
    border-radius: 50% !important;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border: 2px solid rgba(255,127,80,0.3) !important;
    background: transparent !important;
    color: var(--text) !important;
}

.beat-btn:hover {
    transform: scale(1.1);
    border-color: var(--brand1) !important;
    background: rgba(255,127,80,0.1) !important;
}

.btn-check:checked + .beat-btn {
    background: linear-gradient(135deg, var(--brand1), var(--brand2)) !important;
    border-color: var(--brand1) !important;
    color: white !important;
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(255, 127, 80, 0.4);
}

.extended-beats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* Enhanced Button Styles */
.metronome-page .btn {
    border-radius: 25px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.metronome-page .btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
}

.metronome-page .btn:hover::before {
    width: 100%;
    height: 100%;
}

.metronome-page .btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.metronome-page .btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.metronome-page .btn-success {
    background: linear-gradient(135deg, var(--success-color), var(--info-color));
    border: none;
    font-size: 1.1rem;
    padding: 12px 30px;
}

.metronome-page .btn-outline-secondary {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.16);
    color: var(--text);
}

.metronome-page .btn-outline-secondary:hover:not(:disabled) {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.3);
}

/* Form Controls */
.metronome-page .form-select {
    border-radius: 12px;
    border: 2px solid rgba(255,255,255,0.16);
    transition: all 0.3s ease;
    background-color: var(--card);
    color: var(--text);
    padding: 12px 16px;
    font-weight: 500;
}

.metronome-page .form-select:focus {
    border-color: var(--brand1);
    box-shadow: 0 0 0 0.2rem rgba(255, 127, 80, 0.25);
    background-color: var(--card);
    color: var(--text);
}

.metronome-page .form-select option {
    background-color: var(--card);
    color: var(--text);
}

/* Enhanced Animations */
@keyframes beatPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 10px 30px rgba(255, 127, 80, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 15px 40px rgba(255, 127, 80, 0.6);
    }
}

@keyframes beatScale {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.15);
    }
}

@keyframes firstBeatPulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        box-shadow: 0 0 25px rgba(255, 107, 107, 0.8);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
        box-shadow: 0 0 35px rgba(255, 107, 107, 1);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        box-shadow: 0 0 25px rgba(255, 107, 107, 0.8);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Audio Error Alert */
.alert-warning {
    background: linear-gradient(135deg, rgba(250, 204, 21, 0.1), rgba(251, 191, 36, 0.1));
    border: 1px solid rgba(250, 204, 21, 0.3);
    border-radius: var(--border-radius);
    color: #fde047;
}

.alert-warning .btn-outline-warning {
    color: #fde047;
    border-color: rgba(250, 204, 21, 0.5);
}

.alert-warning .btn-outline-warning:hover {
    background: rgba(250, 204, 21, 0.2);
    border-color: rgba(250, 204, 21, 0.7);
    color: #fde047;
}

/* Responsive Design */
@media (max-width: 768px) {
    .preset-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .presets-section {
        padding: 1rem;
    }

    .metronome-visuals-section {
        padding: 1.5rem;
    }

    .bpm-display {
        width: 100px;
        height: 100px;
    }

    .bpm-value {
        font-size: 2rem;
    }

    .tempo-name {
        font-size: 1.2rem;
    }

    .tempo-name-display {
        padding: 10px 24px;
    }

    .beat-indicator {
        width: 120px;
        height: 120px;
    }

    .beat-circle {
        width: 70px;
        height: 70px;
    }

    .beat-counter {
        font-size: 2rem;
    }

    .current-beat {
        font-size: 2.5rem;
    }

    .beat-separator,
    .total-beats {
        font-size: 1.5rem;
    }

    .beat-btn {
        min-width: 44px;
        height: 44px;
        font-size: 0.9rem;
    }

    .beats-selector {
        gap: 6px;
    }

    .control-buttons {
        flex-direction: column;
        gap: 0.75rem;
    }

    .control-buttons .btn {
        width: 100%;
        max-width: 200px;
    }
}

@media (max-width: 480px) {
    .metronome-visuals-section,
    .presets-section,
    .advanced-settings-section {
        padding: 1rem;
    }

    .bpm-display {
        width: 90px;
        height: 90px;
    }

    .bpm-value {
        font-size: 1.75rem;
    }

    .bpm-label {
        font-size: 0.75rem;
    }

    .tempo-name {
        font-size: 1rem;
    }

    .beat-indicator {
        width: 100px;
        height: 100px;
    }

    .beat-circle {
        width: 60px;
        height: 60px;
    }

    .beat-btn {
        min-width: 40px;
        height: 40px;
        font-size: 0.85rem;
    }

    .beats-selector {
        gap: 4px;
    }

    .preset-card {
        padding: 0.75rem;
        gap: 8px;
    }

    .preset-icon {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    .preset-name {
        font-size: 0.9rem;
    }

    .preset-details {
        font-size: 0.8rem;
    }
}

/* Loading Animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spinner-border {
    animation: spin 1s linear infinite;
}

/* Alert Animations */
.alert {
    animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Focus states for accessibility */
.btn:focus-visible {
    outline: 2px solid var(--brand1);
    outline-offset: 2px;
}

.form-control:focus-visible,
.form-select:focus-visible {
    outline: 2px solid var(--brand1);
    outline-offset: 2px;
}

.bpm-slider:focus-visible {
    outline: 2px solid var(--brand1);
    outline-offset: 4px;
}

.beat-btn:focus-visible,
.preset-card:focus-visible {
    outline: 2px solid var(--brand1);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .beat-indicator {
        border: 2px solid var(--text);
    }
    
    .beat-circle {
        border: 1px solid var(--text);
    }
    
    .btn {
        border: 2px solid currentColor;
    }

    .bpm-display {
        border: 2px solid var(--text);
    }

    .preset-card {
        border: 2px solid var(--text);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .beat-indicator.active,
    .beat-circle,
    .tempo-name-display,
    .bpm-display::before,
    .preset-card::before {
        animation: none;
    }
    
    .btn::before {
        transition: none;
    }
    
    .advanced-settings-content {
        animation: none;
    }
}

/* Dark mode enhancements */
@media (prefers-color-scheme: dark) {
    .metronome-page {
        /* Already dark by default, but ensure consistency */
        background: var(--bg);
    }
}