/* General Styles */
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

footer {
    margin-top: auto;
}

/* Match site-wide max-width: expand Bootstrap column constraints to full container.
   Covers col-lg-10 (main wrappers), col-lg-8 (ear-training, reading-staff),
   and col-lg-6 (settings, result cards) when used as centered layout wrappers. */
@media (min-width: 992px)
{
    .col-lg-10.mx-auto,
    .col-lg-8.mx-auto,
    .col-lg-6.mx-auto
    {
        flex: 0 0 auto;
        width: 100%;
        max-width: none;
    }
}

/* Fix header alignment - ensure it matches main site */
header .header-content {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 1.2rem 2rem !important;
}

header nav {
    display: flex !important;
    align-items: center !important;
}

/* Desktop: nav-links visible */
@media (min-width: 769px) {
    header .nav-links {
        display: flex !important;
        align-items: center !important;
        margin: 0 !important;
        padding: 0 !important;
    }
}

/* Mobile: nav-links hidden by default, shown when .active */
@media (max-width: 768px) {
    header nav .nav-links:not(.active) {
        display: none !important;
    }

    header .nav-links.active {
        display: flex !important;
    }
}

header .nav-links li {
    list-style: none !important;
    margin: 0 !important;
}

header .controls {
    display: flex !important;
    align-items: center !important;
}

/* Section Cards with colored backgrounds - WCAG compliant */
.section-card-blue {
    background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 100%);
}

.section-card-green {
    background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
}

.section-card-orange {
    background: linear-gradient(135deg, #FFF3E0 0%, #FFE0B2 100%);
}

/* Dark theme variants for section cards */
[data-theme="dark"] .section-card-blue {
    background: linear-gradient(135deg, #1A2332 0%, #1E3A5F 100%);
}

[data-theme="dark"] .section-card-green {
    background: linear-gradient(135deg, #1A2E1F 0%, #1E3A28 100%);
}

[data-theme="dark"] .section-card-orange {
    background: linear-gradient(135deg, #2E2318 0%, #3A2E1E 100%);
}

/* Ensure text contrast on colored cards */
.section-card-blue .card-title,
.section-card-green .card-title,
.section-card-orange .card-title {
    color: #1a1a1a;
}

.section-card-blue .card-text,
.section-card-green .card-text,
.section-card-orange .card-text {
    color: #2c2c2c !important;
}

[data-theme="dark"] .section-card-blue .card-title,
[data-theme="dark"] .section-card-green .card-title,
[data-theme="dark"] .section-card-orange .card-title {
    color: #E0E1DD;
}

[data-theme="dark"] .section-card-blue .card-text,
[data-theme="dark"] .section-card-green .card-text,
[data-theme="dark"] .section-card-orange .card-text {
    color: #C5C6C7 !important;
}

/* Scale Selection Buttons */
.scale-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.scale-btn {
    min-width: 70px;
    font-weight: 600;
}

/* Exercise Stats */
.exercise-stats {
    display: flex;
    gap: 10px;
    font-size: 1.1rem;
}

/* Staff Container - Responsive Music Notation */
#staffContainer {
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    margin: 0 auto;
    padding: 10px 0;
    /* Smooth scrolling for better UX if overflow occurs */
    -webkit-overflow-scrolling: touch;
}

/* Hide scrollbar on webkit browsers while keeping functionality */
#staffContainer::-webkit-scrollbar {
    height: 8px;
}

#staffContainer::-webkit-scrollbar-track {
    background: transparent;
}

#staffContainer::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

#staffContainer::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] #staffContainer::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] #staffContainer::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Question Card */
.question-card {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    color: white;
    padding: 0.5rem 1.5rem; /* Reduced only vertical padding, kept horizontal */
    border: none;
}

.question-card h2 {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 0; /* Remove default margin */
    color: white !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); /* Improve contrast */
}

/* Compact spacing for exercises */
#exerciseArea .mb-4 {
    margin-bottom: 0.75rem !important;
}

#exerciseArea .mb-3 {
    margin-bottom: 0.5rem !important;
}

#exerciseArea .mt-4 {
    margin-top: 0.75rem !important;
}

#exerciseArea .my-4 {
    margin-top: 0.75rem !important;
    margin-bottom: 0.75rem !important;
}

/* Note Buttons Container */
.keyboard-container {
    padding: 10px 0;
}

.note-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    max-width: 800px;
    margin: 0 auto;
    justify-content: center;
}

/* Chromatic notes layout - 2 rows of 6 notes */
.note-buttons.chromatic-layout {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
    max-width: 600px;
}

/* Piano Layout - Keyboard style */
.note-buttons.piano-layout {
    display: grid;
    grid-template-columns: repeat(30, 1fr);
    grid-template-rows: 60px 80px;
    gap: 2px;
    max-width: 100%;
    margin: 0 auto;
    position: relative;
    padding: 0 10px;
}

/* Note Buttons */
.note-btn {
    min-width: 70px;
    font-weight: 600;
    font-size: 1.1rem;
    transition: all 0.15s ease;
    padding: 0.5rem 1rem;
}

/* Normal layout - increased vertical padding */
.note-buttons:not(.piano-layout) .note-btn {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

/* Piano layout specific styles */
.piano-layout .note-btn {
    min-width: unset;
    border-radius: 0 0 4px 4px;
    font-size: 0.75rem;
    padding: 2px 1px;
    margin: 0;
}

.piano-layout .note-natural {
    grid-row: 2;
    z-index: 1;
    border-radius: 0 0 6px 6px;
    border: 2px solid #888;
    border-top: 1px solid #888;
}

.piano-layout .note-altered {
    grid-row: 1;
    z-index: 2;
    height: 100%;
    border-radius: 0 0 4px 4px;
    border: 1px solid #000;
}

.note-natural {
    background: white;
    border: 2px solid #6c757d;
    color: #333;
}

.note-natural:hover {
    background: #f8f9fa;
    color: #333;
    transform: translateY(-2px);
}

.note-natural:active,
.note-natural:focus {
    background: white !important;
    border-color: #6c757d !important;
    color: #333 !important;
    box-shadow: none !important;
}

.note-altered {
    background: #212529;
    border: 2px solid #000;
    color: white;
}

.note-altered:hover {
    background: #343a40;
    transform: translateY(-2px);
}

.note-altered:active,
.note-altered:focus {
    background: #212529 !important;
    border-color: #000 !important;
    color: white !important;
    box-shadow: none !important;
}

.note-btn.correct,
.interval-btn.correct {
    background: #22c55e !important;
    border-color: #16a34a !important;
    color: white !important;
    animation: flash-correct 0.5s ease;
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.6) !important;
}

.note-btn.incorrect,
.interval-btn.incorrect {
    background: #ef4444 !important;
    border-color: #dc2626 !important;
    color: white !important;
    animation: flash-incorrect 0.5s ease;
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.6) !important;
}

/* Animations */
@keyframes flash-correct {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes flash-incorrect {
    0%, 100% { opacity: 1; }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

/* Result Card */
.result-card {
    margin-top: 50px;
    border: none;
}

.result-stats {
    font-size: 1.1rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .question-card h2 {
        font-size: 1.5rem;
    }

    .exercise-stats {
        font-size: 0.9rem;
    }

    .note-buttons {
        grid-template-columns: repeat(6, 1fr);
    }

    .note-btn {
        min-width: 50px;
        font-size: 0.9rem;
    }
}

@media (max-width: 576px) {
    .question-card h2 {
        font-size: 1.2rem;
    }

    .note-buttons {
        grid-template-columns: repeat(5, 1fr);
    }

    .note-btn {
        min-width: 45px;
        font-size: 0.85rem;
    }
}

/* Progress page styles */
.progress-card {
    border-left: 4px solid #2563eb;
}

.progress-card .badge {
    font-size: 1rem;
}

/* Statistics boxes */
.statistic-box {
    padding: 20px;
    margin: 10px 0;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    border: 2px solid #dee2e6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.statistic-value {
    font-size: 2rem;
    font-weight: bold;
    color: #2563eb;
}

.statistic-label {
    font-size: 0.9rem;
    color: #495057;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 5px;
    font-weight: 600;
}

/* History table styles */
.table-success {
    background-color: #d1f2eb !important;
    font-weight: 600;
}

/* Question card content - ensure readability when showing results */
.question-card .card-body {
    color: white;
}

.question-card .card-body h5,
.question-card .card-body p,
.question-card .card-body .lead,
.question-card .card-body strong {
    color: white !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.question-card .card-body .text-muted {
    color: rgba(255, 255, 255, 0.85) !important;
}

/* Tables inside question-card need white background for readability */
.question-card .table-responsive {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.question-card .table {
    color: #212529;
    margin-bottom: 0;
}

.question-card .table th {
    color: #495057;
    border-color: #dee2e6;
}

.question-card .table td {
    color: #212529;
    border-color: #dee2e6;
}

.question-card .table-responsive .text-muted {
    color: #6c757d !important;
}

/* Statistics boxes inside question-card */
.question-card .statistic-box {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(255, 255, 255, 0.3);
}

.question-card .statistic-value {
    color: #2563eb;
}

.question-card .statistic-label {
    color: #495057;
}

/* Alerts inside question-card */
.question-card .alert {
    color: #212529;
}

.question-card .alert-info {
    background-color: rgba(255, 255, 255, 0.9);
    border-color: #0dcaf0;
    color: #055160;
}

/* Dark theme adjustments for question-card content */
[data-theme="dark"] .question-card .card-body {
    color: #000000;
}

[data-theme="dark"] .question-card .card-body h5,
[data-theme="dark"] .question-card .card-body p,
[data-theme="dark"] .question-card .card-body .lead,
[data-theme="dark"] .question-card .card-body strong {
    color: #000000 !important;
}

[data-theme="dark"] .question-card .card-body .text-muted {
    color: rgba(0, 0, 0, 0.7) !important;
}

[data-theme="dark"] .question-card .table-responsive {
    background: #1B263B;
}

[data-theme="dark"] .question-card .table {
    color: #E0E1DD;
}

[data-theme="dark"] .question-card .table th {
    color: #C5C6C7;
    border-color: #415A77;
}

[data-theme="dark"] .question-card .table td {
    color: #E0E1DD;
    border-color: #415A77;
}

[data-theme="dark"] .question-card .table-responsive .text-muted {
    color: #9CA3AF !important;
}

[data-theme="dark"] .question-card .table-striped > tbody > tr:nth-of-type(odd) {
    background-color: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .question-card .table-success {
    background-color: rgba(34, 197, 94, 0.3) !important;
    color: #E0E1DD;
}

[data-theme="dark"] .question-card .statistic-box {
    background: rgba(27, 38, 59, 0.95);
    border-color: #415A77;
}

[data-theme="dark"] .question-card .statistic-value {
    color: #5FA8D3;
}

[data-theme="dark"] .question-card .statistic-label {
    color: #C5C6C7;
}

[data-theme="dark"] .question-card .alert-info {
    background-color: rgba(27, 38, 59, 0.9);
    border-color: var(--accent);
    color: #E0E1DD;
}

/* Responsive statistics */
@media (max-width: 768px) {
    .statistic-value {
        font-size: 1.5rem;
    }

    .statistic-label {
        font-size: 0.8rem;
    }
}

/* Desktop - larger note names */
@media (min-width: 768px) {
    .piano-layout .note-btn {
        font-size: 1rem;
    }
}

@media (min-width: 1024px) {
    .piano-layout .note-btn {
        font-size: 1.25rem;
    }
}

@media (min-width: 1200px) {
    .piano-layout .note-btn {
        font-size: 1.5rem;
    }
}

/* Dark Theme Adaptations */
[data-theme="dark"] .note-natural {
    background: #E0E1DD;
    border-color: #778DA9;
    color: #0D1B2A;
}

[data-theme="dark"] .note-natural:hover {
    background: #C5C6C7;
    color: #0D1B2A;
}

[data-theme="dark"] .note-natural:active,
[data-theme="dark"] .note-natural:focus {
    background: #E0E1DD !important;
    border-color: #778DA9 !important;
    color: #0D1B2A !important;
}

[data-theme="dark"] .note-altered {
    background: #1B263B;
    border-color: #0D1B2A;
    color: #E0E1DD;
}

[data-theme="dark"] .note-altered:hover {
    background: #1F2937;
}

[data-theme="dark"] .note-altered:active,
[data-theme="dark"] .note-altered:focus {
    background: #1B263B !important;
    border-color: #0D1B2A !important;
    color: #E0E1DD !important;
}

[data-theme="dark"] .piano-layout .note-natural {
    border-color: #778DA9;
}

[data-theme="dark"] .piano-layout .note-altered {
    border-color: #0D1B2A;
}

/* Dark theme for cards and text */
[data-theme="dark"] .card {
    background-color: var(--surface-elevated);
    border-color: var(--border);
}

[data-theme="dark"] .card-body h5,
[data-theme="dark"] .card-title {
    color: var(--text-primary);
}

[data-theme="dark"] .text-muted {
    color: var(--text-muted) !important;
}

[data-theme="dark"] .statistic-box {
    background: linear-gradient(135deg, #1B263B 0%, #0D1B2A 100%);
    border-color: #415A77;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .statistic-value {
    color: #5FA8D3;
}

[data-theme="dark"] .statistic-label {
    color: #C5C6C7;
}

[data-theme="dark"] .progress-card {
    border-left-color: var(--accent);
}

[data-theme="dark"] .question-card {
    background: linear-gradient(135deg, #60a5fa 0%, #93c5fd 100%);
    color: #000000;
}

[data-theme="dark"] .question-card h2 {
    color: #000000 !important;
    text-shadow: none;
}

[data-theme="dark"] .bg-light {
    background-color: var(--surface) !important;
}

[data-theme="dark"] .modal-content {
    background-color: var(--surface-elevated);
    color: var(--text-primary);
}

[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
    border-color: var(--border);
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background-color: var(--surface);
    border-color: var(--border);
    color: var(--text-primary);
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background-color: var(--surface);
    border-color: var(--accent);
    color: var(--text-primary);
}

[data-theme="dark"] .form-check-input {
    background-color: var(--surface);
    border-color: var(--border);
}

[data-theme="dark"] .form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}

[data-theme="dark"] .form-label {
    color: var(--text-primary);
}

[data-theme="dark"] .alert-info {
    background-color: rgba(62, 146, 204, 0.2);
    border-color: var(--accent);
    color: var(--text-primary);
}

/* Dark theme for Settings page */
[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4,
[data-theme="dark"] h5 {
    color: var(--text-primary);
}

[data-theme="dark"] .form-check-label {
    color: var(--text-primary);
}

[data-theme="dark"] .card-body {
    color: var(--text-primary);
}

[data-theme="dark"] .form-range {
    background-color: transparent;
}

[data-theme="dark"] .form-range::-webkit-slider-track {
    background-color: var(--border);
}

[data-theme="dark"] .form-range::-moz-range-track {
    background-color: var(--border);
}

[data-theme="dark"] .alert-success {
    background-color: rgba(34, 197, 94, 0.2);
    border-color: #22c55e;
    color: var(--text-primary);
}

[data-theme="dark"] p,
[data-theme="dark"] label {
    color: var(--text-primary);
}
