/* CSS Variables for theming */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --accent-color: #f59e0b;
    --accent-active: #d97706;
    --bg-color: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --success-color: #22c55e;
    --danger-color: #ef4444;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --transition: all 0.2s ease;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* App Container */
.app-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    padding: 20px 0 30px;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Main Content */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Section Styles */
section {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

section h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* BPM Section */
.bpm-section {
    text-align: center;
}

.bpm-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
}

.bpm-value {
    font-size: 5rem;
    font-weight: 800;
    line-height: 1;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.bpm-label {
    font-size: 1.2rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: 4px;
}

.bpm-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    margin-bottom: 16px;
}

.bpm-slider {
    flex: 1;
    max-width: 200px;
    height: 8px;
    border-radius: 4px;
    background: var(--bg-tertiary);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.bpm-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.bpm-slider::-webkit-slider-thumb:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

.bpm-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
    box-shadow: var(--shadow);
}

.bpm-input-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.bpm-input-container label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.bpm-input {
    width: 80px;
    padding: 8px 12px;
    border: 2px solid var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    background: var(--bg-color);
    color: var(--text-primary);
    font-size: 1rem;
    text-align: center;
    transition: var(--transition);
}

.bpm-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Button Styles */
.btn {
    padding: 10px 16px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-adjust {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    min-width: 44px;
}

.btn-adjust:hover {
    background: var(--primary-color);
}

.btn-adjust:active {
    transform: scale(0.95);
}

/* Time Signature Section */
.time-signature-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
}

.time-select {
    padding: 12px 16px;
    font-size: 1.5rem;
    font-weight: 700;
    border: 2px solid var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    background: var(--bg-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}

.time-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.time-divider {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.common-signatures {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-signature {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    min-width: 60px;
}

.btn-signature:hover {
    background: var(--primary-color);
}

.btn-signature.active {
    background: var(--primary-color);
}

/* Beat Indicator Section */
.beat-indicator-section {
    text-align: center;
}

.beat-indicators {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.beat-indicator {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    transition: var(--transition);
    border: 3px solid transparent;
}

.beat-indicator.active {
    background: var(--primary-color);
    transform: scale(1.2);
    box-shadow: 0 0 20px var(--primary-color);
}

.beat-indicator.accent {
    border-color: var(--accent-color);
}

.beat-indicator.accent.active {
    background: var(--accent-color);
    box-shadow: 0 0 20px var(--accent-color);
}

/* Pendulum */
.pendulum-container {
    height: 60px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-end;
}

.pendulum {
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    position: relative;
    transform: translateX(0);
    transition: transform 0.1s linear;
}

.pendulum::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -100%);
    width: 4px;
    height: 40px;
    background: var(--text-secondary);
    border-radius: 2px;
}

.pendulum.left {
    transform: translateX(-80px);
}

.pendulum.right {
    transform: translateX(80px);
}

/* Accent Section */
.accent-section {
    text-align: center;
}

.accent-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.accent-beats {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.accent-beat {
    width: 44px;
    height: 44px;
    border-radius: var(--border-radius-sm);
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    color: var(--text-primary);
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.accent-beat:hover {
    border-color: var(--text-secondary);
}

.accent-beat.accented {
    background: var(--accent-color);
    border-color: var(--accent-active);
}

.accent-presets {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-preset {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 8px 12px;
}

.btn-preset:hover {
    background: var(--primary-color);
    color: var(--text-primary);
}

/* Tap Tempo Section */
.tap-tempo-section {
    text-align: center;
    background: transparent;
    padding: 10px;
    box-shadow: none;
}

.btn-tap {
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1.2rem;
    padding: 16px 32px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    border: 2px solid var(--bg-tertiary);
}

.btn-tap:hover {
    border-color: var(--primary-color);
    background: var(--bg-tertiary);
}

.btn-tap:active {
    transform: scale(0.98);
    background: var(--primary-color);
}

.tap-icon {
    font-size: 1.4rem;
}

.tap-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 10px;
}

/* Main Controls */
.main-controls {
    text-align: center;
    background: transparent;
    padding: 10px;
    box-shadow: none;
}

.btn-play {
    background: var(--success-color);
    color: var(--bg-color);
    font-size: 1.4rem;
    padding: 20px 48px;
    border-radius: 50px;
    box-shadow: var(--shadow-lg);
    min-width: 180px;
}

.btn-play:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
}

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

.btn-play.playing {
    background: var(--danger-color);
}

.play-icon {
    font-size: 1.2rem;
}

/* Volume Section */
.volume-section {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    background: transparent;
    padding: 10px;
    box-shadow: none;
}

.volume-section label {
    color: var(--text-secondary);
}

.volume-slider {
    flex: 1;
    max-width: 150px;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-tertiary);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text-primary);
    cursor: pointer;
    box-shadow: var(--shadow);
}

.volume-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text-primary);
    cursor: pointer;
    border: none;
}

#volumeValue {
    font-size: 0.9rem;
    color: var(--text-muted);
    min-width: 40px;
}

/* Footer */
footer {
    text-align: center;
    padding: 24px 0;
    margin-top: 20px;
    border-top: 1px solid var(--bg-tertiary);
}

footer p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

footer a:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 480px) {
    html {
        font-size: 14px;
    }

    .app-container {
        padding: 12px;
    }

    header h1 {
        font-size: 2rem;
    }

    .bpm-value {
        font-size: 4rem;
    }

    .bpm-controls {
        flex-wrap: wrap;
    }

    .bpm-slider {
        order: 1;
        max-width: 100%;
        width: 100%;
        margin-top: 10px;
    }

    section {
        padding: 16px;
    }

    .beat-indicator {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }

    .accent-beat {
        width: 40px;
        height: 40px;
    }

    .btn-play {
        padding: 16px 36px;
        font-size: 1.2rem;
    }

    .common-signatures {
        gap: 8px;
    }

    .btn-signature {
        min-width: 50px;
        padding: 8px 12px;
    }
}

@media (max-width: 360px) {
    .bpm-value {
        font-size: 3.5rem;
    }

    .bpm-controls {
        gap: 8px;
    }

    .btn-adjust {
        min-width: 40px;
        padding: 8px 12px;
    }
}

/* Animation for beat flash */
@keyframes beatFlash {
    0% {
        box-shadow: 0 0 0 0 var(--primary-color);
    }
    50% {
        box-shadow: 0 0 30px 10px var(--primary-color);
    }
    100% {
        box-shadow: 0 0 0 0 var(--primary-color);
    }
}

.beat-indicator.flash {
    animation: beatFlash 0.1s ease-out;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --bg-color: #000000;
        --bg-secondary: #1a1a1a;
        --bg-tertiary: #333333;
        --text-primary: #ffffff;
        --text-secondary: #cccccc;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }

    .pendulum {
        display: none;
    }
}
