/* Writing Practice Styles */

/* General Layout */
.screen {
    animation: fadeIn 0.3s ease-in;
}

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

.subtitle {
    color: #7f8c8d;
    font-size: 1.1rem;
    margin-top: -10px;
    margin-bottom: 2rem;
}

.btn-back {
    background: #95a5a6;
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 1.5rem;
}

.btn-back:hover {
    background: #7f8c8d;
    transform: translateX(-5px);
}

/* Mode Selection */
.mode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.mode-card {
    background: #f9f9f9;
    border: 3px solid #ddd;
    border-radius: 15px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-card:hover {
    background: #3498db;
    color: white;
    border-color: #3498db;
    transform: translateY(-8px);
    box-shadow: 0 8px 20px rgba(52, 152, 219, 0.4);
}

.mode-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.mode-card h3 {
    font-size: 1.5rem;
    margin: 1rem 0 0.5rem 0;
}

.mode-card p {
    font-size: 1rem;
    opacity: 0.8;
}

/* Lesson Selection */
.lesson-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.lesson-card {
    background: white;
    border: 2px solid #34495e;
    border-radius: 12px;
    padding: 2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.lesson-card:hover {
    background: #3498db;
    color: white;
    border-color: #3498db;
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.3);
}

.lesson-card h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.3rem;
}

.lesson-card p {
    margin: 0;
    opacity: 0.8;
}

/* Character Selection */
.selection-header {
    margin-bottom: 1.5rem;
}

.search-container {
    margin: 1.5rem 0;
}

#char-search {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    transition: border-color 0.3s ease;
}

#char-search:focus {
    outline: none;
    border-color: #3498db;
}

.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.character-card {
    aspect-ratio: 1;
    background: white;
    border: 2px solid #34495e;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.character-card:hover {
    background: #3498db;
    color: white;
    border-color: #3498db;
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}

.character-card.completed {
    background: #27ae60;
    color: white;
    border-color: #27ae60;
}

/* Writing Practice */
.practice-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.progress-info {
    font-size: 1.1rem;
    font-weight: 600;
    color: #34495e;
}

.character-info-panel {
    background: #f8f9fa;
    border: 2px solid #3498db;
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
}

.vocab-details {
    text-align: center;
}

.indonesian-text {
    font-size: 1.5rem;
    color: #2c3e50;
    margin: 0 0 1rem 0;
}

.pinyin-text {
    font-size: 1.2rem;
    color: #e74c3c;
    margin: 0.5rem 0;
}

.zhuyin-text {
    font-size: 1.2rem;
    color: #3498db;
    margin: 0.5rem 0;
}

.writing-area {
    text-align: center;
    padding: 1rem 0;
}

.stroke-info {
    display: flex;
    justify-content: space-around;
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
    font-weight: 700;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 10px;
}

.stroke-display {
    color: #3498db;
}

.mistake-display {
    color: #e74c3c;
}

.character-canvas {
    min-height: 450px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 2rem auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    padding: 1rem;
}

.practice-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.btn-hint,
.btn-skip,
.btn-reset {
    padding: 1rem 2rem;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.btn-hint {
    background: #f39c12;
    color: white;
}

.btn-hint:hover {
    background: #e67e22;
    transform: translateY(-3px);
    box-shadow: 0 4px 10px rgba(243, 156, 18, 0.4);
}

.btn-skip {
    background: #95a5a6;
    color: white;
}

.btn-skip:hover {
    background: #7f8c8d;
    transform: translateY(-3px);
    box-shadow: 0 4px 10px rgba(149, 165, 166, 0.4);
}

.btn-reset {
    background: #e74c3c;
    color: white;
}

.btn-reset:hover {
    background: #c0392b;
    transform: translateY(-3px);
    box-shadow: 0 4px 10px rgba(231, 76, 60, 0.4);
}

/* Feedback Panel */
.feedback-panel {
    min-height: 70px;
    margin: 2rem 0;
    padding: 1.2rem;
    border-radius: 10px;
    font-size: 1.2rem;
    font-weight: 600;
    text-align: center;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feedback-panel.info {
    background: #e8f4f8;
    color: #2980b9;
    border: 2px solid #3498db;
}

.feedback-panel.correct {
    background: #d4edda;
    color: #155724;
    border: 2px solid #27ae60;
}

.feedback-panel.incorrect {
    background: #f8d7da;
    color: #721c24;
    border: 2px solid #e74c3c;
}

#feedback-message {
    margin: 0;
}

/* Completion Screen */
.completion-content {
    text-align: center;
    padding: 2rem;
    max-width: 600px;
    margin: 0 auto;
}

.completion-title {
    font-size: 2.5rem;
    color: #27ae60;
    margin-bottom: 2rem;
}

.character-summary {
    margin: 2rem 0;
}

.completed-char-display {
    font-size: 8rem;
    color: #2c3e50;
    margin: 1rem 0;
    animation: scaleIn 0.5s ease-out;
}

@keyframes scaleIn {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.completed-vocab-info {
    margin-top: 1.5rem;
}

.completed-indonesian {
    font-size: 1.5rem;
    color: #2c3e50;
    font-weight: 600;
    margin: 0.5rem 0;
}

.completed-pinyin {
    font-size: 1.2rem;
    color: #e74c3c;
    margin: 0.5rem 0;
}

.stats-panel {
    background: #f8f9fa;
    border: 3px solid #3498db;
    border-radius: 15px;
    padding: 2rem;
    margin: 2rem auto;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.3rem;
    margin: 1rem 0;
    padding: 0.5rem 0;
    border-bottom: 1px solid #ddd;
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-label {
    font-weight: 600;
    color: #34495e;
}

.stat-value {
    font-weight: 700;
    color: #3498db;
    font-size: 1.5rem;
}

.completion-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.btn-primary,
.btn-secondary {
    padding: 1rem 2rem;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-3px);
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.4);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
    transform: translateY(-3px);
    box-shadow: 0 4px 10px rgba(149, 165, 166, 0.4);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .mode-grid {
        grid-template-columns: 1fr;
    }

    .mode-card {
        padding: 2rem 1.5rem;
    }

    .lesson-grid {
        grid-template-columns: 1fr;
    }

    .character-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    }

    .character-card {
        font-size: 2rem;
    }

    /* Make info panel compact on mobile */
    .character-info-panel {
        padding: 0.8rem;
        margin-top: 1rem;
        margin-bottom: 1rem;
    }

    .indonesian-text {
        font-size: 1.1rem;
        margin: 0 0 0.3rem 0;
    }

    .pinyin-text {
        font-size: 0.95rem;
        margin: 0.2rem 0;
    }

    .zhuyin-text {
        font-size: 0.9rem;
        margin: 0.2rem 0;
    }

    .stroke-info {
        font-size: 1.1rem;
        padding: 0.6rem;
        margin-bottom: 0.8rem;
    }

    .character-canvas {
        min-height: auto;
        max-width: 100%;
        padding: 0.5rem;
        margin: 0.5rem auto;
        overflow: hidden;
    }

    .character-canvas svg {
        max-width: 100%;
        height: auto;
        display: block;
        margin: 0 auto;
    }

    .practice-controls {
        flex-direction: column;
        margin-top: 1rem;
    }

    .btn-hint,
    .btn-skip,
    .btn-reset {
        width: 100%;
        padding: 0.8rem 1.5rem;
    }

    .feedback-panel {
        min-height: 50px;
        margin: 1rem 0;
        padding: 0.8rem;
        font-size: 1rem;
    }

    .completed-char-display {
        font-size: 5rem;
    }

    .completion-actions {
        flex-direction: column;
    }

    .btn-primary,
    .btn-secondary {
        width: 100%;
    }

    .practice-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
        margin-bottom: 1rem;
    }

    .progress-info {
        font-size: 1rem;
    }
}

/* Tablet adjustments */
@media (max-width: 1024px) and (min-width: 769px) {
    .mode-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .character-grid {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    }
}

/* Stroke Order Lookup Styles */
.lookup-header {
    text-align: center;
    margin-bottom: 2rem;
}

.lookup-input-container {
    display: flex;
    gap: 1rem;
    max-width: 600px;
    margin: 0 auto 3rem;
    align-items: center;
}

#hanzi-input {
    flex: 1;
    padding: 1rem;
    font-size: 1.5rem;
    border: 2px solid #3498db;
    border-radius: 8px;
    text-align: center;
    font-family: "Microsoft YaHei", "微軟正黑體", sans-serif;
    transition: all 0.3s ease;
}

#hanzi-input:focus {
    outline: none;
    border-color: #2980b9;
    box-shadow: 0 0 10px rgba(52, 152, 219, 0.3);
}

#hanzi-input::placeholder {
    color: #bdc3c7;
    font-size: 1.2rem;
}

#show-strokes-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

#show-strokes-btn:hover {
    background: #2980b9;
    transform: scale(1.05);
}

.stroke-display-area {
    min-height: 300px;
    padding: 2rem;
    background: #f8f9fa;
    border-radius: 12px;
}

.stroke-order-section {
    margin: 2rem 0;
}

.stroke-order-section h3 {
    color: #2c3e50;
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.stroke-order-container {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    justify-content: center;
    align-items: center;
}

.hanzi-writer-container {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.hanzi-writer-container:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.empty-message {
    text-align: center;
    color: #7f8c8d;
    font-size: 1.2rem;
    padding: 3rem;
}

.error-message {
    color: #e74c3c;
    text-align: center;
    padding: 1rem;
    font-size: 0.9rem;
}

/* Responsive adjustments for lookup */
@media (max-width: 768px) {
    .lookup-input-container {
        flex-direction: column;
        padding: 0 1rem;
    }

    #hanzi-input {
        width: 100%;
        font-size: 1.3rem;
    }

    #show-strokes-btn {
        width: 100%;
        padding: 1rem;
    }

    .stroke-order-container {
        gap: 1rem;
    }

    .hanzi-writer-container {
        transform: scale(0.9);
    }
}

/* Animation Toggle Styles */
.animation-toggle-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin: 0 auto 2rem;
    max-width: 600px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.4s;
    border-radius: 34px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #3498db;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(26px);
}

.toggle-label {
    font-size: 1.1rem;
    font-weight: 500;
    color: #2c3e50;
}

/* Character Lookup Card with Pinyin */
.character-lookup-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.pinyin-label {
    font-size: 1rem;
    font-weight: 600;
    color: #3498db;
    text-align: center;
    font-family: Arial, sans-serif;
    margin-top: 0.5rem;
}

/* Responsive adjustments for toggle and pinyin */
@media (max-width: 768px) {
    .animation-toggle-container {
        margin: 0 1rem 1.5rem;
    }

    .toggle-label {
        font-size: 1rem;
    }

    .pinyin-label {
        font-size: 0.9rem;
    }
}
