/* ═══════════════════════════════════════════════════════════
   Blueprint Preview Modal — Styles
   Shows proposed structure for review before committing
   ═══════════════════════════════════════════════════════════ */

/* ── Overlay ────────────────────────────────────────────── */
.bp-preview-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.bp-preview-overlay.bp-preview-visible {
    opacity: 1;
}

.bp-preview-overlay.bp-preview-closing {
    opacity: 0;
}

/* ── Modal ──────────────────────────────────────────────── */
.bp-preview-modal {
    background: var(--bg-card, #1e293b);
    border: 1px solid var(--glass-border, rgba(255,255,255,0.1));
    border-radius: 16px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
    width: min(90vw, 860px);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(12px) scale(0.98);
    transition: transform 0.2s ease;
}

.bp-preview-visible .bp-preview-modal {
    transform: translateY(0) scale(1);
}

/* ── Header ─────────────────────────────────────────────── */
.bp-preview-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), transparent);
}

.bp-preview-header h2 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-main, #f8fafc);
}

.bp-preview-subtitle {
    margin: 0.25rem 0 0;
    font-size: 0.85rem;
    color: var(--text-muted, #94a3b8);
}

.bp-preview-close {
    background: none;
    border: none;
    color: var(--text-muted, #94a3b8);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.bp-preview-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main, #f8fafc);
}

/* ── Page Offset Banner ────────────────────────────────── */
.bp-page-offset-banner {
    padding: 0.75rem 1.5rem;
    background: rgba(245, 158, 11, 0.06);
    border-bottom: 1px solid rgba(245, 158, 11, 0.15);
}

.bp-offset-caution {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

.bp-offset-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.bp-offset-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.8rem;
    color: var(--text-muted, #94a3b8);
    line-height: 1.4;
}

.bp-offset-text strong {
    color: #fbbf24;
    font-size: 0.82rem;
}

.bp-offset-input-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.bp-offset-label {
    font-size: 0.78rem;
    color: var(--text-muted, #94a3b8);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    white-space: nowrap;
}

.bp-offset-hint {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    font-size: 0.65rem;
    color: var(--text-muted, #94a3b8);
    cursor: help;
    font-weight: 700;
}

.bp-offset-input {
    width: 64px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 6px;
    padding: 0.3rem 0.4rem;
    font-size: 0.82rem;
    color: var(--text-main, #f8fafc);
    font-family: inherit;
    text-align: center;
    transition: border-color 0.15s ease;
}

.bp-offset-input:focus {
    outline: none;
    border-color: #fbbf24;
    background: rgba(255, 255, 255, 0.1);
}

.bp-offset-example {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
    flex: 1;
    min-width: 120px;
}

.bp-offset-apply {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.35);
    border-radius: 6px;
    padding: 0.3rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    white-space: nowrap;
}

.bp-offset-apply:hover {
    background: rgba(245, 158, 11, 0.25);
    border-color: rgba(245, 158, 11, 0.5);
}

/* ── Body (scrollable tree) ─────────────────────────────── */
.bp-preview-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
    min-height: 200px;
}

.bp-preview-body::-webkit-scrollbar {
    width: 6px;
}

.bp-preview-body::-webkit-scrollbar-track {
    background: transparent;
}

.bp-preview-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
}

/* ── Item Rows ──────────────────────────────────────────── */
.bp-item-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.6rem;
    border-radius: 8px;
    transition: background 0.15s ease;
}

.bp-item-row:hover {
    background: rgba(255, 255, 255, 0.04);
}

.bp-item-chapter {
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid rgba(99, 102, 241, 0.12);
    margin-bottom: 0.25rem;
}

.bp-item-topic {
    background: rgba(34, 197, 94, 0.04);
    border: 1px solid rgba(34, 197, 94, 0.08);
    margin-bottom: 0.15rem;
}

.bp-item-video {
    border: 1px solid transparent;
    margin-bottom: 0.1rem;
}

.bp-item-icon {
    font-size: 0.95rem;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

/* ── Checkbox ───────────────────────────────────────────── */
.bp-include-check {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color, #6366f1);
    cursor: pointer;
    flex-shrink: 0;
}

/* ── Title input ────────────────────────────────────────── */
.bp-title-input {
    flex: 1;
    min-width: 0;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
    color: var(--text-main, #f8fafc);
    font-family: inherit;
    transition: border-color 0.15s ease;
}

.bp-title-input:focus {
    outline: none;
    border-color: var(--primary-color, #6366f1);
    background: rgba(255, 255, 255, 0.08);
}

.bp-chapter-title {
    font-weight: 600;
    font-size: 0.9rem;
}

/* ── Page range inputs ──────────────────────────────────── */
.bp-page-range {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.bp-page-range label {
    font-size: 0.75rem;
    color: var(--text-muted, #94a3b8);
    margin-right: 0.15rem;
}

.bp-page-range span {
    font-size: 0.75rem;
    color: var(--text-muted, #94a3b8);
}

.bp-page-input {
    width: 52px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 5px;
    padding: 0.3rem 0.35rem;
    font-size: 0.8rem;
    color: var(--text-main, #f8fafc);
    font-family: inherit;
    text-align: center;
    transition: border-color 0.15s ease;
}

.bp-page-input:focus {
    outline: none;
    border-color: var(--primary-color, #6366f1);
    background: rgba(255, 255, 255, 0.08);
}

/* Remove number spinner arrows */
.bp-page-input::-webkit-outer-spin-button,
.bp-page-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

.bp-page-input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* ── Nesting / Children ─────────────────────────────────── */
.bp-children {
    padding-left: 2rem;
    border-left: 2px solid rgba(255, 255, 255, 0.06);
    margin-left: 0.7rem;
    margin-top: 0.15rem;
    margin-bottom: 0.4rem;
}

.bp-chapter-block {
    margin-bottom: 0.75rem;
}

.bp-topic-block {
    margin-bottom: 0.25rem;
}

/* ── Validation Warning ─────────────────────────────────── */
.bp-preview-validation {
    padding: 0 1.5rem;
}

.bp-validation-warning {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: 10px;
    margin-bottom: 0.5rem;
}

.bp-validation-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.bp-validation-content {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text-main, #f8fafc);
    line-height: 1.5;
}

.bp-validation-content strong {
    color: #fbbf24;
}

.bp-validation-hint {
    margin: 0.3rem 0 0;
    font-size: 0.8rem;
    color: var(--text-muted, #94a3b8);
}

.bp-gap-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.35rem;
}

.bp-gap-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 5px;
    font-size: 0.75rem;
    color: #fbbf24;
    font-weight: 500;
}

.bp-gap-section {
    margin-bottom: 0.6rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.bp-gap-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.bp-validation-actions {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex-shrink: 0;
}

/* ── Footer ─────────────────────────────────────────────── */
.bp-preview-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.1);
}

/* ── Buttons ────────────────────────────────────────────── */
.bp-btn {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    font-family: inherit;
    white-space: nowrap;
}

.bp-btn-approve {
    background: var(--primary-color, #6366f1);
    color: white;
    border-color: var(--primary-color, #6366f1);
}

.bp-btn-approve:hover {
    background: var(--primary-hover, #4f46e5);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.bp-btn-skip {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-main, #f8fafc);
    border-color: rgba(255, 255, 255, 0.12);
}

.bp-btn-skip:hover {
    background: rgba(255, 255, 255, 0.1);
}

.bp-btn-cancel {
    background: transparent;
    color: var(--text-muted, #94a3b8);
    border-color: transparent;
}

.bp-btn-cancel:hover {
    color: var(--text-main, #f8fafc);
    background: rgba(255, 255, 255, 0.04);
}

.bp-btn-dismiss {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem;
}

.bp-btn-dismiss:hover {
    background: rgba(245, 158, 11, 0.25);
}

.bp-btn-back {
    background: transparent;
    color: var(--text-muted, #94a3b8);
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem;
}

.bp-btn-back:hover {
    color: var(--text-main, #f8fafc);
}


/* ── Add / Delete buttons ──────────────────────────────── */
.bp-add-row {
    padding: 0.4rem 0.6rem;
}

.bp-add-row-inline {
    padding: 0.25rem 0.6rem;
}

.bp-btn-add {
    background: rgba(99, 102, 241, 0.08);
    color: var(--primary-color, #6366f1);
    border: 1px dashed rgba(99, 102, 241, 0.3);
    border-radius: 6px;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}

.bp-btn-add:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.5);
}

.bp-btn-add-small {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
}

.bp-btn-delete {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0.2rem 0.3rem;
    border-radius: 4px;
    opacity: 0.3;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.bp-btn-delete:hover {
    opacity: 1;
    background: rgba(239, 68, 68, 0.12);
}

/* [PAGE-ALIGN] Peek PDF button inside blueprint rows */
.bp-peek-btn {
    opacity: 0.6;
    font-size: 0.85rem;
    padding: 2px 6px;
    margin-left: 2px;
    flex-shrink: 0;
}

.bp-peek-btn:hover {
    opacity: 1;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 640px) {
    .bp-preview-modal {
        width: 98vw;
        max-height: 95vh;
        border-radius: 12px;
    }

    .bp-item-row {
        flex-wrap: wrap;
    }

    .bp-page-range {
        width: 100%;
        padding-left: 2.5rem;
        margin-top: 0.25rem;
    }

    .bp-preview-footer {
        flex-wrap: wrap;
    }
}
