:root {
    --primary: #4361EE;
    --primary-hover: #3A53D0;
    --bg: #F3F4F6;
    --panel-bg: #FFFFFF;
    --text: #1F2937;
    --border: #E5E7EB;
    --success: #10B981;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }

body, html { height: 100%; background-color: var(--bg); color: var(--text); overflow: hidden; }

/* Top Navigation */
.top-nav-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    z-index: 10;
    position: relative;
    height: 60px;
}

.site-title { font-size: 1.2rem; font-weight: bold; color: #2C3E50; }

.mode-switcher { display: flex; gap: 10px; }
.mode-btn { background: #F8FAFC; border: 1px solid var(--border); padding: 8px 16px; font-weight: 600; color: #6B7280; cursor: pointer; border-radius: 6px; transition: all 0.2s; }
.mode-btn:hover { background: #F1F5F9; }
.mode-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* Project Actions (Save / Load) */
.project-actions { display: flex; gap: 10px; align-items: center; }
.project-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #F8FAFC;
    border: 1px solid var(--border);
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.project-btn:hover {
    background: #EEF2F6;
    border-color: #CBD5E1;
    color: #111827;
    transform: translateY(-1px);
}
.project-btn.save-btn:hover {
    background: #EFF6FF;
    border-color: #93C5FD;
    color: #1D4ED8;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.15);
}
.project-btn.load-btn:hover {
    background: #F0FDF4;
    border-color: #86EFAC;
    color: #15803D;
    box-shadow: 0 2px 6px rgba(34, 197, 94, 0.15);
}
.project-btn:active {
    transform: translateY(0);
}

/* Toast Notification */
.project-toast {
    position: fixed;
    top: 75px;
    right: 25px;
    background: #1E293B;
    color: #FFFFFF;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.project-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.app-container { display: flex; height: calc(100vh - 60px); position: relative; }

/* Admin Panel Wrapper & Sidebar (расширен до 530px) */
.admin-panel-wrapper { position: relative; width: 530px; min-width: 530px; height: 100%; display: flex; z-index: 20; }
.admin-panel { width: 100%; height: 100%; background: var(--panel-bg); padding: 25px 25px; border-right: 1px solid var(--border); overflow-y: auto; box-shadow: 2px 0 10px rgba(0,0,0,0.02); }
.admin-panel h2, .admin-panel h3 { font-size: 1.1rem; margin-bottom: 15px; color: #111827; }

/* Вертикальная красная закладка ТЕСТЫ на ребре пульта */
.notes-tab-btn {
    position: absolute;
    right: -38px;
    top: 90px;
    width: 38px;
    height: 110px;
    background-color: #ef4444;
    border: none;
    border-radius: 0 10px 10px 0;
    cursor: pointer;
    box-shadow: 4px 0 15px rgba(239, 68, 68, 0.35);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}
.notes-tab-btn:hover {
    background-color: #dc2626;
    transform: translateX(2px);
}
.notes-tab-btn.active {
    background-color: #b91c1c;
    box-shadow: 4px 0 18px rgba(185, 28, 28, 0.45);
}
.notes-tab-btn span {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 2px;
    font-size: 13px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* Выезжающий блокнот поверх пульта */
.notes-drawer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #ffffff;
    z-index: 95;
    border-right: 1px solid var(--border);
    box-shadow: 8px 0 25px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}
.notes-drawer.open {
    transform: translateX(0);
}

.notes-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}
.notes-drawer-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
}
.notes-autosave-badge {
    font-size: 11px;
    font-weight: 600;
    color: #059669;
    background: #d1fae5;
    padding: 3px 8px;
    border-radius: 12px;
}
.notes-close-btn {
    background: transparent;
    border: none;
    font-size: 20px;
    color: #64748b;
    cursor: pointer;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 4px;
    transition: 0.15s;
}
.notes-close-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.notes-quick-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    gap: 10px;
}
.quick-btn-group {
    display: flex;
    align-items: center;
    gap: 6px;
}
.quick-action-btn {
    width: 36px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-weight: 700;
    font-size: 14px;
    color: #1e293b;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}
.quick-action-btn:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}
.quick-action-btn.btn-question {
    color: #4361ee;
    font-size: 16px;
}
.quick-action-btn.btn-add {
    background: #10b981;
    border-color: #059669;
    color: white;
    font-size: 20px;
    width: 44px;
    margin-left: 4px;
}
.quick-action-btn.btn-add:hover {
    background: #059669;
}
.quick-action-btn.correct-active {
    background: #10b981 !important;
    border-color: #059669 !important;
    color: #ffffff !important;
}

.notes-textarea {
    flex: 1;
    width: 100%;
    padding: 16px 20px;
    border: none;
    outline: none;
    font-size: 14px;
    line-height: 1.6;
    color: #1e293b;
    resize: none;
    background: #fafafa;
    font-family: inherit;
}
.notes-footer {
    padding: 8px 16px;
    font-size: 12px;
    color: #64748b;
    background: #f8fafc;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.form-group { margin-bottom: 15px; }
.form-group label, .answers-group label { display: block; font-size: 13px; margin-bottom: 8px; font-weight: 600; color: #4B5563; }
.form-group textarea, .answer-item input[type="text"] { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; resize: vertical; }
.form-group textarea:focus, .answer-item input[type="text"]:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1); }

.answers-group { margin-bottom: 20px; }
.answer-item { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.answer-item input[type="radio"] { width: 18px; height: 18px; cursor: pointer; accent-color: var(--primary); }

.control-group { background: #FAFAFA; border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 15px; }

/* Buttons */
.primary-btn, .secondary-btn { width: 100%; padding: 12px; border: none; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.primary-btn { background: var(--primary); color: white; }
.primary-btn:hover { opacity: 0.9; }
.secondary-btn { background: transparent; border: 1px solid var(--border); color: #4B5563; }
.secondary-btn:hover { background: #F9FAFB; }

/* Preview Panel */
.preview-panel { flex: 1; padding: 40px; overflow-y: auto; display: flex; flex-direction: column; align-items: center; }

/* PDF Pages Grid */
.pages-container { display: flex; flex-direction: column; align-items: center; gap: 40px; width: 100%; padding-bottom: 40px; }
.pages-container.exporting-pdf { gap: 0 !important; padding: 0 !important; }
.pages-container.exporting-pdf .page { box-shadow: none !important; margin: 0 !important; border-radius: 0 !important; }

.page { 
    width: 793px; 
    min-height: 1122px; 
    box-sizing: border-box; 
    background: white; 
    box-shadow: 0 10px 25px rgba(0,0,0,0.1); 
    padding: 24px 20px; 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    grid-auto-rows: min-content; 
    gap: 14px; 
    position: relative; 
    page-break-after: always; 
    break-after: page; 
}

/* Test Card on A4 */
.card { 
    border: 1.5px solid var(--border); 
    border-radius: 10px; 
    padding: 12px 14px; 
    background: #fff; 
    position: relative; 
    display: flex; 
    flex-direction: column; 
    box-sizing: border-box; 
    page-break-inside: avoid !important; 
    break-inside: avoid !important; 
}
.card-question { font-weight: 600; font-size: 15px; line-height: 1.35; margin-bottom: 10px; color: #111827; word-break: break-word; }
.card-answers { display: flex; flex-direction: column; gap: 6px; }
.card-answer-item { font-size: 13.5px; line-height: 1.3; padding: 6px 10px; border: 1px solid #F3F4F6; border-radius: 6px; color: #4B5563; background: #FAFAFA; word-break: break-word; }
.card-answer-item.correct { border-color: var(--success); background: rgba(16, 185, 129, 0.1); color: #065F46; font-weight: 600; }
.card-answer-item.hidden-correct { border-color: #F3F4F6; background: #FAFAFA; color: #4B5563; font-weight: normal; } /* When toggle is active */

.card.editing { border: 2px dashed var(--primary) !important; background-color: #EEF2FF !important; }
.card.editing::after { content: 'РЕДАКТИРОВАНИЕ'; position: absolute; bottom: 0; left: 0; width: 100%; background: var(--primary); color: white; font-size: 11px; font-weight: 600; text-align: center; padding: 4px 0; border-radius: 0 0 8px 8px; z-index: 10; }

.delete-card-btn, .edit-card-btn { position: absolute; top: 10px; color: white; border: none; border-radius: 50%; width: 24px; height: 24px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 14px; opacity: 0; transition: 0.2s; z-index: 5; }
.delete-card-btn { right: 10px; background: #EF4444; }
.edit-card-btn { right: 40px; background: #3B82F6; font-size: 12px; }

.card:hover .delete-card-btn, .card:hover .edit-card-btn { opacity: 1; }

/* Video Container */
.video-container { width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; }
.canvas-wrapper { height: 100%; max-height: 800px; aspect-ratio: 9/16; background: white; border-radius: 12px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,0.1); position: relative; }
canvas { width: 100%; height: 100%; object-fit: contain; }

.export-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255,255,255,0.9); display: flex; flex-direction: column; justify-content: center; align-items: center; z-index: 10; }
.spinner { width: 40px; height: 40px; border: 4px solid var(--border); border-top: 4px solid var(--primary); border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 15px; }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* Player Controls */
.player-controls { position: absolute; bottom: 0; left: 0; width: 100%; padding: 15px 20px; background: rgba(255,255,255,0.95); display: flex; align-items: center; gap: 15px; border-top: 1px solid var(--border); box-shadow: 0 -5px 15px rgba(0,0,0,0.05); backdrop-filter: blur(5px); z-index: 5; }
.play-btn { width: 36px; height: 36px; border-radius: 50%; border: none; background: var(--primary); color: white; display: flex; justify-content: center; align-items: center; cursor: pointer; font-size: 14px; flex-shrink: 0; }
.play-btn:hover { opacity: 0.9; }
input[type=range] { flex: 1; accent-color: var(--primary); cursor: pointer; }
#videoTimeDisplay { font-size: 12px; font-weight: 600; color: #4B5563; flex-shrink: 0; font-family: monospace; }

/* Custom Typography Range Slider (стиль QUIZ_app_PRO) */
.custom-range-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e2e8f0;
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
    margin: 8px 0 4px 0;
}
.custom-range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid #ffffff;
    box-shadow: 0 2px 6px rgba(67, 97, 238, 0.4);
    cursor: pointer;
    transition: transform 0.15s ease;
}
.custom-range-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}
.font-size-badge {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    padding: 3px 10px;
    border-radius: 6px;
    font-family: inherit;
}

/* Print adjustments */
@media print {
    body { background: white; }
    .top-nav-bar, .admin-panel, .delete-card-btn { display: none !important; }
    .app-container { height: auto; overflow: visible; display: block; }
    .preview-panel { padding: 0; overflow: visible; display: block; }
    .pages-container { gap: 0; padding-bottom: 0; }
    .page { box-shadow: none; margin: 0; border: none; page-break-after: always; min-height: 297mm; }
}
