/* ═══════════════════════════════════════════
   shared.css — Design System
   ═══════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
    --bg: #f0f4f8;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-bg: rgba(37, 99, 235, .08);
    --accent-glow: rgba(37, 99, 235, .18);
    --green: #16a34a;
    --green-bg: rgba(22, 163, 74, .12);
    --red: #dc2626;
    --red-bg: rgba(220, 38, 38, .10);
    --orange: #ea580c;
    --orange-bg: rgba(234, 88, 12, .10);
    --purple: #7c3aed;
    --text: #1e293b;
    --text-dim: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .06);
    --shadow-md: 0 1px 3px rgba(0, 0, 0, .06), 0 4px 16px rgba(0, 0, 0, .04);
    --shadow-lg: 0 4px 24px rgba(0, 0, 0, .08), 0 12px 48px rgba(0, 0, 0, .04);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--r-sm);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
    text-decoration: none;
}

.btn svg {
    width: 16px;
    height: 16px;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(37, 99, 235, .25);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(37, 99, 235, .35);
}

.btn-success {
    background: var(--green);
    color: #fff;
}

.btn-success:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--red);
    color: #fff;
}

.btn-danger:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.btn-outline {
    background: #fff;
    color: var(--text);
    border: 1.5px solid var(--border);
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 32px;
    font-size: 16px;
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none !important;
}

/* ─── Form elements ─── */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.form-input,
.form-select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--r-sm);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--text);
    background: #fff;
    transition: border-color .2s, box-shadow .2s;
    outline: none;
}

.form-input:focus,
.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input.error {
    border-color: var(--red);
    box-shadow: 0 0 0 3px var(--red-bg);
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-error {
    font-size: 12px;
    color: var(--red);
    margin-top: 4px;
}

/* ─── Cards ─── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-title {
    font-size: 16px;
    font-weight: 700;
}

/* ─── Tables ─── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th {
    text-align: left;
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-dim);
    border-bottom: 2px solid var(--border);
    background: #f8fafc;
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background .15s;
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ─── Badges ─── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .02em;
}

.badge-blue {
    background: var(--accent-bg);
    color: var(--accent);
}

.badge-green {
    background: var(--green-bg);
    color: var(--green);
}

.badge-red {
    background: var(--red-bg);
    color: var(--red);
}

.badge-orange {
    background: var(--orange-bg);
    color: var(--orange);
}

.badge-gray {
    background: #f1f5f9;
    color: var(--text-muted);
}

/* ─── Modal ─── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: #fff;
    border-radius: var(--r-lg);
    padding: 28px;
    width: 90%;
    max-width: 520px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: translateY(10px);
    transition: transform .2s;
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* ─── Empty state ─── */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: .5;
}

.empty-state p {
    font-size: 14px;
}

/* ─── Utility ─── */
.text-accent {
    color: var(--accent);
}

.text-green {
    color: var(--green);
}

.text-red {
    color: var(--red);
}

.text-dim {
    color: var(--text-dim);
}

.text-muted {
    color: var(--text-muted);
}

/* ═══════════════════════════════════════════
   Q_Render — Image Layout System
   ═══════════════════════════════════════════ */

/* Base image wrapper */
.question-diagram {
    margin-bottom: 10px;
    margin-top: 10px;
    text-align: center;
}

.question-diagram img {
    width: 100%;
    height: auto;
    pointer-events: none;
    display: block;
}

/* Float contexts (text wraps around image) */
.question-diagram.float-right { float: right; margin-left: 20px; }
.question-diagram.float-left  { float: left;  margin-right: 20px; }

/* Block contexts (no text wrap, breaks flow) */
.question-diagram.block-left   { display: block; margin-right: auto; margin-left: 0; clear: both; }
.question-diagram.block-right  { display: block; margin-left: auto; margin-right: 0; clear: both; }
.question-diagram.block-center { display: block; margin-left: auto; margin-right: auto; clear: both; }

/* Draggable image (editor mode) */
.question-diagram.draggable {
    cursor: grab;
    border: 1px dashed transparent;
    z-index: 10;
    position: relative;
}
.question-diagram.draggable:active { cursor: grabbing; }
.question-diagram.draggable:hover  { border-color: var(--accent); }

/* Resize handle (editor mode) */
.resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 15px;
    height: 15px;
    background: var(--accent);
    cursor: nwse-resize;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 11;
}
.question-diagram.draggable:hover .resize-handle { opacity: 1; }

/* Image editor control bar */
.image-editor {
    margin-top: 5px;
    opacity: 0.3;
    transition: opacity 0.2s;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.image-editor:hover { opacity: 1; }
.image-editor label { display: inline-flex; align-items: center; gap: 4px; }
.image-editor select {
    font-size: 11px;
    padding: 2px 4px;
    border-radius: 4px;
    border: 1px solid var(--border);
}
.image-editor .drag-hint {
    color: var(--red);
    font-weight: bold;
    font-size: 11px;
}

/* ═══════════════════════════════════════════
   Q_Render — Options Layout
   ═══════════════════════════════════════════ */

.qr-options-container {
    margin-top: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 15px 10px;
    clear: both;
}
.qr-options-container.vertical-layout {
    flex-direction: column;
    align-items: flex-start;
}

.qr-option-item {
    font-size: 15px;
    display: flex;
    align-items: center;
    flex: 0 1 auto;
    margin-right: 10px;
    cursor: pointer;
    padding: 8px 15px;
    border-radius: 8px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}
.qr-options-container.vertical-layout .qr-option-item {
    margin-right: 0;
    margin-bottom: 2px;
}

.qr-option-item input[type="radio"] { display: none; }
.qr-option-item:hover { background-color: rgba(0, 0, 0, 0.03); }
.qr-option-item:has(input[type="radio"]:checked) {
    background-color: rgba(37, 99, 235, 0.08);
    border: 1px solid rgba(37, 99, 235, 0.3);
}

.qr-option-number {
    margin-right: 8px;
    font-weight: 600;
    color: var(--text-dim);
}

/* Editor-specific: non-clickable preview */
.qr-option-item.editor-preview { cursor: default; }
.qr-option-item.editor-preview:hover { background-color: transparent; }

/* Correct answer highlight (admin view) */
.qr-option-item.correct-answer {
    background-color: var(--green-bg);
    border: 1px solid var(--green);
}

/* Options layout/correct answer editor bar */
.options-editor {
    margin-top: 15px;
    margin-bottom: 8px;
    opacity: 0.3;
    transition: opacity 0.2s;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    clear: both;
}
.options-editor:hover { opacity: 1; }
.options-editor label {
    background: #f0f0f0;
    padding: 3px 8px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
}
.options-editor select {
    font-size: 11px;
    padding: 2px 4px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

/* Question content wrapper (clearfix for floats) */
.q-render-content {
    overflow: hidden;
    clear: both;
}

/* Question text styling for Q_Render layout */
.q-render-text {
    font-size: 15px;
    text-align: justify;
    line-height: 1.7;
}


.text-sm {
    font-size: 13px;
}

.text-xs {
    font-size: 12px;
}

.fw-600 {
    font-weight: 600;
}

.fw-700 {
    font-weight: 700;
}

.mt-4 {
    margin-top: 4px;
}

.mt-8 {
    margin-top: 8px;
}

.mt-16 {
    margin-top: 16px;
}

.mb-8 {
    margin-bottom: 8px;
}

.mb-16 {
    margin-bottom: 16px;
}

.flex {
    display: flex;
}

.flex-center {
    display: flex;
    align-items: center;
}

.gap-8 {
    gap: 8px;
}

.gap-12 {
    gap: 12px;
}

/* ─── Alert toast ─── */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    padding: 12px 20px;
    border-radius: var(--r-sm);
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    box-shadow: var(--shadow-lg);
    transform: translateX(120%);
    transition: transform .3s ease;
}

.toast.show {
    transform: translateX(0);
}

.toast-success {
    background: var(--green);
}

.toast-error {
    background: var(--red);
}

.toast-info {
    background: var(--accent);
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }

    .data-table {
        font-size: 13px;
    }

    .data-table th,
    .data-table td {
        padding: 8px 10px;
    }
}