:root {
    --primary-color: #FF6B6B;
    --secondary-color: #4ECDC4;
    --dark-bg: #1A1A2E;
    --card-bg: #16213E;
    --text-color: #E94560;
    --text-light: #F7F7F7;
    --text-muted: #A0A0A0;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --font-main: 'Outfit', sans-serif;
    --font-thai: 'Sarabun', sans-serif;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--dark-bg);
    color: var(--text-light);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 20px;
}

.app-container {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

header {
    text-align: center;
    margin-bottom: 1rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 600;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-muted);
    font-weight: 300;
    font-weight: 300;
}

/* Search Bar */
.search-container {
    position: relative;
    width: 100%;
    margin-bottom: 1rem;
}

.search-container input {
    width: 100%;
    padding: 15px 20px 15px 50px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-light);
    font-family: var(--font-main);
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
}

.search-container input:focus {
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 15px rgba(255, 107, 107, 0.2);
}

.search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    fill: var(--text-muted);
    transition: fill 0.3s ease;
}

.search-container input:focus+.search-icon {
    fill: var(--primary-color);
}

/* Category Navigation */
.category-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    padding-bottom: 10px;
}

.category-nav::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari */
}

.category-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-light);
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s ease;
    font-family: var(--font-main);
    font-size: 0.9rem;
}

.category-btn:hover,
.category-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

/* Category Image */
.category-image-container {
    width: 100%;
    height: 200px;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 20px;
    border: 1px solid var(--glass-border);
}

.category-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.category-image-container img.contain-image {
    object-fit: contain;
    background-color: var(--card-bg);
    /* Optional: fills empty space if aspect ratio differs */
}

.category-image-container:hover img {
    transform: scale(1.05);
}

/* Phrase List */
.phrase-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.phrase-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--glass-border);
    transition: transform 0.2s ease;
}

.phrase-card:hover {
    transform: scale(1.02);
    border-color: var(--secondary-color);
}

.phrase-content {
    flex: 1;
}

.phrase-thai {
    font-family: var(--font-thai);
    font-size: 1.5rem;
    color: var(--secondary-color);
    margin-bottom: 4px;
}

.phrase-transliteration {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-style: italic;
}

.phrase-english {
    font-size: 1rem;
    color: var(--text-light);
}

.audio-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.audio-btn:hover {
    color: var(--primary-color);
    background: rgba(255, 255, 255, 0.05);
}

.audio-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 40px;
    font-style: italic;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .app-container {
        padding: 0 10px;
    }

    header h1 {
        font-size: 2rem;
    }

    .phrase-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .audio-btn {
        align-self: flex-end;
        margin-top: -3rem;
        /* Pull up to align with text if needed, or just let it flow */
        margin-top: 0;
        background: var(--glass-bg);
        /* Make it more visible on mobile */
    }

    .phrase-thai {
        font-size: 1.3rem;
    }
}

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

.audio-btn.playing {
    color: var(--secondary-color);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

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

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 90%;
    max-width: 600px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    position: relative;
    animation: slideIn 0.3s ease-out;
}

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

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close-modal {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close-modal:hover,
.close-modal:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

#lessonTitle {
    margin-top: 0;
    color: #2563eb;
    font-family: 'Outfit', sans-serif;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.lesson-content {
    font-family: 'Sarabun', sans-serif;
    line-height: 1.6;
    color: #374151;
}

.tone-item {
    background: #f9fafb;
    border-left: 4px solid #2563eb;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 0 8px 8px 0;
}

.tone-item h3 {
    margin-top: 0;
    color: #1f2937;
    font-size: 1.1em;
}

.tone-item .example {
    font-style: italic;
    color: #4b5563;
    margin-bottom: 0;
}

.lesson-note {
    background-color: #fffbeb;
    border: 1px solid #fcd34d;
    color: #92400e;
    padding: 15px;
    border-radius: 8px;
    margin-top: 20px;
}

/* View Lesson Button */
.view-lesson-btn {
    display: block;
    width: 100%;
    max-width: 300px;
    margin: 0 auto 20px auto;
    padding: 12px 20px;
    background-color: #2563eb;
    color: white;
    border: none;
    border-radius: 8px;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.view-lesson-btn:hover {
    background-color: #1d4ed8;
}

.view-lesson-btn svg {
    width: 20px;
    height: 20px;
    vertical-align: text-bottom;
    margin-right: 8px;
    fill: currentColor;
}