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

:root {
    --primary-color: #4f46e5;
    --primary-dark: #4338ca;
    --secondary-color: #10b981;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.15;
    z-index: -1;
    transition: opacity 0.5s ease;
}

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

header {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem;
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

header h1 {
    font-size: 2.5rem;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

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

.language-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.language-selector label {
    font-weight: 600;
    color: var(--text-primary);
}

.language-selector select {
    padding: 0.75rem 1.5rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 200px;
}

.language-selector select:hover {
    border-color: var(--primary-color);
}

.language-selector select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.language-selector-footer {
    margin-top: 3rem;
    padding: 2rem;
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow);
    text-align: center;
}

.main-content {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
    align-items: start;
}

.topics-sidebar {
    background: var(--surface);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    position: sticky;
    top: 2rem;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
}

.topics-sidebar h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border);
    padding-bottom: 0.75rem;
}

.topics-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.topic-item {
    padding: 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    background: var(--background);
}

.topic-item:hover {
    background: var(--primary-color);
    color: white;
    transform: translateX(4px);
}

.topic-item.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-dark);
    box-shadow: var(--shadow);
}

.topic-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.topic-item h3 {
    font-size: 1rem;
    font-weight: 600;
    flex: 1;
    margin: 0;
}

.topic-play-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

.topic-item:not(.active) .topic-play-button {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.topic-item:not(.active) .topic-play-button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.3);
}

.topic-item.active .topic-play-button {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    color: white;
}

.topic-item.active .topic-play-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(255, 255, 255, 0.2);
}

.topic-play-button.playing {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
    animation: pulse 1.5s ease-in-out infinite;
}

.topic-play-button .play-icon {
    font-size: 0.9rem;
    line-height: 1;
}

.topic-play-button .play-text {
    font-size: 0.85rem;
    font-weight: 600;
}

.phrases-content {
    background: var(--surface);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--shadow);
    min-height: 500px;
}

.welcome-message {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.welcome-message h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.topic-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 3px solid var(--primary-color);
    flex-wrap: wrap;
    gap: 1rem;
}

#topicTitle {
    font-size: 2rem;
    color: var(--text-primary);
    margin: 0;
    flex: 1;
}

.topic-navigation {
    display: flex;
    gap: 0.75rem;
}

.nav-button {
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}

.nav-button:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.3);
}

.nav-button:active:not(:disabled) {
    transform: translateY(0);
}

.nav-button:disabled,
.nav-button.disabled {
    background: var(--border);
    color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.5;
}

.phrases-list {
    display: grid;
    gap: 1.5rem;
}

.phrase-card {
    background: var(--background);
    border-radius: 12px;
    padding: 1.5rem;
    border: 2px solid var(--border);
    transition: all 0.3s ease;
    cursor: pointer;
}

.phrase-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.phrase-header {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border);
}

.phrase-english {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.phrase-english .play-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
    vertical-align: middle;
    margin-left: 0.5rem;
}

.phrase-english .play-button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.3);
}

.phrase-english .play-button:active {
    transform: translateY(0);
}

.phrase-english .play-button.playing {
    background: var(--secondary-color);
    animation: pulse 1.5s ease-in-out infinite;
}

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

.play-text {
    font-size: 0.85rem;
}

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

.phrase-ipa {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 8px;
    border-left: 3px solid var(--primary-color);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ipa-item {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    font-size: 0.95rem;
}

.ipa-item strong {
    color: var(--text-secondary);
    font-weight: 600;
    min-width: 35px;
    font-size: 0.9rem;
}

.ipa-text {
    font-family: 'Charis SIL', 'Doulos SIL', 'Times New Roman', serif;
    font-size: 1.15rem;
    color: var(--primary-dark);
    font-style: normal;
    letter-spacing: 0.5px;
    line-height: 1.6;
}

.phrase-translation {
    font-size: 1.2rem;
    color: var(--text-primary);
    line-height: 1.8;
}

.phrase-translation strong {
    color: var(--secondary-color);
    font-weight: 600;
}

/* Scrollbar styling */
.topics-sidebar::-webkit-scrollbar {
    width: 8px;
}

.topics-sidebar::-webkit-scrollbar-track {
    background: var(--background);
    border-radius: 4px;
}

.topics-sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.topics-sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Responsive design */
@media (max-width: 968px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .topics-sidebar {
        position: relative;
        top: 0;
        max-height: none;
    }

    .topics-list {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 0.75rem;
    }

    header h1 {
        font-size: 2rem;
    }

    .container {
        padding: 1rem;
    }
}

@media (max-width: 640px) {
    header h1 {
        font-size: 1.75rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .language-selector {
        flex-direction: column;
        align-items: stretch;
    }

    .language-selector select {
        width: 100%;
    }

    .phrases-content {
        padding: 1.5rem;
    }

    .topic-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .topic-navigation {
        width: 100%;
        justify-content: space-between;
    }
    
    .nav-button {
        flex: 1;
    }
    
    .phrase-header {
        flex-direction: column;
        align-items: stretch;
    }

    .phrase-english {
        font-size: 1.25rem;
        flex-direction: column;
        align-items: flex-start;
    }

    .phrase-english .play-button {
        width: auto;
        margin-left: 0;
        margin-top: 0.5rem;
    }

    .phrase-translation {
        font-size: 1.1rem;
    }
}

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

.phrase-card {
    animation: fadeIn 0.3s ease;
}

.topic-item {
    animation: fadeIn 0.3s ease;
}

/* Image Gallery Section */
.image-gallery-section {
    margin-top: 4rem;
    padding: 2rem;
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.gallery-title {
    font-size: 2rem;
    color: var(--text-primary);
    margin-bottom: 2rem;
    text-align: center;
    border-bottom: 3px solid var(--primary-color);
    padding-bottom: 1rem;
}

.thumbnail-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.thumbnail-item {
    position: relative;
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--border);
    transition: all 0.3s ease;
    aspect-ratio: 1;
}

.thumbnail-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.thumbnail-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Image Viewer Modal */
.image-viewer-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    animation: fadeIn 0.3s ease;
}

.image-viewer-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.close-modal {
    position: absolute;
    top: -40px;
    right: 0;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10001;
    line-height: 1;
    transition: all 0.3s ease;
}

.close-modal:hover {
    color: var(--secondary-color);
    transform: scale(1.2);
}

.modal-image-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    width: 100%;
    position: relative;
}

.modal-image-container {
    max-width: calc(100% - 200px);
    max-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 2rem 0;
    flex: 1;
}

.modal-image-container img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal-top-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1rem;
    width: 100%;
}

.modal-nav-btn {
    background: rgba(79, 70, 229, 0.9);
    color: white;
    border: none;
    padding: 1rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
    z-index: 10001;
    flex-shrink: 0;
    align-self: center;
}

.modal-nav-btn:hover {
    background: var(--primary-color);
    transform: scale(1.05);
}

.download-btn {
    padding: 0.75rem 1.5rem;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.download-btn:hover {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
}

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

/* Learning Result Modal */
.learning-result-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.3s ease;
    overflow-y: auto;
}

.learning-result-modal.active {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem;
}

.modal-content-report {
    position: relative;
    background: var(--surface);
    border-radius: 16px;
    padding: 2rem;
    max-width: 900px;
    width: 100%;
    margin: 2rem auto;
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    overflow-y: auto;
}

.close-modal-report {
    position: absolute;
    top: 20px;
    right: 20px;
    color: var(--text-primary);
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10001;
    line-height: 1;
    transition: all 0.3s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--background);
}

.close-modal-report:hover {
    color: var(--primary-color);
    background: var(--border);
    transform: scale(1.1);
}

.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 3px solid var(--primary-color);
    flex-wrap: wrap;
    gap: 1rem;
}

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

.report-actions {
    display: flex;
    gap: 1rem;
}

.action-btn {
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.action-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(79, 70, 229, 0.3);
}

.report-content {
    color: var(--text-primary);
}

.report-summary {
    margin-bottom: 2rem;
}

.report-summary h3 {
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 1rem;
}

.chart-wrapper {
    background: var(--background);
    padding: 1.5rem;
    border-radius: 12px;
    border: 2px solid var(--border);
    text-align: center;
}

.chart-wrapper h4 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.chart-wrapper canvas {
    max-height: 300px;
    margin: 0 auto;
}

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

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    display: inline-block;
}

.report-topics {
    margin-top: 2rem;
}

.report-topics h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.topics-list-report {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.topic-report-item {
    padding: 1.5rem;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--background);
    transition: all 0.3s ease;
}

.topic-report-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
}

.topic-report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.topic-report-header h4 {
    color: var(--primary-color);
    margin: 0;
    font-size: 1.2rem;
}

.topic-completion {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--secondary-color);
    padding: 0.25rem 0.75rem;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 6px;
}

.topic-report-details {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.report-footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border);
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.no-data {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-style: italic;
}

@media (max-width: 768px) {
    .thumbnail-gallery {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.75rem;
    }
    
    .modal-image-wrapper {
        flex-direction: column;
        gap: 1rem;
    }
    
    .modal-image-container {
        max-width: 100%;
    }
    
    .modal-nav-btn {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
        width: auto;
    }
    
    .modal-top-controls {
        flex-direction: column;
        gap: 1rem;
    }
    
    .close-modal {
        top: 10px;
        right: 10px;
        font-size: 30px;
    }
    
    .learning-result-modal.active {
        padding: 1rem;
    }
    
    .modal-content-report {
        padding: 1.5rem;
        margin: 1rem auto;
    }
    
    .report-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}


