/* ════════════════════════════════════════════════════════
   question-detail.css  —  Blazor Question Detail Page
   ════════════════════════════════════════════════════════ */

:root {
    --primary: #1a56db;
    --primary-light: #e8f0fd;
    --primary-dark: #1341b0;
    --success: #0d9f6e;
    --success-light: #e3f8f0;
    --warning: #c27803;
    --warning-light: #fdf3e0;
    --danger: #c81e1e;
    --danger-light: #fde8e8;
    --info: #0694a2;
    --info-light: #e0f7f9;
    --ai: #7c3aed;
    --ai-light: #ede9fe;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --font: 'Vazirmatn', sans-serif;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --shadow-md: 0 4px 16px rgba(0, 0, 0, .08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, .12);
    --transition: .15s ease;
}

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

body {
    font-family: var(--font);
    background: var(--gray-50);
    color: var(--gray-800);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
}

/* ── Page wrapper ── */
.page-wrapper {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px;
}

/* ── Breadcrumb ── */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--gray-400);
    margin-bottom: 20px;
}

.breadcrumb a {
    color: var(--primary);
    text-decoration: none;
    cursor: pointer;
}

.breadcrumb .sep { color: var(--gray-300); }

.breadcrumb .current {
    color: var(--gray-700);
    font-weight: 500;
}

/* ── Page header — کلاس به‌جای inline style  ── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 16px;
}

.page-header-title {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.question-main-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-900);
}

.badge-row {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.page-header-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* ── Main grid ── */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
    align-items: start;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid transparent;
    white-space: nowrap;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: #fff; color: var(--gray-700); border-color: var(--gray-200); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-50); }
.btn-ghost { background: transparent; color: var(--gray-500); border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--gray-100); color: var(--gray-800); }
.btn-danger { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }
.btn-warning { background: var(--warning-light); color: var(--warning); border-color: var(--warning); }
.btn-ai { background: var(--ai); color: #fff; border-color: var(--ai); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 7px; }
.btn .ti { font-size: 14px; }

/* ── Badge ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
}

.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }
.badge-ai { background: var(--ai-light); color: var(--ai); }
.badge-purple { background: #ede9fe; color: #5b21b6; }

/* ── Card ── */
.card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 16px;
}

.card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title { font-size: 13px; font-weight: 600; color: var(--gray-900); }
.card-body { padding: 18px; }

/* ── Question text ── */
.question-text-block {
    font-size: 16px;
    font-weight: 500;
    color: var(--gray-900);
    line-height: 1.8;
    padding: 20px;
    background: var(--gray-50);
    border-radius: var(--radius-md);
    border-right: 4px solid var(--primary);
    margin-bottom: 16px;
}

/* ── Answer options ── */
.answer-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
}

.answer-option.correct { border-color: var(--success); background: var(--success-light); }

.option-mark {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--gray-100);
    color: var(--gray-500);
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.answer-option.correct .option-mark { background: var(--success); color: #fff; }
.option-text { flex: 1; font-size: 13px; color: var(--gray-700); padding-top: 3px; }

/* ── Explanation box ── */
.explanation-box {
    margin-top: 16px;
    padding: 12px;
    background: var(--gray-50);
    border-radius: var(--radius-md);
    border-right: 3px solid var(--warning);
}

.explanation-title { font-size: 11px; font-weight: 600; color: var(--warning); margin-bottom: 4px; }
.explanation-body { font-size: 13px; color: var(--gray-600); }

/* ── Lifecycle stepper ── */
.lc-stepper { display: flex; align-items: center; margin: 4px 0 16px; }

.lc-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    position: relative;
}

.lc-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 14px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--gray-200);
    z-index: 0;
}

.lc-step.done::after { background: var(--primary); }

.lc-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--gray-200);
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    z-index: 1;
    position: relative;
}

.lc-step.done .lc-dot { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.lc-step.current .lc-dot { border-color: var(--primary); background: var(--primary); color: #fff; }
.lc-step.archived .lc-dot { border-color: var(--danger); background: var(--danger-light); color: var(--danger); }

.lc-label { font-size: 10px; color: var(--gray-400); margin-top: 4px; text-align: center; }
.lc-step.current .lc-label { color: var(--primary); font-weight: 500; }

.lc-action-btn { justify-content: center; }

/* ── Toggle switch — قانون ۱۵: فقط @onchange روی input ── */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--gray-50);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
}

.switch { position: relative; width: 38px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }

.switch-track {
    position: absolute;
    inset: 0;
    background: var(--gray-300);
    border-radius: 20px;
    cursor: pointer;
    transition: background .2s;
}

.switch-track::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    top: 3px;
    right: 3px;
    transition: transform .2s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .15);
}

.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(-16px); }
.switch input:disabled + .switch-track { opacity: .5; cursor: not-allowed; }

/* ── Timeline ── */
.timeline { position: relative; padding-right: 20px; }

.timeline::before {
    content: '';
    position: absolute;
    right: 7px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--gray-200);
}

.tl-item { position: relative; padding-bottom: 16px; padding-right: 20px; }

.tl-dot {
    position: absolute;
    right: -7px;
    top: 4px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--primary);
}

.tl-dot.minor { background: var(--gray-300); box-shadow: 0 0 0 2px var(--gray-300); }
.tl-time { font-size: 11px; color: var(--gray-400); margin-bottom: 2px; }
.tl-content { font-size: 13px; color: var(--gray-700); }
.tl-content strong { color: var(--gray-900); }
.tl-detail { font-size: 11px; color: var(--gray-400); margin-top: 2px; }

/* ── Meta table ── */
.meta-table { width: 100%; border-collapse: collapse; }
.meta-table td { padding: 7px 0; border-bottom: 1px solid var(--gray-100); font-size: 13px; vertical-align: top; }
.meta-table td:first-child { color: var(--gray-400); width: 130px; font-size: 12px; }
.meta-table tr:last-child td { border-bottom: none; }

/* ── AI confidence row ── */
.ai-confidence-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

/* ── Media gallery ── */
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.media-item {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
    cursor: pointer;
}

.media-item:hover .media-overlay { opacity: 1; }

.media-thumb {
    width: 100%;
    aspect-ratio: 4 / 3;
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    opacity: 0;
    transition: opacity .2s;
}

.media-overlay .btn { padding: 5px; color: #fff; border-color: rgba(255, 255, 255, .3); }
.media-info { padding: 6px 8px; font-size: 10px; color: var(--gray-400); }

.media-upload-placeholder {
    border: 1.5px dashed var(--gray-200) !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    aspect-ratio: 4 / 3;
}

/* ── Report item ── */
.report-item {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 8px;
}

.report-item.open { border-color: var(--danger); }
.report-item.resolved { border-color: var(--success); }

/* ── Section title ── */
.section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin: 16px 0 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title::after { content: ''; flex: 1; height: 1px; background: var(--gray-200); }

/* ── Info box ── */
.info-box {
    padding: 9px 12px;
    border-radius: var(--radius-md);
    font-size: 12px;
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.info-box.warning { background: var(--warning-light); color: var(--warning); }
.info-box.info { background: var(--info-light); color: var(--info); }
.info-box.ai { background: var(--ai-light); color: var(--ai); }

/* ── Tabs ── */
.tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--gray-200);
    margin-bottom: 16px;
}

.tab {
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-500);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

.tab:hover { color: var(--gray-800); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Tag chip ── */
.tag-chip {
    background: var(--gray-100);
    color: var(--gray-600);
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
}

/* ── Education path ── */
.edu-path-body { padding: 12px 16px; }
.edu-path-list { display: flex; flex-direction: column; gap: 4px; }

.edu-path-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.edu-label { color: var(--gray-400); width: 80px; flex-shrink: 0; }

/* ── Meta JSON pre ── */
.meta-pre {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: 14px;
    font-size: 12px;
    color: var(--gray-600);
    font-family: monospace;
    overflow-x: auto;
    direction: ltr;
    text-align: left;
}

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

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
    background: #fff;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 560px;
    max-width: 96vw;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    transform: translateY(8px);
    transition: transform .2s;
}

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

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.modal-title { font-size: 15px; font-weight: 600; color: var(--gray-900); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-shrink: 0;
}

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

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-600);
    margin-bottom: 5px;
}

.form-control {
    width: 100%;
    padding: 7px 11px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: 13px;
    color: var(--gray-800);
    background: #fff;
    transition: border var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, .1);
}

textarea.form-control { resize: vertical; min-height: 80px; }

/* ── Toast ── */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--gray-900);
    color: #fff;
    border-radius: var(--radius-lg);
    font-size: 12px;
    box-shadow: var(--shadow-lg);
    animation: slideUp .2s;
    min-width: 240px;
}

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

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

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 8px; }

/* ════════════════════════════════════════════════════════
   RESPONSIVE PATCH — question-detail.css
   (CSS class محور، نه selector شکننده با [style*="..."])
   ════════════════════════════════════════════════════════ */

@media (max-width: 960px) {
    .main-grid { grid-template-columns: 1fr 280px; gap: 14px; }
}

@media (max-width: 768px) {
    body { overflow-x: hidden; }

    .page-wrapper { padding: 14px 12px; }

    /* breadcrumb */
    .breadcrumb { font-size: 12px; flex-wrap: nowrap; overflow: hidden; }
    .breadcrumb .current {
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        max-width: 160px;
    }

    /* page header — از کلاس‌های واقعی، نه [style*="..."] */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 14px;
    }

    .page-header-title {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .question-main-title { font-size: 16px; }

    .page-header-actions {
        width: 100%;
        flex-wrap: wrap;
        gap: 6px;
        flex-shrink: unset;
    }

    .page-header-actions .btn {
        flex: 1;
        justify-content: center;
        min-width: 80px;
        font-size: 12px;
        padding: 5px 8px;
    }

    /* main grid → تک‌ستون */
    .main-grid { grid-template-columns: 1fr !important; gap: 0; }

    /* card */
    .card-header { padding: 10px 14px; flex-wrap: wrap; gap: 6px; }
    .card-body { padding: 14px; }

    /* question text */
    .question-text-block { font-size: 14px; padding: 14px 12px; }

    /* answer options */
    .answer-option { padding: 8px 10px; gap: 8px; }
    .option-text { font-size: 12px; }

    /* tabs → scroll افقی */
    .tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        scrollbar-width: none;
        gap: 0;
        -webkit-overflow-scrolling: touch;
    }

    .tabs::-webkit-scrollbar { display: none; }
    .tab { white-space: nowrap; font-size: 12px; padding: 8px 12px; }

    /* media grid → 2 ستون */
    .media-grid { grid-template-columns: repeat(2, 1fr); }

    /* meta-table */
    .meta-table td:first-child { width: 90px; font-size: 11px; }
    .meta-table td { font-size: 12px; padding: 6px 0; }

    /* lifecycle stepper */
    .lc-stepper { margin-bottom: 12px; }
    .lc-dot { width: 24px; height: 24px; font-size: 11px; }
    .lc-label { font-size: 9px; }
    .lc-step:not(:last-child)::after { top: 12px; }

    /* toggle-row */
    .toggle-row { flex-wrap: wrap; gap: 8px; align-items: flex-start; }

    /* AI confidence row */
    .ai-confidence-row { flex-direction: column; gap: 8px; }

    /* education path */
    .edu-path-row { flex-wrap: wrap; }

    /* modal → bottom sheet */
    .modal-overlay { align-items: flex-end; }
    .modal {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        max-height: 90vh;
    }

    .modal-header { padding: 12px 16px; }
    .modal-body { padding: 16px; }
    .modal-footer { padding: 10px 16px; flex-wrap: wrap; gap: 6px; }
    .modal-footer .btn { flex: 1; justify-content: center; }

    /* pre/JSON */
    .meta-pre { font-size: 11px !important; padding: 10px !important; }

    .section-title { margin: 12px 0 8px; }

    /* toast */
    .toast-container { left: 10px; right: 10px; bottom: 12px; }
    .toast { min-width: unset; width: 100%; }
}

@media (max-width: 480px) {
    .page-wrapper { padding: 10px; }

    .question-main-title { font-size: 15px; }

    /* دکمه‌های action: دو به دو */
    .page-header-actions .btn {
        min-width: calc(50% - 3px);
        max-width: calc(50% - 3px);
        font-size: 11px;
    }

    .question-text-block { font-size: 13px; padding: 10px; }
    .media-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
    .lc-label { display: none; }
    .card-title { font-size: 12px; }

    /* education path label کوچک‌تر */
    .edu-label { width: 60px; }
}
