/* css/style.css */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --text-color: #333;
    --bg-color: #f8f9fa;
    --border-radius: 8px;
}

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

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

.app-header {
    background: var(--primary-color);
    color: white;
    padding: 2rem 1rem;
    text-align: center;
}

.app-header h1 {
    margin-bottom: 0.5rem;
    font-size: 2.5em;
}

.app-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.app-footer {
    text-align: center;
    padding: 1rem;
    color: #7f8c8d;
    font-size: 0.9em;
}




/* เพิ่มใน css/style.css */

/* Hanzi Animation Styles */
.hanzi-animation-container {
    text-align: center;
    margin: 20px 0;
    padding: 20px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.hanzi-canvas {
    margin: 0 auto;
    border: 3px solid #1a73e8;
    border-radius: 10px;
    background: white;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
}

.hanzi-controls {
    margin-top: 15px;
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.hanzi-controls button {
    padding: 10px 15px;
    border: none;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.btn-animate {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-quiz {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn-reset {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.hanzi-controls button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.hanzi-controls button:active {
    transform: translateY(0);
}

/* Audio Button Styles */
.audio-button {
    padding: 8px 16px;
    border: 2px solid #4CAF50;
    border-radius: 20px;
    background: white;
    color: #4CAF50;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 5px;
}

.audio-button:hover {
    background: #4CAF50;
    color: white;
    transform: scale(1.05);
}

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

/* Combined Character-Audio Player */
.character-audio-player {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin: 15px 0;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    border: 1px solid #e0e0e0;
}

.player-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

.character-large {
    font-size: 3em;
    font-weight: bold;
    color: #1a73e8;
}

.pinyin-display {
    font-size: 1.2em;
    color: #666;
    font-style: italic;
}

.player-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.combined-button {
    padding: 12px 20px;
    border: none;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-play-all {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-animate-only {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.btn-audio-only {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    color: white;
}

.combined-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.tone-search-buttons {
    display: flex;
    gap: 10px;
    margin: 15px 0;
    flex-wrap: wrap;
    justify-content: center;
}

.tone-btn {
    padding: 10px 15px;
    border: 2px solid #3498db;
    border-radius: 10px;
    background: white;
    cursor: pointer;
    text-align: center;
    min-width: 90px;
    transition: all 0.3s ease;
    font-family: inherit;
}

.tone-btn:hover {
    background: #ecf0f1;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.tone-btn.active {
    background: #3498db;
    color: white;
    border-color: #2980b9;
}

.tone-1 { border-color: #e74c3c; }
.tone-2 { border-color: #f39c12; }
.tone-3 { border-color: #27ae60; }
.tone-4 { border-color: #9b59b6; }
.tone-0 { border-color: #95a5a6; }

.tone-1.active { background: #e74c3c; }
.tone-2.active { background: #f39c12; }
.tone-3.active { background: #27ae60; }
.tone-4.active { background: #9b59b6; }
.tone-0.active { background: #95a5a6; }


/* Responsive design */
@media (max-width: 768px) {
    .hanzi-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .hanzi-controls button {
        width: 200px;
    }
    
    .hanzi-canvas {
        width: 120px !important;
        height: 120px !important;
    }
    
    .player-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .character-large {
        font-size: 2.5em;
    }
    
    .player-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .combined-button {
        width: 200px;
        justify-content: center;
    }
}

/* */

    /* Reset และ Base Styles */
    * {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
    }
    
    body {
        font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        margin: 0;
        padding: 20px;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        min-height: 100vh;
    }
    
    /* Container */
    #app {
        max-width: 800px;
        margin: 0 auto;
        background: white;
        border-radius: 20px;
        box-shadow: 0 20px 40px rgba(0,0,0,0.1);
        overflow: hidden;
    }
    
    /* Header */
    h1 {
        background: linear-gradient(135deg, #2c3e50, #3498db);
        color: white;
        padding: 25px 30px;
        margin: 0;
        font-size: 28px;
        font-weight: 600;
        display: flex;
        align-items: center;
        gap: 15px;
    }
    
    h1:before {
        content: "📚";
        font-size: 32px;
    }
    
    /* Search Container */
    .search-container {
        padding: 30px;
        background: white;
        border-bottom: 1px solid #f0f0f0;
    }
    
    #searchInput {
        width: 100%;
        padding: 18px 20px;
        font-size: 18px;
        border: 2px solid #e0e0e0;
        border-radius: 15px;
        margin-bottom: 15px;
        transition: all 0.3s ease;
        background: #f8f9fa;
    }
    
    #searchInput:focus {
        outline: none;
        border-color: #3498db;
        background: white;
        box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
        transform: translateY(-2px);
    }
    
    /* Utility Buttons */
    .utility-buttons {
        display: flex;
        gap: 12px;
        margin-top: 15px;
        flex-wrap: wrap;
    }
    
    .utility-btn {
        background: linear-gradient(135deg, #3498db, #2980b9);
        color: white;
        border: none;
        padding: 12px 20px;
        border-radius: 10px;
        cursor: pointer;
        font-size: 14px;
        font-weight: 500;
        transition: all 0.3s ease;
        display: flex;
        align-items: center;
        gap: 8px;
        box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
    }
    
    .utility-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
    }
    
    .utility-btn.favorites {
        background: linear-gradient(135deg, #f39c12, #e67e22);
        box-shadow: 0 4px 15px rgba(243, 156, 18, 0.3);
    }
    
    .utility-btn.history {
        background: linear-gradient(135deg, #9b59b6, #8e44ad);
        box-shadow: 0 4px 15px rgba(155, 89, 182, 0.3);
    }
    
    /* Results Container */
    .results-container {
        padding: 0 30px 30px;
    }
    
    /* Search Info */
    .search-info {
        background: linear-gradient(135deg, #ecf0f1, #bdc3c7);
        padding: 20px;
        border-radius: 15px;
        margin-bottom: 20px;
        border-left: 5px solid #3498db;
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .search-info strong {
        color: #2c3e50;
        font-size: 16px;
    }
    
    .clear-history-btn {
        background: #e74c3c;
        color: white;
        border: none;
        padding: 8px 16px;
        border-radius: 8px;
        cursor: pointer;
        font-size: 12px;
        transition: all 0.3s ease;
    }
    
    .clear-history-btn:hover {
        background: #c0392b;
        transform: translateY(-1px);
    }
    
    /* Result Items */
    .result-item {
        background: white;
        border: 1px solid #e0e0e0;
        border-radius: 15px;
        padding: 25px;
        margin-bottom: 20px;
        transition: all 0.3s ease;
        position: relative;
        overflow: hidden;
    }
    
    .result-item:hover {
        transform: translateY(-3px);
        box-shadow: 0 10px 30px rgba(0,0,0,0.1);
        border-color: #3498db;
    }
    
    .result-item:before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 5px;
        height: 100%;
        background: linear-gradient(135deg, #3498db, #2980b9);
    }
    
    .result-item.compound:before {
        background: linear-gradient(135deg, #27ae60, #2ecc71);
    }
    
    /* Character Display */
    .character-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 15px;
    }
    
    .character-main {
        display: flex;
        align-items: center;
        gap: 15px;
    }
    
    .chinese-char {
        font-size: 42px;
        font-weight: bold;
        color: #2c3e50;
        text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    }
    
    /* ซ้ำ
    .type-badge {
        background: #3498db;
        color: white;
        padding: 6px 12px;
        border-radius: 20px;
        font-size: 12px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    
    .type-badge.compound {
        background: linear-gradient(135deg, #27ae60, #2ecc71);
    }
    
    .type-badge.character {
        background: linear-gradient(135deg, #3498db, #2980b9);
    }
    */
    
    /* Favorite Button */
    .favorite-btn {
        background: none;
        border: 2px solid #bdc3c7;
        padding: 10px;
        border-radius: 50%;
        cursor: pointer;
        font-size: 20px;
        transition: all 0.3s ease;
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .favorite-btn:hover {
        border-color: #e74c3c;
        transform: scale(1.1);
    }
    
    .favorite-btn.active {
        background: #e74c3c;
        border-color: #e74c3c;
        color: white;
    }
    
    /* Pinyin and Meanings */
    .pinyin {
        color: #e74c3c;
        font-size: 20px;
        font-weight: 500;
        margin-bottom: 10px;
    }
    
    /* ซ้ำ
    .tone-indicator {
        color: #7f8c8d;
        font-size: 14px;
        margin-left: 8px;
    }
    */
    
    .meaning-section {
        margin-bottom: 12px;
    }
    
    .meaning-section strong {
        color: #2c3e50;
        display: inline-block;
        min-width: 120px;
    }
    
    .example-sentence {
        font-style: italic;
        color: #7f8c8d;
        border-left: 3px solid #3498db;
        padding-left: 15px;
        margin: 15px 0;
    }
    


    /* Meta Info */
    /* ซ้ำ
    .meta-info {
        font-size: 12px;
        color: #7f8c8d;
        margin-top: 15px;
        padding-top: 15px;
        border-top: 1px solid #ecf0f1;
        display: flex;
        flex-wrap: wrap;
        gap: 15px;
    }
    
    .meta-tags {
        font-size: 11px;
        color: #95a5a6;
        margin-top: 8px;
    }
    */
    
    /* Welcome Message */
    .welcome-message {
        text-align: center;
        padding: 40px 20px;
        color: #7f8c8d;
    }
    
    .welcome-message p {
        font-size: 18px;
        margin-bottom: 20px;
    }
    
    /* Loading Animation */
    .loading-spinner {
        display: inline-block;
        width: 20px;
        height: 20px;
        border: 3px solid #f3f3f3;
        border-top: 3px solid #3498db;
        border-radius: 50%;
        animation: spin 1s linear infinite;
        margin-right: 10px;
    }
    
    @keyframes spin {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(360deg); }
    }
    
    /* Recent Searches */
    .recent-searches {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 10px;
    }
    
    .recent-search-tag {
        background: #ecf0f1;
        color: #2c3e50;
        padding: 6px 12px;
        border-radius: 20px;
        cursor: pointer;
        transition: all 0.3s ease;
        font-size: 12px;
    }
    
    .recent-search-tag:hover {
        background: #3498db;
        color: white;
        transform: translateY(-1px);
    }
    
    /* Responsive Design */
    @media (max-width: 768px) {
        body {
            padding: 10px;
            background: #667eea;
        }
        
        #app {
            border-radius: 15px;
        }
        
        h1 {
            padding: 20px;
            font-size: 24px;
            flex-direction: column;
            text-align: center;
            gap: 10px;
        }
        
        .search-container {
            padding: 20px;
        }
        
        #searchInput {
            padding: 15px;
            font-size: 16px;
        }
        
        .results-container {
            padding: 0 20px 20px;
        }
        
        .result-item {
            padding: 20px;
        }
        
        .chinese-char {
            font-size: 36px;
        }
        
        .character-header {
            flex-direction: column;
            gap: 15px;
        }
        
        .utility-buttons {
            justify-content: center;
        }
        
        .utility-btn {
            flex: 1;
            min-width: 140px;
            justify-content: center;
        }
    }
    
    @media (max-width: 480px) {
        h1 {
            font-size: 20px;
            padding: 15px;
        }
        
        .search-container {
            padding: 15px;
        }
        
        .result-item {
            padding: 15px;
        }
        
        .chinese-char {
            font-size: 32px;
        }
        
        .pinyin {
            font-size: 18px;
        }
    }
    
    /* Debug Info */
    .debug-info {
        font-size: 11px;
        color: #95a5a6;
        background: #f8f9fa;
        padding: 10px;
        border-radius: 8px;
        margin-top: 10px;
        border-left: 3px solid #95a5a6;
    }


/* ========================================= */
/* HANZI ANIMATOR STYLES */
/* ========================================= */

/* Modal Background */
#hanziAnimatorModal.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    overflow: auto;
}

/* Modal Content */
#hanziAnimatorModal .modal-content {
    background: white;
    padding: 25px;
    border-radius: 12px;
    max-width: 520px;
    margin: 40px auto;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    border: 2px solid #e0e0e0;
}

/* Close Button */
#hanziAnimatorModal .close {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    font-weight: bold;
    transition: color 0.3s;
}

#hanziAnimatorModal .close:hover {
    color: #333;
}

/* Title */
#hanziAnimatorModal h3 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 25px;
    font-size: 24px;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

/* Character Display */
#hanziAnimatorModal .character-display {
    text-align: center;
    margin: 25px 0;
    padding: 25px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 10px;
    border: 1px solid #dee2e6;
}

#hanziAnimatorModal #targetCharacter {
    font-size: 120px;
    line-height: 1.2;
    color: #2c3e50;
    margin-bottom: 10px;
    font-family: "SimSun", "STKaiti", "Microsoft YaHei", serif;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

#hanziAnimatorModal #pinyinDisplay {
    font-size: 26px;
    color: #e74c3c;
    font-weight: bold;
    margin-bottom: 5px;
}

#hanziAnimatorModal #meaningDisplay {
    font-size: 16px;
    color: #7f8c8d;
    font-style: italic;
}

/* Drawing Canvas */
#hanziAnimatorModal .drawing-area {
    text-align: center;
    margin: 25px 0;
}

#hanziAnimatorModal #hanziCanvas {
    border: 3px solid #bdc3c7;
    background: #ffffff;
    cursor: crosshair;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transition: border-color 0.3s;
}

#hanziAnimatorModal #hanziCanvas:hover {
    border-color: #3498db;
}

/* Controls */
#hanziAnimatorModal .animator-controls {
    margin: 25px 0;
    text-align: center;
}

#hanziAnimatorModal .animator-btn {
    color: white;
    border: none;
    padding: 12px 20px;
    margin: 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: bold;
    transition: all 0.3s ease;
    min-width: 120px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

#hanziAnimatorModal .animator-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
    opacity: 0.95;
}

#hanziAnimatorModal .animator-btn:active {
    transform: translateY(-1px);
}

/* Specific button colors */
#hanziAnimatorModal #btnStartAnimation {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
}

#hanziAnimatorModal #btnClearCanvas {
    background: linear-gradient(135deg, #e67e22, #f39c12);
}

#hanziAnimatorModal #btnPlayAudio {
    background: linear-gradient(135deg, #2980b9, #3498db);
}

#hanziAnimatorModal #btnPracticeMode {
    background: linear-gradient(135deg, #8e44ad, #9b59b6);
}

/* Stroke Info */
#hanziAnimatorModal .stroke-info {
    margin-top: 25px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #3498db;
}

#hanziAnimatorModal .stroke-info h4 {
    margin: 0 0 12px 0;
    color: #2c3e50;
    font-size: 18px;
}

#hanziAnimatorModal #strokeOrderDisplay {
    font-size: 18px;
    color: #2c3e50;
    font-weight: bold;
    line-height: 1.6;
    font-family: "SimSun", "STKaiti", monospace;
}

#hanziAnimatorModal #strokeCount {
    font-size: 15px;
    color: #7f8c8d;
    margin-top: 10px;
    font-style: italic;
}

/* Practice Stats */
#hanziAnimatorModal .practice-stats {
    margin-top: 20px;
    text-align: center;
    font-size: 15px;
    color: #7f8c8d;
    padding: 12px;
    background: #ecf0f1;
    border-radius: 6px;
    font-weight: bold;
}

#hanziContainer {
    width: 400px;
    height: 400px;
    border: 2px solid #3498db;
    background: white;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
}

/* Responsive Design */
@media (max-width: 600px) {
    #hanziAnimatorModal .modal-content {
        margin: 20px auto;
        padding: 20px;
        max-width: 90%;
    }
    
    #hanziAnimatorModal #targetCharacter {
        font-size: 80px;
    }
    
    #hanziAnimatorModal #hanziCanvas {
        width: 300px;
        height: 300px;
    }
    
    #hanziAnimatorModal .animator-btn {
        padding: 10px 15px;
        min-width: 100px;
        font-size: 14px;
        margin: 5px;
    }
}

/*  */

/* สไตล์สำหรับประเภทคำต่างๆ */
.word-class-noun { color: #2196f3; }
.word-class-verb { color: #4caf50; }
.word-class-adjective { color: #ff9800; }
.word-class-adverb { color: #9c27b0; }
.word-class-pronoun { color: #e91e63; }
.word-class-numeral { color: #795548; }
.word-class-preposition { color: #607d8b; }
.word-class-conjunction { color: #009688; }
.word-class-measure { color: #ff5722; }
.word-class-interjection { color: #f44336; }

/* Badge สำหรับประเภทคำ */
.type-badge {
    background: #ff9800;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    margin-left: 8px;
}

.type-badge.compound {
        background: linear-gradient(135deg, #27ae60, #2ecc71);
}
    
.type-badge.character {
        background: linear-gradient(135deg, #3498db, #2980b9);
}

.type-badge.noun { background: #2196f3; }
.type-badge.verb { background: #4caf50; }
.type-badge.adjective { background: #ff9800; }
.type-badge.adverb { background: #9c27b0; }
.type-badge.pronoun { background: #e91e63; }
.type-badge.numeral { background: #795548; }
.type-badge.preposition { background: #607d8b; }
.type-badge.conjunction { background: #009688; }
.type-badge.measure { background: #ff5722; }
.type-badge.interjection { background: #f44336; }

/*  */

/* สำหรับแสดงผล meta info */
.meta-info {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
    font-size: 12px;
    color: #666;
}

.meta-info span {
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid #e9ecef;
}

.meta-tags {
        font-size: 11px;
        color: #95a5a6;
        margin-top: 8px;
}

.tone-indicator {
    background: #e3f2fd;
    color: #1976d2;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 11px;
    margin-left: 5px;
}



/*.  */

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.favorite-btn {
    transition: all 0.3s ease;
}

.favorite-btn.active {
    color: #e74c3c;
}

.favorite-btn:hover {
    transform: scale(1.1);
}

