/* ========================================================================
   Resume Builder — page styling on top of tokens.css + resources.css.

   The editor form is OWNED here, scoped to `.rb-editor`, so it beats the
   footer.css `.form-group { display:flex }` global leak (same trap fixed on
   post-job). The live preview sheet (`.resume-sheet`) renders in two
   templates (modern / classic) themed by a single `--rb-accent` custom
   property set from JS. Print rules hide all chrome and emit only the sheet.
   ======================================================================== */

.rb-main {
    padding: 2rem 0 4rem;
}

/* ---------- Mobile Edit / Preview switch (desktop hides it) ---------- */
.rb-mobile-tabs {
    display: none;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-full);
    padding: 4px;
    margin: 0 auto 1.25rem;
    max-width: 320px;
    box-shadow: var(--shadow-sm);
}

.rb-mobile-tab {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.6rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    color: var(--gray-500);
    background: transparent;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: var(--transition);
}

.rb-mobile-tab.is-active { background: var(--primary-color); color: var(--white); }

/* ---------- Workspace ---------- */
.rb-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    gap: 1.75rem;
    align-items: start;
}

/* ---------- Editor ---------- */
.rb-editor {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-xl);
    box-shadow: 0 1px 2px hsl(220 25% 10% / 0.04), 0 10px 28px hsl(220 25% 10% / 0.07);
    padding: 1.5rem;
}

.rb-editor-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding-bottom: 1.25rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--gray-200);
}

.rb-editor-title {
    font-family: var(--font-secondary);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0 0 0.25rem;
}

.rb-editor-note {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8125rem;
    color: var(--gray-500);
    margin: 0;
}

.rb-editor-note i { color: var(--success-green); }

.rb-editor-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.rb-danger:hover { color: var(--danger-red); border-color: var(--danger-red); }

/* ---------- Sections ---------- */
.rb-section { padding: 1.25rem 0; border-bottom: 1px solid var(--gray-100); }
.rb-section:last-child { border-bottom: none; padding-bottom: 0; }
.rb-section:first-of-type { padding-top: 0; }

.rb-section-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0 0 1rem;
}

.rb-section-title .optional { font-size: 0.75rem; }

.rb-step-num {
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--primary-tint);
    color: var(--primary-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8125rem;
    font-weight: 700;
}

/* ---------- Form (scoped — neutralises footer.css .form-group flex leak) ---------- */
.rb-editor .form-group { display: block; margin: 0 0 1rem; padding: 0; border: 0; background: none; }
.rb-editor .form-group:last-child { margin-bottom: 0; }

.rb-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1rem;
}

.rb-grid-2 .form-group { margin-bottom: 1rem; }

.rb-editor label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--gray-700);
    margin: 0 0 0.4rem;
}

.rb-editor .required { color: var(--danger-red); }
.rb-editor .optional { color: var(--gray-400); font-weight: 400; font-size: 0.8em; }

.rb-editor input[type="text"],
.rb-editor input[type="tel"],
.rb-editor input[type="email"],
.rb-editor input[type="number"],
.rb-editor select,
.rb-editor textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 0.7rem 0.85rem;
    font-size: 0.9375rem;
    font-family: inherit;
    color: var(--gray-900);
    background: var(--white);
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-md);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

.rb-editor textarea { min-height: 5rem; resize: vertical; line-height: 1.55; }

.rb-editor input::placeholder,
.rb-editor textarea::placeholder { color: var(--gray-400); }

.rb-editor input:hover,
.rb-editor select:hover,
.rb-editor textarea:hover { border-color: var(--gray-300); }

.rb-editor input:focus,
.rb-editor select:focus,
.rb-editor textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-tint);
}

.rb-editor .field-hint {
    display: block;
    margin-top: 0.35rem;
    color: var(--gray-500);
    font-size: 0.75rem;
    line-height: 1.45;
}

/* Select wrapper chevron (for level selects rendered inside repeat items) */
.rb-select-wrap { position: relative; }
.rb-select-wrap select { padding-right: 2.25rem; cursor: pointer; }
.rb-select-wrap > i {
    position: absolute;
    right: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--gray-400);
    font-size: 0.7rem;
}

/* ---------- Repeatable items ---------- */
.rb-repeat-list { display: flex; flex-direction: column; gap: 0.85rem; margin-bottom: 0.85rem; }

.rb-repeat-item {
    position: relative;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 1rem 1rem 0.85rem;
}

.rb-repeat-item .rb-item-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.65rem;
}

.rb-item-label { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--gray-400); }

.rb-item-remove {
    border: none;
    background: none;
    color: var(--gray-400);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.25rem 0.4rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.rb-item-remove:hover { color: var(--danger-red); background: var(--gray-100); }

.rb-check-row {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--gray-700);
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    margin-top: 0.25rem;
}

.rb-check-row input { width: 1.05rem; height: 1.05rem; accent-color: var(--primary-color); margin: 0; }

.rb-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    color: var(--primary-color);
    background: var(--primary-tint);
    border: 1px dashed rgba(26, 137, 23, 0.4);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
    justify-content: center;
}

.rb-add-btn:hover { background: rgba(26, 137, 23, 0.16); border-style: solid; }

.rb-empty-hint { font-size: 0.8125rem; color: var(--gray-400); font-style: italic; margin: 0 0 0.85rem; }

/* ---------- Skill chips ---------- */
.rb-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.rb-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.4rem 0.35rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--gray-700);
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-full);
}

.rb-chip button {
    border: none;
    background: none;
    color: var(--gray-400);
    cursor: pointer;
    font-size: 0.75rem;
    line-height: 1;
    padding: 0.2rem 0.3rem;
    border-radius: 50%;
}

.rb-chip button:hover { color: var(--danger-red); background: var(--gray-200); }

/* ========================================================================
   Preview pane
   ======================================================================== */
.rb-preview-pane { position: sticky; top: 1.25rem; }

.rb-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}

.rb-toolbar-group { display: flex; align-items: center; gap: 0.6rem; }
.rb-toolbar-label { font-size: 0.75rem; font-weight: 600; color: var(--gray-500); }

.rb-template-toggle {
    display: flex;
    background: var(--gray-100);
    border-radius: var(--radius-full);
    padding: 3px;
}

.rb-template-btn {
    padding: 0.35rem 0.8rem;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: inherit;
    color: var(--gray-500);
    background: transparent;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: var(--transition);
}

.rb-template-btn.is-active { background: var(--white); color: var(--gray-900); box-shadow: var(--shadow-sm); }

.rb-accents { display: flex; gap: 0.4rem; }

.rb-accent-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--white);
    box-shadow: 0 0 0 1px var(--gray-300);
    cursor: pointer;
    padding: 0;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.rb-accent-swatch:hover { transform: scale(1.1); }
.rb-accent-swatch.is-active { box-shadow: 0 0 0 2px var(--gray-900); }

.rb-toolbar-actions { display: flex; align-items: center; gap: 0.75rem; margin-left: auto; }

.rb-save-state {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-400);
    transition: color 0.3s ease;
    white-space: nowrap;
}

.rb-save-state.is-saved { color: var(--success-green); }
.rb-save-state.is-saving { color: var(--warning-orange); }

/* ---------- The sheet ---------- */
.resume-sheet-wrap {
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    max-height: calc(100vh - 9rem);
    overflow-y: auto;
}

.resume-sheet {
    --rb-accent: var(--primary-color);
    --rb-accent-soft: rgba(26, 137, 23, 0.08);
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    background: #fff;
    color: #1f2430;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 12px 32px rgba(0, 0, 0, 0.10);
    border-radius: 4px;
    overflow: hidden;
    font-size: 13px;
    line-height: 1.5;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

/* Shared resume typography */
.resume-sheet h2.rs-name {
    font-family: var(--font-secondary);
    font-size: 1.9rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 0;
    color: #1a1f2b;
    line-height: 1.15;
}

.resume-sheet .rs-role { font-size: 0.95rem; font-weight: 600; color: var(--rb-accent); margin: 0.15rem 0 0; }

.resume-sheet .rs-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--rb-accent);
    margin: 0 0 0.6rem;
}

.resume-sheet .rs-entry { margin-bottom: 0.85rem; }
.resume-sheet .rs-entry:last-child { margin-bottom: 0; }

.resume-sheet .rs-entry-top {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: baseline;
}

.resume-sheet .rs-entry-title { font-weight: 700; color: #1a1f2b; font-size: 0.9rem; }
.resume-sheet .rs-entry-org { font-weight: 600; color: #3a4150; font-size: 0.85rem; }
.resume-sheet .rs-entry-meta { font-size: 0.75rem; color: #8a93a3; white-space: nowrap; }
.resume-sheet .rs-entry-desc { margin: 0.3rem 0 0; color: #444b59; white-space: pre-wrap; font-size: 0.82rem; }
.resume-sheet .rs-placeholder { color: #b9c0cc; font-style: italic; }

.resume-sheet .rs-pill-list { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.resume-sheet .rs-pill {
    font-size: 0.75rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: var(--rb-accent-soft);
    color: #2b3340;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

/* ----- Modern template ----- */
.tpl-modern .rs-modern { display: grid; grid-template-columns: 34% 1fr; min-height: 100%; }

.tpl-modern .rs-sidebar {
    background: var(--rb-accent);
    color: rgba(255, 255, 255, 0.95);
    padding: 1.6rem 1.25rem;
}

.tpl-modern .rs-sidebar .rs-section-title { color: rgba(255, 255, 255, 0.92); border-bottom: 1px solid rgba(255, 255, 255, 0.28); padding-bottom: 0.3rem; }
.tpl-modern .rs-side-section { margin-bottom: 1.4rem; }
.tpl-modern .rs-side-section:last-child { margin-bottom: 0; }
.tpl-modern .rs-contact-item { display: flex; gap: 0.5rem; align-items: flex-start; font-size: 0.78rem; margin-bottom: 0.5rem; word-break: break-word; }
.tpl-modern .rs-contact-item i { width: 14px; text-align: center; margin-top: 0.12rem; opacity: 0.9; }
.tpl-modern .rs-sidebar .rs-pill { background: rgba(255, 255, 255, 0.16); color: #fff; border-color: rgba(255, 255, 255, 0.3); }
.tpl-modern .rs-side-line { font-size: 0.8rem; margin-bottom: 0.4rem; display: flex; justify-content: space-between; gap: 0.5rem; }
.tpl-modern .rs-side-line span:last-child { opacity: 0.82; }

.tpl-modern .rs-main { padding: 1.6rem 1.5rem; }
.tpl-modern .rs-header { margin-bottom: 1.1rem; }
.tpl-modern .rs-block { margin-bottom: 1.25rem; }
.tpl-modern .rs-block:last-child { margin-bottom: 0; }

/* ----- Classic template ----- */
.tpl-classic .rs-classic { padding: 1.9rem 2rem; }
.tpl-classic .rs-header { text-align: center; padding-bottom: 0.9rem; margin-bottom: 1.1rem; border-bottom: 2px solid var(--rb-accent); }
.tpl-classic .rs-name { font-size: 2.1rem; }
.tpl-classic .rs-contact-line { margin-top: 0.55rem; font-size: 0.78rem; color: #525a68; display: flex; flex-wrap: wrap; justify-content: center; gap: 0.3rem 0.9rem; }
.tpl-classic .rs-contact-line span { display: inline-flex; align-items: center; gap: 0.3rem; }
.tpl-classic .rs-block { margin-bottom: 1.15rem; }
.tpl-classic .rs-block:last-child { margin-bottom: 0; }
.tpl-classic .rs-section-title { border-bottom: 1px solid #e3e7ee; padding-bottom: 0.3rem; }

/* ========================================================================
   Print — emit only the sheet, at full page.
   ======================================================================== */
@media print {
    @page { size: A4; margin: 13mm; }

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

    #preloader,
    .header,
    .resource-breadcrumb,
    .resource-hero,
    .rb-mobile-tabs,
    .rb-editor,
    .rb-toolbar,
    .rb-print-hint,
    .more-resources,
    .modern-footer { display: none !important; }

    .rb-main { padding: 0 !important; }
    .resource-shell, .resource-shell--wide { max-width: none !important; padding: 0 !important; }
    .rb-workspace { display: block !important; gap: 0 !important; }
    /* Force the sheet visible even if the mobile Edit/Preview switch hid it. */
    .rb-preview-pane { display: block !important; position: static !important; }
    .resume-sheet-wrap {
        background: none !important;
        border: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
        max-height: none !important;
        overflow: visible !important;
    }
    .resume-sheet {
        max-width: none !important;
        width: 100% !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        font-size: 12px;
    }
    .tpl-modern .rs-sidebar { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ========================================================================
   Responsive
   ======================================================================== */
@media (max-width: 960px) {
    .rb-mobile-tabs { display: flex; }
    .rb-workspace { grid-template-columns: 1fr; }
    .rb-preview-pane { position: static; }
    .resume-sheet-wrap { max-height: none; }

    /* On mobile we show one pane at a time via the Edit/Preview tabs. */
    .rb-workspace.show-editor .rb-preview-pane { display: none; }
    .rb-workspace.show-preview .rb-editor { display: none; }
}

@media (max-width: 560px) {
    .rb-grid-2 { grid-template-columns: 1fr; }
    .rb-toolbar { gap: 0.6rem 0.85rem; }
    .rb-toolbar-actions { margin-left: 0; width: 100%; justify-content: space-between; }
    .resume-sheet-wrap { padding: 0.75rem; }
    .tpl-modern .rs-modern { grid-template-columns: 1fr; }
    .resume-sheet { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
    .rb-mobile-tab, .rb-template-btn, .rb-accent-swatch, .rb-add-btn, .rb-item-remove { transition: none; }
}
