/* Guide layout */
.guide-page {
    background: var(--bg);
    min-height: 100vh;
}

.guide-hero {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    padding: 60px 0 50px;
    position: relative;
    overflow: hidden;
}

.guide-hero::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, var(--accent) 0%, transparent 60%);
    opacity: 0.15;
    border-radius: 50%;
    top: -150px;
    left: -100px;
}

.guide-hero-content {
    position: relative;
    z-index: 1;
    max-width: 720px;
}

.guide-hero h1 {
    font-size: 36px;
    margin: 0 0 14px;
    font-weight: 800;
}

.guide-hero p {
    font-size: 17px;
    opacity: 0.9;
    margin: 0;
}

.guide-breadcrumb {
    font-size: 13px;
    opacity: 0.8;
    margin-bottom: 14px;
}

.guide-breadcrumb a {
    color: rgba(255, 255, 255, 0.85);
}

.guide-breadcrumb a:hover {
    color: #fff;
}

.guide-toc-toggle {
    display: none;
    background: var(--primary);
    color: #fff;
    border: 0;
    padding: 12px 18px;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    margin: 18px 0;
    width: 100%;
}

.guide-wrap {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 48px;
    padding: 48px 0 80px;
    align-items: start;
}

/* TOC sidebar */
.guide-toc {
    position: sticky;
    top: 90px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    max-height: calc(100vh - 110px);
    overflow-y: auto;
}

.guide-toc h3 {
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0 0 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.guide-toc ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.guide-toc li { margin-bottom: 4px; }

.guide-toc a {
    display: block;
    padding: 8px 12px;
    color: var(--text-muted);
    border-radius: 6px;
    font-size: 13.5px;
    line-height: 1.5;
    border-right: 3px solid transparent;
    transition: all .15s;
}

.guide-toc a:hover {
    background: var(--surface-2);
    color: var(--primary);
}

.guide-toc a.active {
    background: rgba(214, 38, 42, 0.06);
    color: var(--primary);
    font-weight: 600;
    border-right-color: var(--primary);
}

/* Main content */
.guide-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 50px 56px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.guide-section {
    margin-bottom: 60px;
    scroll-margin-top: 90px;
}

.guide-section:last-child { margin-bottom: 0; }

.guide-section h2 {
    font-size: 28px;
    color: var(--text);
    margin: 0 0 18px;
    padding-bottom: 14px;
    border-bottom: 2px solid var(--primary);
    font-weight: 800;
}

.guide-section h3 {
    font-size: 20px;
    color: var(--text);
    margin: 32px 0 12px;
    font-weight: 700;
}

.guide-section h4 {
    font-size: 16px;
    color: var(--text);
    margin: 24px 0 8px;
    font-weight: 700;
}

.guide-section p {
    color: var(--text);
    line-height: 1.95;
    margin: 12px 0;
    font-size: 15px;
}

.guide-section ul,
.guide-section ol {
    padding-right: 24px;
    line-height: 2;
    color: var(--text);
    font-size: 15px;
}

.guide-section li { margin: 4px 0; }

.guide-section a {
    color: var(--primary);
    border-bottom: 1px dashed var(--primary-light);
}

.guide-section a:hover {
    color: var(--accent-dark);
    border-bottom-color: var(--accent);
}

.guide-section strong {
    color: var(--text);
    font-weight: 700;
}

/* Code */
.guide-section code {
    background: var(--surface-2);
    color: var(--primary-dark);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: ui-monospace, 'SF Mono', Menlo, Monaco, Consolas, monospace;
    font-size: 13px;
    direction: ltr;
    display: inline-block;
}

.guide-section pre {
    background: #0f172a;
    color: #e2e8f0;
    padding: 18px 22px;
    border-radius: 8px;
    overflow-x: auto;
    direction: ltr;
    text-align: left;
    font-family: ui-monospace, 'SF Mono', Menlo, Monaco, Consolas, monospace;
    font-size: 13px;
    line-height: 1.7;
    margin: 16px 0;
}

.guide-section pre code {
    background: transparent;
    color: inherit;
    padding: 0;
    font-size: inherit;
}

/* Callouts */
.callout {
    display: flex;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 8px;
    margin: 18px 0;
    font-size: 14px;
    line-height: 1.85;
    border-right: 4px solid;
}

.callout .icon {
    flex-shrink: 0;
    font-size: 18px;
    line-height: 1;
    margin-top: 2px;
}

.callout-info {
    background: #fef6e7;
    color: #92400e;
    border-color: var(--accent);
}

.callout-success {
    background: #ecfdf5;
    color: #065f46;
    border-color: var(--success);
}

.callout-warning {
    background: #fffbeb;
    color: #92400e;
    border-color: var(--warning);
}

.callout-danger {
    background: #fef2f2;
    color: #991b1b;
    border-color: var(--danger);
}

.callout strong { color: inherit; }

/* Steps */
.steps {
    counter-reset: step;
    list-style: none;
    padding: 0;
    margin: 18px 0;
}

.steps > li {
    counter-increment: step;
    position: relative;
    padding-right: 56px;
    margin-bottom: 22px;
    min-height: 40px;
}

.steps > li::before {
    content: counter(step);
    position: absolute;
    right: 0;
    top: 0;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 14px;
    box-shadow: 0 4px 10px rgba(214, 38, 42, 0.25);
}

.steps > li > strong {
    display: block;
    margin-bottom: 6px;
    font-size: 16px;
}

/* Table */
.guide-section table {
    width: 100%;
    border-collapse: collapse;
    margin: 18px 0;
    background: var(--surface);
    font-size: 13.5px;
}

.guide-section th,
.guide-section td {
    padding: 12px 14px;
    text-align: right;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.guide-section th {
    background: var(--surface-2);
    font-weight: 700;
    color: var(--text);
}

.guide-section tr:last-child td { border-bottom: 0; }

/* Settings field example */
.settings-field {
    background: var(--surface-2);
    border-radius: 8px;
    padding: 16px 18px;
    margin: 12px 0;
    border-right: 3px solid var(--accent);
}

.settings-field .name {
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
    font-size: 14px;
}

.settings-field .desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.7;
    margin: 0;
}

.settings-field .default {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-light);
}

.settings-field .default code {
    background: #fff;
    padding: 2px 6px;
    font-size: 11px;
}

/* Back to top */
.back-to-top {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 44px;
    height: 44px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: grid;
    place-items: center;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transition: all .2s;
    z-index: 50;
    border: 0;
    font-size: 18px;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-3px);
    background: var(--primary-dark);
}

/* Responsive */
@media (max-width: 960px) {
    .guide-wrap {
        grid-template-columns: 1fr;
        gap: 0;
        padding: 24px 0 60px;
    }
    .guide-toc {
        position: fixed;
        top: 64px;
        right: 0;
        left: 0;
        max-height: 0;
        overflow: hidden;
        padding: 0 20px;
        border-radius: 0;
        transition: max-height .25s, padding .25s;
        z-index: 90;
    }
    .guide-toc.open {
        max-height: 70vh;
        padding: 20px;
        overflow-y: auto;
    }
    .guide-toc-toggle { display: block; }
    .guide-content { padding: 32px 24px; }
    .guide-hero h1 { font-size: 26px; }
    .guide-section h2 { font-size: 22px; }
}

/* ─────────────── استایل چاپ / خروجی PDF ─────────────── */
@media print {
    @page {
        size: A4;
        margin: 16mm 14mm;
    }

    body.guide-page { background: #fff !important; }

    /* عناصر تعاملی/ناوبری در PDF لازم نیستند */
    .site-header,
    .guide-toc,
    .guide-toc-toggle,
    .back-to-top,
    .site-footer,
    .mobile-toggle,
    .guide-breadcrumb { display: none !important; }

    /* تک‌ستونه و تمام‌عرض */
    .guide-wrap { display: block !important; }
    .guide-content {
        padding: 0 !important;
        box-shadow: none !important;
        border: 0 !important;
        background: #fff !important;
        max-width: 100% !important;
    }

    .guide-hero {
        background: #fff !important;
        color: #111 !important;
        padding: 0 0 12px !important;
        border-bottom: 2px solid #d6262a;
        margin-bottom: 16px;
    }
    .guide-hero::after,
    .guide-hero::before { display: none !important; }
    .guide-hero h1 { color: #111 !important; }
    .guide-hero p { color: #444 !important; }

    /* جلوگیری از شکستن نامناسب */
    .guide-section { page-break-inside: auto; }
    .guide-section h2 {
        page-break-after: avoid;
        break-after: avoid;
        page-break-before: auto;
    }
    .guide-section h3,
    .guide-section h4 {
        page-break-after: avoid;
        break-after: avoid;
    }
    table, pre, .callout, figure, img {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    a { color: #111 !important; text-decoration: none !important; }
    pre, code { white-space: pre-wrap !important; word-wrap: break-word; }
}
