/* CSS Variables for theming */
:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --accent-color: #f093fb;
    --success-color: #4ade80;
    --warning-color: #fbbf24;
    --error-color: #f87171;
    
    --bg-primary: #1e1e2e;
    --bg-secondary: #313244;
    --bg-tertiary: #45475a;
    --text-primary: #cdd6f4;
    --text-secondary: #bac2de;
    --text-muted: #6c7086;
    
    --border-radius: 12px;
    --border-radius-sm: 6px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.2);
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

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

/* Header */
.app-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: var(--border-radius);
    padding: 1.5rem 2rem;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-lg);
    flex-wrap: wrap;
    gap: 1rem;
}

.app-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.level-display {
    display: flex;
    gap: 1rem;
    align-items: center;
    color: white;
    font-weight: 600;
}

.streak {
    color: white;
    font-weight: 600;
    font-size: 1.1rem;
}

/* Navigation tabs */
.tab-navigation {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    padding: 0.5rem;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    overflow-x: auto;
}

.tab-button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    min-width: fit-content;
}

.tab-button:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.tab-button.active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    box-shadow: var(--shadow);
}

/* Main content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.tab-content {
    display: none;
    flex: 1;
    animation: fadeIn 0.3s ease-in;
}

.tab-content.active {
    display: block;
}

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

/* Staff container */
.staff-container {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
}

#music-staff {
    width: 100%;
    max-width: 800px;
    height: 200px;
    border-radius: var(--border-radius-sm);
}

#exercise-staff {
    width: 100%;
    max-width: 400px;
    height: 150px;
    border-radius: var(--border-radius-sm);
}

.staff-controls {
    margin-top: 1rem;
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

/* Piano keyboard */
.piano-container {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 2rem 1rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
    overflow-x: auto;
}

.piano-keyboard {
    position: relative;
    height: 200px;
    margin: 0 auto;
}

.piano-keyboard.small {
    height: 120px;
}

.piano-key {
    position: relative;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid #ddd;
    user-select: none;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 10px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.piano-key.white {
    position: absolute;
    top: 0;
    width: 40px;
    height: 200px;
    background: linear-gradient(to bottom, #ffffff 0%, #f8f8f8 100%);
    z-index: 1;
    color: #333;
    border: 1px solid #ccc;
    border-radius: 0 0 4px 4px;
}

.piano-keyboard.small .piano-key.white {
    width: 30px;
    height: 120px;
    font-size: 0.8rem;
}

.piano-key.black {
    width: 26px;
    height: 130px;
    background: linear-gradient(to bottom, #2a2a2a 0%, #1a1a1a 100%);
    position: absolute;
    top: 0;
    z-index: 2;
    color: white;
    font-size: 0.75rem;
    border-radius: 0 0 3px 3px;
}

.piano-keyboard.small .piano-key.black {
    width: 20px;
    height: 80px;
    font-size: 0.7rem;
}

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

.piano-key.active {
    transform: translateY(4px);
    filter: brightness(1.3);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.piano-key.correct {
    background: linear-gradient(to bottom, var(--success-color), #22c55e);
    color: white;
}

.piano-key.wrong {
    background: linear-gradient(to bottom, var(--error-color), #ef4444);
    color: white;
}

/* Quick actions */
.quick-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

/* Buttons */
button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius-sm);
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    filter: brightness(1.1);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Exercise specific styles */
.exercise-header {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.exercise-header h2 {
    color: var(--text-primary);
    margin: 0;
}

.difficulty-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
}

.exercise-content {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.exercise-staff-container {
    background: white;
    border-radius: var(--border-radius-sm);
    padding: 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
}

.exercise-info {
    text-align: center;
    margin-bottom: 1.5rem;
}

.score-display {
    display: flex;
    gap: 2rem;
    justify-content: center;
    margin-top: 0.5rem;
    font-weight: 600;
}

.exercise-keyboard {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    padding: 1rem 0;
}

.exercise-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Songs section */
.songs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.songs-content {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
}

.song-filters {
    margin-bottom: 1.5rem;
}

.songs-list {
    display: grid;
    gap: 1rem;
}

.song-item {
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
    border-left: 4px solid var(--primary-color);
}

.song-item:hover {
    transform: translateX(5px);
    box-shadow: var(--shadow);
}

.song-info h4 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

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

.song-status {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.song-status.new { background: var(--warning-color); color: white; }
.song-status.practicing { background: var(--primary-color); color: white; }
.song-status.almost { background: var(--accent-color); color: white; }
.song-status.mastered { background: var(--success-color); color: white; }

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: var(--bg-secondary);
    margin: 5% auto;
    padding: 2rem;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    position: relative;
    animation: slideIn 0.3s ease-out;
}

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

.close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
}

.close:hover {
    color: var(--text-primary);
}

/* Forms */
input, select, textarea {
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 1rem;
    border: 2px solid var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
    transition: var(--transition);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Chat interface */
.tutor-header {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--text-primary);
}

.chat-container {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 1rem;
    box-shadow: var(--shadow-lg);
    height: 500px;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.tutor-message, .user-message {
    max-width: 80%;
    padding: 1rem;
    border-radius: var(--border-radius-sm);
    animation: messageSlideIn 0.3s ease-out;
}

.tutor-message {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    align-self: flex-start;
}

.user-message {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    align-self: flex-end;
}

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

.chat-input-container {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

#chat-input {
    flex: 1;
    margin-bottom: 0;
}

.config-section {
    margin-top: 2rem;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 1rem;
}

.config-content {
    padding: 1rem 0 0 0;
}

/* Progress section */
.progress-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.stat-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.achievements-section, .weekly-goals {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.achievements-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.achievement-item {
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
}

.achievement-item:hover {
    transform: scale(1.02);
}

.achievement-item.unlocked {
    background: linear-gradient(135deg, var(--success-color), #22c55e);
    color: white;
}

.achievement-icon {
    font-size: 2rem;
}

.achievement-info h4 {
    margin-bottom: 0.25rem;
}

.achievement-info p {
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Mobile responsive */
@media (max-width: 768px) {
    .app-container {
        padding: 0.5rem;
    }
    
    .app-header {
        padding: 1rem;
        flex-direction: column;
        text-align: center;
    }
    
    .app-header h1 {
        font-size: 1.5rem;
    }
    
    .tab-navigation {
        padding: 0.25rem;
        gap: 0.25rem;
    }
    
    .tab-button {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    .piano-container {
        padding: 1rem 0.5rem;
    }
    
    .exercise-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .songs-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .song-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
    
    .stat-card {
        padding: 1.5rem;
    }
    
    .stat-value {
        font-size: 2rem;
    }
    
    .tutor-message, .user-message {
        max-width: 95%;
    }
    
    .modal-content {
        margin: 10% auto;
        width: 95%;
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .app-header {
        padding: 0.75rem;
    }
    
    .level-display {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .quick-actions {
        flex-direction: column;
    }
    
    .exercise-controls {
        flex-direction: column;
    }
    
    .score-display {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .chat-container {
        height: 400px;
    }
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Success animations */
.success-flash {
    animation: successFlash 0.6s ease-in-out;
}

@keyframes successFlash {
    0%, 100% { background-color: inherit; }
    50% { background-color: var(--success-color); }
}