/* ===================================
   Piano MIDI Maestro - Base Styles
   =================================== */

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

:root {
    /* These will be overridden by themes */
    --primary-color: #3498db;
    --secondary-color: #2c3e50;
    --accent-color: #e74c3c;
    --success-color: #2ecc71;
    --warning-color: #f39c12;
    --bg-color: #ecf0f1;
    --card-bg: #ffffff;
    --text-color: #2c3e50;
    --text-secondary: #7f8c8d;
    --border-color: #bdc3c7;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.15);

    /* Piano colors */
    --white-key: #ffffff;
    --white-key-pressed: #e8e8e8;
    --black-key: #2c3e50;
    --black-key-pressed: #1a252f;
    --key-border: #999;
    --key-highlight: rgba(52, 152, 219, 0.3);

    /* Transitions */
    --transition: all 0.3s ease;
    --transition-fast: all 0.15s ease;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===================================
   Audio Loading Indicator
   =================================== */

.audio-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 0.5rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.9rem;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}

/* ===================================
   Header
   =================================== */

.app-header {
    background: var(--card-bg);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 1rem 0;
}

.app-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-header h1 {
    font-size: 1.8rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.midi-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition);
}

.midi-status:hover {
    border-color: var(--primary-color);
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--warning-color);
    animation: pulse 2s infinite;
}

.midi-status.connected .status-indicator {
    background: var(--success-color);
    animation: none;
}

.midi-status.disconnected .status-indicator {
    background: var(--accent-color);
}

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

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--primary-color);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
}

.icon-btn:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow);
}

/* ===================================
   Main Layout
   =================================== */

.main-container {
    display: flex;
    gap: 2rem;
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
}

/* ===================================
   Sidebar
   =================================== */

.sidebar {
    width: 250px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.game-modes h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.mode-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--card-bg);
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 0.5rem;
    box-shadow: var(--shadow);
}

.mode-btn .icon {
    font-size: 1.5rem;
}

.mode-btn .label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
}

.mode-btn:hover {
    border-color: var(--primary-color);
    transform: translateX(5px);
}

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

.mode-btn.active .label {
    color: white;
}

/* Progress Panel */
.progress-panel {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.progress-panel h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.stat-item:last-child {
    border-bottom: none;
}

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

.stat-value {
    font-weight: bold;
    color: var(--primary-color);
    font-size: 1.1rem;
}

/* ===================================
   Game Area
   =================================== */

.game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Challenge Display */
.challenge-display {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.challenge-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.challenge-header h2 {
    font-size: 1.5rem;
    color: var(--text-color);
}

.timer {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--warning-color);
    min-width: 80px;
    text-align: right;
}

.challenge-content {
    text-align: center;
}

.note-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin: 2rem 0;
}

.note-main {
    font-size: 5rem;
    font-weight: bold;
    color: var(--primary-color);
    animation: fadeInScale 0.5s ease;
}

.note-alt {
    font-size: 2rem;
    color: var(--text-secondary);
    font-weight: 500;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.hint-area {
    margin: 1.5rem 0;
    padding: 1rem;
    background: var(--bg-color);
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.hint-text {
    color: var(--text-secondary);
    font-size: 1rem;
}

.feedback {
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1rem;
}

.feedback-message {
    padding: 1rem 2rem;
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: 600;
    animation: slideIn 0.3s ease;
}

.feedback-message.success {
    background: var(--success-color);
    color: white;
}

.feedback-message.error {
    background: var(--accent-color);
    color: white;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Piano Container */
.piano-container {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

#piano-canvas {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    cursor: pointer;
}

.piano-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.control-btn {
    padding: 0.75rem 1.5rem;
    border: 2px solid var(--border-color);
    background: white;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
}

.control-btn:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.control-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.control-btn.primary {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.control-btn.primary:hover {
    background: #2980b9;
}

/* Theory Panel */
.theory-panel {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.theory-panel h3 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.theory-content {
    color: var(--text-secondary);
    line-height: 1.8;
}

.theory-content p {
    margin-bottom: 0.5rem;
}

.theory-content ul {
    margin-left: 1.5rem;
    margin-top: 0.5rem;
}

.theory-content li {
    margin-bottom: 0.3rem;
}

/* ===================================
   Modal
   =================================== */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.5rem;
    color: var(--text-color);
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close-btn:hover {
    background: var(--bg-color);
    color: var(--accent-color);
}

.modal-body {
    padding: 2rem;
}

.setting-group {
    margin-bottom: 2rem;
}

.setting-group:last-child {
    margin-bottom: 0;
}

.setting-group h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text-color);
}

/* Theme Options */
.theme-options {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.theme-btn {
    flex: 1;
    min-width: 150px;
    padding: 1rem;
    border: 2px solid var(--border-color);
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.theme-btn:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.theme-btn.active {
    border-color: var(--primary-color);
    background: var(--bg-color);
}

.theme-preview {
    width: 60px;
    height: 40px;
    border-radius: 6px;
    display: block;
}

.modern-preview {
    background: linear-gradient(135deg, #3498db 0%, #2c3e50 100%);
}

.colorful-preview {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.classic-preview {
    background: linear-gradient(135deg, #8b7355 0%, #f5f5dc 100%);
}

/* Notation & Game Options */
.notation-options,
.game-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.radio-label,
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}

.radio-label:hover,
.checkbox-label:hover {
    background: var(--bg-color);
}

.radio-label input,
.checkbox-label input {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.radio-label span,
.checkbox-label span {
    color: var(--text-color);
    font-size: 0.95rem;
}

/* MIDI Device Select */
.midi-select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: var(--transition);
}

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

/* ===================================
   Responsive Design
   =================================== */

@media (max-width: 1024px) {
    .main-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        flex-direction: row;
        gap: 1rem;
    }

    .game-modes,
    .progress-panel {
        flex: 1;
    }
}

@media (max-width: 768px) {
    .app-header h1 {
        font-size: 1.3rem;
    }

    .sidebar {
        flex-direction: column;
    }

    .note-main {
        font-size: 3.5rem;
    }

    .note-alt {
        font-size: 1.5rem;
    }

    .piano-controls {
        flex-direction: column;
    }

    .control-btn {
        width: 100%;
    }
}

/* ===================================
   Utility Classes
   =================================== */

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
