/* === PDF TEST CREATION - SHUB-STYLE PREMIUM === */

/* --- Layout chính --- */
.pdf-creator-page { min-height: 100vh; background: linear-gradient(135deg, #f0f4ff 0%, #e8edf5 100%); }

.pdf-creator-layout {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 1.5rem;
    min-height: calc(100vh - 120px);
    align-items: start;
}

.container--full-width {
    width: 98%; max-width: none; margin: 0 auto; padding: 0 1rem;
}

/* --- Stepper Bar (3 bước) --- */
.stepper-bar {
    display: flex; align-items: center; justify-content: center;
    background: white; border-radius: 16px; padding: 16px 32px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06); margin-bottom: 1.5rem;
    gap: 0;
}
.stepper-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 24px; border-radius: 12px; cursor: pointer;
    font-weight: 600; font-size: 0.95rem; color: #94a3b8;
    transition: all 0.3s ease; position: relative; user-select: none;
}
.stepper-item .step-number {
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem; font-weight: 700;
    background: #e2e8f0; color: #94a3b8; transition: all 0.3s ease;
    flex-shrink: 0;
}
.stepper-item.active { color: #1e293b; background: #eff6ff; }
.stepper-item.active .step-number { background: #3b82f6; color: white; box-shadow: 0 2px 8px rgba(59,130,246,0.3); }
.stepper-item.completed .step-number { background: #10b981; color: white; }
.stepper-item.completed { color: #10b981; }
.stepper-connector { width: 48px; height: 2px; background: #e2e8f0; margin: 0 4px; flex-shrink: 0; }
.stepper-connector.active { background: #3b82f6; }

/* --- Summary Bar --- */
.summary-bar {
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
    background: white; border-radius: 14px; padding: 14px 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.05); margin-bottom: 1.5rem;
    border: 1px solid #e2e8f0;
}
.summary-item {
    display: flex; align-items: center; gap: 8px; font-size: 0.92rem;
}
.summary-item label { color: #64748b; font-weight: 500; white-space: nowrap; }
.summary-item input[type="number"] {
    width: 70px; padding: 6px 10px; border: 1.5px solid #e2e8f0;
    border-radius: 8px; font-size: 1rem; font-weight: 700;
    color: #1e293b; text-align: center; transition: border-color 0.2s;
}
.summary-item input[type="number"]:focus { border-color: #3b82f6; outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
.summary-separator { width: 1px; height: 28px; background: #e2e8f0; }
.summary-bar .btn-action {
    padding: 8px 18px; border-radius: 10px; border: 1.5px solid #e2e8f0;
    background: white; font-weight: 600; font-size: 0.88rem;
    cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 6px;
    color: #475569;
}
.summary-bar .btn-action:hover { border-color: #3b82f6; color: #3b82f6; background: #eff6ff; }
.summary-bar .btn-action.btn-save {
    background: linear-gradient(135deg, #3b82f6, #2563eb); color: white; border: none;
    box-shadow: 0 2px 8px rgba(37,99,235,0.25);
}
.summary-bar .btn-action.btn-save:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,0.35); }
.summary-bar .btn-action:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* --- PDF Viewer --- */
.pdf-viewer-container {
    background: white; border-radius: 16px; padding: 1.25rem;
    overflow-y: auto; box-shadow: 0 2px 16px rgba(0,0,0,0.06);
    max-height: calc(100vh - 240px); position: sticky; top: 100px;
    border: 1px solid #e2e8f0;
}
#pdf-upload-area {
    border: 2.5px dashed #cbd5e1; border-radius: 16px;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    min-height: 400px; text-align: center; color: #94a3b8;
    transition: all 0.3s ease; cursor: pointer; padding: 2rem;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
}
#pdf-upload-area:hover, #pdf-upload-area.drag-over {
    border-color: #3b82f6; background: linear-gradient(135deg, #eff6ff, #dbeafe);
    color: #3b82f6;
}
#pdf-upload-area i { font-size: 3.5rem; margin-bottom: 1rem; }
#pdf-upload-area p { font-size: 1.05rem; margin: 0 0 1rem; }
#pdf-upload-area .file-info { font-size: 0.85rem; color: #94a3b8; margin-top: 0.5rem; }
#pdf-render-area { display: none; }
#pdf-render-area canvas { width: 100% !important; height: auto !important; margin-bottom: 8px; border-radius: 4px; }

/* --- PDF loaded info bar --- */
.pdf-loaded-bar {
    display: flex; align-items: center; gap: 10px; padding: 10px 16px;
    background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 10px;
    margin-bottom: 12px; font-size: 0.9rem; color: #166534;
}
.pdf-loaded-bar i { color: #22c55e; }
.pdf-loaded-bar .pdf-name { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdf-loaded-bar .btn-change-pdf {
    padding: 4px 12px; border-radius: 6px; border: 1px solid #bbf7d0;
    background: white; color: #166534; font-size: 0.82rem; cursor: pointer;
    font-weight: 500; transition: all 0.2s;
}
.pdf-loaded-bar .btn-change-pdf:hover { background: #dcfce7; }

/* --- Extracting overlay --- */
.extracting-overlay {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 2rem; gap: 12px; color: #64748b;
}
.extracting-overlay .spinner {
    width: 36px; height: 36px; border: 3px solid #e2e8f0;
    border-top-color: #3b82f6; border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Settings/Answer Panel --- */
.settings-panel {
    background: transparent; padding: 0; overflow-y: visible;
}

/* --- Answer Card Grid --- */
.answer-grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 14px;
}

/* --- Individual Answer Card --- */
.answer-card {
    background: white; border-radius: 14px; padding: 16px;
    border: 1.5px solid #e2e8f0; transition: all 0.25s ease;
    position: relative; overflow: hidden;
}
.answer-card::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0;
    width: 4px; background: linear-gradient(180deg, #3b82f6, #8b5cf6);
    border-radius: 4px 0 0 4px; opacity: 0; transition: opacity 0.2s;
}
.answer-card:hover { border-color: #93c5fd; box-shadow: 0 4px 16px rgba(59,130,246,0.08); }
.answer-card:hover::before { opacity: 1; }
.answer-card.has-answer { border-color: #86efac; }
.answer-card.has-answer::before { background: linear-gradient(180deg, #22c55e, #10b981); opacity: 1; }

.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid #f1f5f9;
}
.card-question-number {
    font-weight: 800; font-size: 1rem; color: #1e293b;
    display: flex; align-items: center; gap: 6px;
}
.card-question-number .q-badge {
    background: linear-gradient(135deg, #3b82f6, #6366f1); color: white;
    width: 28px; height: 28px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; font-weight: 700;
}
.card-type-select {
    padding: 4px 10px; border-radius: 8px; border: 1px solid #e2e8f0;
    font-size: 0.82rem; color: #475569; background: #f8fafc;
    cursor: pointer; font-weight: 500;
}
.card-type-select:focus { border-color: #3b82f6; outline: none; }

/* Card body */
.card-body { display: flex; flex-direction: column; gap: 10px; }
.card-row { display: flex; align-items: center; gap: 8px; }
.card-row label {
    font-size: 0.82rem; color: #64748b; font-weight: 500;
    min-width: 55px; white-space: nowrap;
}
.card-row input[type="text"], .card-row input[type="number"], .card-row input[type="url"] {
    flex: 1; padding: 7px 12px; border: 1.5px solid #e2e8f0;
    border-radius: 8px; font-size: 0.9rem; transition: border-color 0.2s;
    min-width: 0;
}
.card-row input:focus { border-color: #3b82f6; outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,0.08); }

/* ABCD buttons for MCQ */
.abcd-options {
    display: flex; gap: 6px; flex: 1;
}
.abcd-btn {
    width: 36px; height: 36px; border-radius: 10px;
    border: 1.5px solid #e2e8f0; background: white;
    font-weight: 700; font-size: 0.9rem; color: #64748b;
    cursor: pointer; transition: all 0.2s; display: flex;
    align-items: center; justify-content: center;
}
.abcd-btn:hover { border-color: #3b82f6; color: #3b82f6; background: #eff6ff; }
.abcd-btn.selected {
    background: linear-gradient(135deg, #3b82f6, #2563eb); color: white;
    border-color: transparent; box-shadow: 0 2px 8px rgba(59,130,246,0.3);
    transform: scale(1.05);
}

/* Video link & hint toggle */
.card-extras { margin-top: 4px; }
.card-extras-toggle {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.8rem; color: #94a3b8; cursor: pointer;
    padding: 4px 0; transition: color 0.2s; border: none; background: none;
}
.card-extras-toggle:hover { color: #3b82f6; }
.card-extras-content {
    display: none; flex-direction: column; gap: 8px;
    margin-top: 8px; padding-top: 8px; border-top: 1px dashed #e2e8f0;
}
.card-extras-content.show { display: flex; }

/* --- Step 2: Extended info panel --- */
.step-content { display: none; }
.step-content.active { display: block; }

/* --- Step 3: Test settings --- */
.test-settings-form {
    background: white; border-radius: 16px; padding: 24px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.06); border: 1px solid #e2e8f0;
}
.test-settings-form .form-group { margin-bottom: 16px; }
.test-settings-form .form-group label {
    display: block; font-weight: 600; font-size: 0.9rem;
    color: #334155; margin-bottom: 6px;
}
.test-settings-form .form-group input,
.test-settings-form .form-group select {
    width: 100%; padding: 10px 14px; border: 1.5px solid #e2e8f0;
    border-radius: 10px; font-size: 0.95rem; transition: border-color 0.2s;
}
.test-settings-form .form-group input:focus,
.test-settings-form .form-group select:focus { border-color: #3b82f6; outline: none; }
.test-settings-form .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.test-settings-form .form-group-inline {
    display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
}

/* --- Detected sections panel --- */
.detected-sections {
    background: #fffbeb; border: 1px solid #fde68a; border-radius: 12px;
    padding: 14px 18px; margin-bottom: 16px;
}
.detected-sections h4 {
    font-size: 0.9rem; color: #92400e; margin: 0 0 8px;
    display: flex; align-items: center; gap: 6px;
}
.detected-sections ul {
    list-style: none; padding: 0; margin: 0;
    display: flex; flex-wrap: wrap; gap: 8px;
}
.detected-sections li {
    padding: 4px 12px; background: #fef3c7; border-radius: 8px;
    font-size: 0.82rem; color: #78350f; font-weight: 500;
}

/* --- Modal Nhập Nhanh (upgraded) --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.5); backdrop-filter: blur(4px);
    display: flex; justify-content: center; align-items: center; z-index: 1000;
}
.modal-content {
    background: white; padding: 28px; border-radius: 18px;
    width: 92%; max-width: 480px; position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    animation: modalIn 0.3s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(20px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-content h3 { margin: 0 0 16px; font-size: 1.2rem; color: #1e293b; }
.close-modal {
    position: absolute; top: 12px; right: 16px; background: none; border: none;
    font-size: 1.8rem; cursor: pointer; color: #94a3b8; line-height: 1;
}
.close-modal:hover { color: #1e293b; }
.modal-tabs { display: flex; gap: 8px; margin: 0 0 16px; }
.modal-tab {
    padding: 8px 20px; cursor: pointer; background: white;
    border: 1.5px solid #e2e8f0; border-radius: 10px;
    font-size: 0.92rem; font-weight: 600; transition: all 0.2s; color: #475569;
}
.modal-tab.active { background: #1e40af; color: white; border-color: #1e40af; }
.modal-tab-content textarea, .modal-tab-content input {
    width: 100%; box-sizing: border-box; padding: 12px 14px;
    font-size: 1rem; border: 1.5px solid #e2e8f0; border-radius: 10px;
    transition: border-color 0.2s;
}
.modal-tab-content textarea:focus, .modal-tab-content input:focus {
    border-color: #3b82f6; outline: none;
}
#answer-counter { margin-top: 6px; font-size: 0.85rem; color: #64748b; text-align: right; display: block; }
.modal-actions { margin-top: 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions .button { padding: 10px 20px; border-radius: 10px; font-weight: 600; font-size: 0.95rem; cursor: pointer; border: none; transition: all 0.2s; }

/* --- Scroll buttons --- */
.scroll-buttons { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.scroll-buttons button {
    width: 44px; height: 44px; border-radius: 12px; border: none;
    background: white; box-shadow: 0 2px 12px rgba(0,0,0,0.1);
    cursor: pointer; font-size: 1rem; color: #475569; transition: all 0.2s;
}
.scroll-buttons button:hover { background: #3b82f6; color: white; transform: translateY(-2px); }

/* --- Auto-detect badge --- */
.auto-detect-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 10px; border-radius: 6px; font-size: 0.75rem;
    background: #dbeafe; color: #1d4ed8; font-weight: 600;
    animation: fadeIn 0.5s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* --- Responsive --- */
@media (max-width: 900px) {
    .pdf-creator-layout { grid-template-columns: 1fr; }
    .pdf-viewer-container { position: static; max-height: 50vh; }
    .stepper-bar { padding: 12px 16px; gap: 0; overflow-x: auto; }
    .stepper-item { padding: 8px 12px; font-size: 0.85rem; }
    .stepper-connector { width: 24px; }
    .summary-bar { flex-wrap: wrap; padding: 12px 16px; gap: 10px; }
    .answer-grid-cards { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

@media (max-width: 600px) {
    .stepper-item span:not(.step-number) { display: none; }
    .summary-separator { display: none; }
    .answer-grid-cards { grid-template-columns: 1fr; }
    .test-settings-form .form-row { grid-template-columns: 1fr; }
}