/* Import font Nunito bo tròn, đẹp */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap');

/* --- Collection Styles --- */
.fc-collection-wrap { max-width: 800px; margin: 20px auto; padding: 20px; font-family: 'Nunito', sans-serif; }
.fc-collection-header { display: flex; align-items: center; justify-content: center; position: relative; margin-bottom: 20px; min-height: 40px; }
.fc-collection-main-title { font-size: 28px; margin: 0; text-align: center; padding: 0 40px; font-weight: 700; color: #2c3e50; }
.fc-back-to-parent {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #555;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
}
.fc-collection-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 30px; justify-items: center; }
.fc-collection-item { cursor: pointer; text-align: center; transition: transform 0.2s; }
.fc-collection-item:hover { transform: scale(1.05); }
.fc-collection-icon { width: 80px; height: 80px; color: white; display: flex; justify-content: center; align-items: center; font-size: 32px; font-weight: bold; margin: 0 auto 10px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); border: 3px solid white; transition: background .3s, opacity .3s; }
.fc-collection-title { font-size: 15px; color: #333; font-weight: 600; }

.fc-collection-grid[data-item-type="set"] .fc-collection-icon {
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.fc-collection-grid[data-item-type="collection"] .fc-collection-icon {
    border-radius: 20px;
    background: linear-gradient(135deg, #0ba360, #3cba92);
}
.fc-collection-grid[data-item-type="collection"] .fc-item-number {
    font-family: serif;
    font-style: italic;
}

.fc-collection-item.completed .fc-collection-icon { background: #bdc3c7 !important; opacity: 0.7; }
.fc-collection-item.completed .fc-collection-icon span { text-decoration: line-through; }

.fc-complete-button-wrapper { text-align: center; margin-top: 30px; }
.fc-complete-set { background: #27ae60; color: #fff; }
.fc-complete-next { background: #3498db; color: #fff; } 
.fc-collection-footer { text-align: center; margin-top: 30px; }
.fc-complete-collection { background: #e67e22; color: #fff; }

.fc-login-prompt { text-align: center; margin-bottom: 20px; background: #fffbe5; padding: 10px; border-radius: 5px; border: 1px solid #ffe8a0; }
.fc-continue-prompt { background-color: #eaf5ff; border: 1px solid #b8d9f3; border-radius: 8px; padding: 15px; margin-bottom: 25px; text-align: center; }
.fc-continue-prompt p { margin: 0 0 10px; font-size: 16px; }
.fc-continue-prompt .fc-btn { margin: 0 5px; }
#fc-continue-yes { background-color: #27ae60; }
#fc-continue-no { background-color: #7f8c8d; }

/* --- Flashcard Styles --- */
.fc-wrap {
    max-width: 600px;
    margin: 20px auto;
    padding: 0;
    font-family: 'Nunito', sans-serif; 
}

.fc-header{
    display:grid;
    grid-template-areas:"title actions" "progress progress";
    grid-template-columns:1fr auto;
    align-items:center;
    text-align:center;
    margin-bottom:15px;
}
.fc-header h3{
    grid-area:title;
    margin:0;
    justify-self:center;
    padding-left:80px;
    font-size:24px;
    font-weight:700;
}
.fc-progress{
    grid-area:progress;
    display:flex;
    justify-content:center;
    gap:20px;
    margin-top:10px;
    font-size:14px;
    font-weight:600;
}
.fc-header-actions{
    grid-area:actions;
    justify-self:end;
    display:flex;
    align-items:center;
    gap:8px;
}
.fc-swap-sides{
    background:#8e44ad;
    color:#fff;
    border:none;
    padding:8px 12px;
    border-radius:20px;
    cursor:pointer;
    font-size:12px;
}
.fc-swap-sides.active{background:#27ae60}

.fc-audio-open{
    background:linear-gradient(135deg,#ff9f43,#ff6b6b);
    color:#fff;
    border:none;
    padding:8px 12px;
    border-radius:20px;
    cursor:pointer;
    font-size:14px;
}
.fc-audio-open:hover{
    transform:translateY(-2px);
    box-shadow:0 6px 18px rgba(255,107,107,.35);
}

.fc-card{position:relative;perspective:1200px;width:100%;height:350px}
.fc-inner{position:relative;width:100%;height:100%;transition:transform .6s;transform-style:preserve-3d;cursor:pointer}
.fc-inner.flipped{transform:rotateY(180deg)}
.fc-face{position:absolute;width:100%;height:100%;-webkit-backface-visibility:hidden;backface-visibility:hidden;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:20px;box-sizing:border-box;border-radius:20px;box-shadow:0 8px 25px rgba(0,0,0,.15);font-size:22px;text-align:center;overflow:hidden}
.fc-text-content{width:100%;height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;white-space:pre-wrap;word-wrap:break-word;line-height:1.5;overflow-y:auto}
.fc-front{background:linear-gradient(135deg,#667eea,#764ba2);color:#fff}
.fc-back{background:linear-gradient(135deg,#f093fb,#f5576c);color:#fff;transform:rotateY(180deg)}
.fc-image-container{max-height:100%;margin:0;padding:0;width:100%;height:100%;display:none;align-items:center;justify-content:center}
.fc-image-container img{max-width:100%;max-height:100%;height:auto;border-radius:8px;object-fit:contain}
.fc-inner.image-only .fc-face.fc-front{padding:0}
.fc-btns{text-align:center;margin-top:20px}
.fc-shortcut-guide,.fc-shortcut-guide-quiz,.fc-shortcut-guide-write{color:#888;font-size:14px;margin-top:15px;text-align:center}
.fc-btn-row{margin:10px 0}
.fc-btn{padding:12px 25px;margin:5px;border:none;border-radius:25px;cursor:pointer;font-size:16px;font-weight:700;transition:all .3s; font-family: 'Nunito', sans-serif;}
.fc-btn:hover{transform:translateY(-2px);box-shadow:0 4px 15px rgba(0,0,0,.2)}
.fc-hard{background:#e74c3c;color:#fff}
.fc-easy{background:#27ae60;color:#fff}
.fc-quiz{background:#9b59b6;color:#fff}
.fc-write{background:#3498db;color:#fff}
.fc-restart,.fc-export,.fc-quiz-exit,.fc-quiz-restart,.fc-back-flashcard,.fc-write-exit{background:#34495e;color:#fff;margin-top:15px}
.fc-restart-hard,.fc-quiz-restart-wrong{background:#e74c3c;color:#fff;margin-top:15px}
.fc-summary{display:flex;gap:20px;justify-content:center;margin:20px 0}
.fc-stat{padding:15px 30px;background:#f8f9fa;border-radius:10px;font-size:18px;font-weight:600}
.fc-lists{display:grid;grid-template-columns:1fr 1fr;gap:20px;margin:20px 0}
.fc-list{padding:15px;background:#f8f9fa;border-radius:10px}
.fc-list h4{margin:0 0 15px;text-align:center}
.fc-list div div{padding:8px;margin:5px 0;background:#fff;border-left:4px solid #3498db;border-radius:5px;font-size:14px}
.fc-quiz-mode,.fc-quiz-results,.fc-results,.fc-writing-mode{background:#fff;padding:20px;border-radius:15px;box-shadow:0 4px 20px rgba(0,0,0,.1)}
.fc-quiz-controls{display:flex;justify-content:space-between;align-items:center;margin-bottom:15px}
.fc-quiz-options-toggle{position:relative}
.fc-quiz-options-list{position:absolute;top:100%;right:0;background:#fff;border:1px solid #ddd;padding:10px;border-radius:5px;z-index:10;width:200px;box-shadow:0 2px 5px rgba(0,0,0,.1)}
.fc-quiz-options-list label{display:block;padding:5px;font-size:14px}
.fc-quiz-question{font-size:18px;margin-bottom:20px;padding:15px;background:linear-gradient(135deg,#667eea,#764ba2);color:#fff;border-radius:10px;text-align:center}
.fc-quiz-options{display:grid;gap:10px;margin:20px 0}
.fc-quiz-option{padding:12px 15px;border:2px solid #ddd;border-radius:10px;background:#fff;cursor:pointer;font-size:16px;text-align:left;transition:all .3s; font-family: 'Nunito', sans-serif;}
.fc-quiz-option:hover{border-color:#3498db;background:#f0f8ff}
.fc-quiz-option.correct{background:#d4edda;border-color:#28a745}
.fc-quiz-option.wrong{background:#f8d7da;border-color:#dc3545}
.fc-quiz-feedback{padding:12px;margin:15px 0;border-radius:10px;font-size:16px;font-weight:600;text-align:center}
.correct-feedback{background:#d4edda;color:#155724}
.wrong-feedback{background:#f8d7da;color:#721c24}
.fc-quiz-next{background:#3498db;color:#fff}
.fc-quiz-results h3,.fc-results h3{text-align:center;margin-bottom:20px;color:#2c3e50;font-size:22px}

/* --- Back Content Specific Styling --- */
.fc-back-line-front {
    font-size: 1.2em;
    font-weight: 800;
    color: #ffeaa7;
    margin-bottom: 5px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.fc-back-line-1 {
    font-size: 1em;
    margin-bottom: 5px;
}
.fc-separator {
    width: 80%;
    height: 2px;
    background: linear-gradient(to right, rgba(255,255,255,0), rgba(255,255,255,0.8), rgba(255,255,255,0));
    margin: 10px auto;
    border-radius: 2px;
}
.fc-back-line-2, .fc-back-line-3 {
    font-size: 0.95em;
    opacity: 0.95;
    margin-bottom: 4px;
}

/* --- Writing Mode Styles --- */
.fc-writing-controls { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.fc-write-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.fc-write-exit { margin-top: 0; }
.fc-write-actions .fc-btn { padding: 8px 15px; font-size: 14px; margin: 0; }
.fc-write-card-selector { font-size: 14px; padding: 8px; border-radius: 5px; max-width: 150px; font-family: 'Nunito', sans-serif;}
.fc-writing-area { position: relative; width: 100%; margin: 20px auto 0; }
.fc-writing-grid { display: flex; flex-wrap: wrap; justify-content: center; width: 100%; }
.fc-writing-char-box { width: 150px; height: 150px; border: 1px dashed #ccc; display: flex; justify-content: center; align-items: center; font-size: 90px; color: #e0e0e0; user-select: none; transition: color 0.3s; font-family: 'Nunito', sans-serif; font-weight: 600;}
.fc-writing-char-box.hide-ghost { color: transparent; }
#fc-writing-canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; touch-action: none; }

/* --- Icon Button Styles --- */
.fc-btn-icon {
    padding: 8px 12px;
    font-size: 14px;
    line-height: 1;
    min-width: 42px;
}
.fc-quiz-controls .fc-btn-icon {
    padding: 10px 12px;
    font-size: 16px;
    margin: 0;
}
.fc-header .fc-swap-sides,
.fc-header .fc-audio-open {
    padding: 8px 12px;
    font-size: 14px;
}

/* --- Audio Modal --- */
.fc-audio-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
}
.fc-audio-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, 0.55);
    backdrop-filter: blur(2px);
}
.fc-audio-dialog {
    position: absolute;
    top: 50%;
    left: 50%;
    width: min(540px, calc(100% - 30px));
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 16px;
    overflow: visible;
    box-shadow: 0 18px 48px rgba(0,0,0,.28);
    animation: fcAudioPop .2s ease-out;
}
@keyframes fcAudioPop {
    from { opacity: 0; transform: translate(-50%, -47%) scale(0.98); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.fc-audio-dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border-radius: 16px 16px 0 0;
}
.fc-audio-dialog-head h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}
.fc-audio-close {
    margin: 0;
    background: rgba(255,255,255,.18);
    color: #fff;
}
.fc-audio-close:hover {
    background: rgba(255,255,255,.28);
}
.fc-audio-dialog-body {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow: visible;
}
.fc-audio-player {
    display: block;
    width: 100%;
    min-height: 54px;
    margin: 0;
    flex: 0 0 auto;
}
.fc-audio-player::-webkit-media-controls-panel {
    overflow: visible;
}
.fc-audio-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    position: relative;
    z-index: 1;
}
.fc-audio-replay,
.fc-audio-loop-toggle {
    margin: 0;
    background: #eef2ff;
    color: #2c3e50;
}
.fc-audio-replay:hover,
.fc-audio-loop-toggle:hover {
    background: #dfe7ff;
}
.fc-audio-loop-toggle.active {
    background: #27ae60;
    color: #fff;
}

@media(max-width:640px){
    .fc-collection-wrap { padding: 10px; }
    .fc-wrap { padding: 0; } 
    .fc-header, .fc-main-content, .fc-results, .fc-quiz-results {
        padding-left: 10px;
        padding-right: 10px;
    }
    .fc-writing-mode { padding: 10px 0; }
    .fc-writing-grid { flex-direction: column; align-items: center; }
    .fc-writing-char-box {
        width: 80vw;
        height: 80vw;
        max-width: 250px;
        max-height: 250px;
        font-size: 150px;
        margin-bottom: 10px;
    }

    .fc-header{
        grid-template-areas:"title title" "progress progress" "actions actions";
        grid-template-columns:1fr;
    }
    .fc-header h3{padding-left:0;font-size:20px}
    .fc-header-actions{justify-self:center;margin-top:10px}
    .fc-lists{grid-template-columns:1fr}
    .fc-summary{flex-direction:column;gap:10px}
    .fc-stat{padding:10px}
    .fc-write-actions{justify-content:center;width:100%}
    .fc-collection-main-title { font-size: 22px; }
    .fc-back-to-parent { font-size: 20px; }

    .fc-audio-dialog {
        width: calc(100% - 20px);
    }
    .fc-audio-dialog-body {
        padding: 14px;
        gap: 12px;
    }
    .fc-audio-actions {
        gap: 8px;
    }
    .fc-audio-replay,
    .fc-audio-loop-toggle {
        width: 100%;
        justify-content: center;
    }
}