/* ===== ResumeForge Pro — Public Builder Styles ===== */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=Playfair+Display:wght@700&display=swap');

.rb-builder-wrap * { box-sizing: border-box; }
.rb-builder-wrap {
    font-family: 'DM Sans', sans-serif;
    background: #f0f2f7;
    min-height: 90vh;
    position: relative;
}

/* ===== STEPS ===== */
.rb-step { display: none; }
.rb-step.rb-step-active { display: block; }

/* ===== STEP 1: GALLERY ===== */
.rb-step-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 32px;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    color: #fff;
}
.rb-step-title { display: flex; align-items: center; gap: 16px; }
.rb-step-num {
    width: 44px; height: 44px;
    background: #e94560; color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.2rem;
    flex-shrink: 0;
}
.rb-step-title h2 { margin: 0; font-size: 1.5rem; font-weight: 700; }
.rb-step-title p  { margin: 4px 0 0; color: rgba(255,255,255,0.65); font-size: 0.9rem; }

/* Buttons */
.rb-btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 22px;
    border: none; border-radius: 10px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem; font-weight: 600;
    cursor: pointer; text-decoration: none;
    transition: all 0.2s;
}
.rb-btn-primary { background: #e94560; color: #fff; }
.rb-btn-primary:hover:not(:disabled) { background: #c73450; transform: translateY(-1px); }
.rb-btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.rb-btn-lg { padding: 12px 28px; font-size: 1rem; }
.rb-btn-sm { padding: 6px 14px; font-size: 0.82rem; }
.rb-btn-outline { background: transparent; border: 1px solid #e94560; color: #e94560; }
.rb-btn-outline:hover { background: #e94560; color: #fff; }
.rb-btn-ghost { background: transparent; border: 1px solid #ddd; color: #555; }
.rb-btn-ghost:hover { background: #f5f5f5; }
.rb-btn-add {
    width: 100%; border: 2px dashed #d0d4e8;
    background: transparent; color: #7b82a8;
    border-radius: 10px; padding: 10px;
    font-size: 0.9rem;
}
.rb-btn-add:hover { border-color: #e94560; color: #e94560; background: rgba(233,69,96,0.04); }
.rb-back-link {
    background: none; border: none;
    color: #e94560; font-size: 0.9rem;
    cursor: pointer; font-weight: 600;
    padding: 0;
}
.rb-back-link:hover { text-decoration: underline; }

/* Category bar */
.rb-category-bar {
    display: flex; gap: 8px; flex-wrap: wrap;
    padding: 16px 32px;
    background: #fff;
    border-bottom: 1px solid #e8eaf0;
    position: sticky; top: 0; z-index: 10;
}
.rb-cat-btn {
    padding: 6px 18px;
    border: 1px solid #e0e2f0; border-radius: 20px;
    background: #fff; color: #666;
    font-size: 0.85rem; font-weight: 500;
    cursor: pointer; transition: all 0.2s;
    font-family: 'DM Sans', sans-serif;
    text-transform: capitalize;
}
.rb-cat-btn:hover { border-color: #e94560; color: #e94560; }
.rb-cat-btn.active { background: #e94560; border-color: #e94560; color: #fff; }

/* Templates Grid */
.rb-templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    padding: 28px 32px;
}
.rb-template-card {
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 3px 12px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: all 0.3s;
    border: 3px solid transparent;
    position: relative;
}
.rb-template-card:hover { transform: translateY(-5px); box-shadow: 0 12px 30px rgba(0,0,0,0.12); }
.rb-template-card.rb-selected { border-color: #e94560; }
.rb-template-card.rb-selected::after {
    content: '✓';
    position: absolute; top: 8px; right: 8px;
    width: 26px; height: 26px;
    background: #e94560; color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem; font-weight: 700;
}
.rb-tpl-thumb {
    height: 270px;
    overflow: hidden;
    position: relative;
    background: #f0f2f7;
}
/* Frame that clips the real rendered HTML */
.rb-tpl-thumb-frame {
    width: 100%;
    height: 270px;
    overflow: hidden;
    position: relative;
    pointer-events: none;
}
/* Scale the 794px-wide resume down to card width (~220px) */
.rb-tpl-thumb-scaler {
    width: 794px;
    transform-origin: top left;
    transform: scale(0.265);   /* 220/794 ≈ 0.277 — adjust if card width changes */
    pointer-events: none;
}
.rb-tpl-loading {
    display: flex; align-items: center; justify-content: center;
    height: 270px; color: #bbb;
}
.rb-spinner-sm {
    width: 22px; height: 22px;
    border: 3px solid #e0e2f0;
    border-top-color: #e94560;
    border-radius: 50%;
    animation: rb-spin 0.8s linear infinite;
}
.rb-tpl-info {
    padding: 12px 14px;
    border-top: 1px solid #f0f2f7;
}
.rb-tpl-info h3 { font-size: 0.9rem; font-weight: 700; color: #1a1a2e; margin: 0 0 4px; }
.rb-tpl-meta { display: flex; justify-content: space-between; align-items: center; }
.rb-tpl-cat { font-size: 0.75rem; color: #888; text-transform: capitalize; }
.rb-badge-premium {
    background: linear-gradient(135deg, #f5a623, #f0820f);
    color: #fff; font-size: 0.68rem; font-weight: 700;
    padding: 2px 8px; border-radius: 10px;
}
.rb-tpl-colors { display: flex; gap: 4px; margin-top: 6px; }
.rb-tpl-dot { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.1); }

/* ===== STEP 2: EDITOR ===== */
.rb-editor-wrap {
    display: grid;
    grid-template-columns: 380px 1fr;
    height: calc(100vh - 120px);
    min-height: 700px;
}

/* Form Panel */
.rb-form-panel {
    background: #fff;
    display: flex; flex-direction: column;
    border-right: 1px solid #e8eaf0;
    overflow: hidden;
}
.rb-form-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px;
    background: #1a1a2e;
    color: #fff;
    gap: 10px;
}
.rb-form-header h3 { margin: 0; font-size: 1rem; font-weight: 700; flex: 1; text-align: center; }

.rb-form-tabs {
    display: flex; overflow-x: auto;
    background: #f8f9ff;
    border-bottom: 1px solid #e8eaf0;
    padding: 0 10px;
}
.rb-ftab {
    padding: 10px 14px;
    border: none; background: transparent;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.82rem; font-weight: 500;
    color: #888; cursor: pointer;
    border-bottom: 3px solid transparent;
    white-space: nowrap; transition: all 0.2s;
}
.rb-ftab.active, .rb-ftab:hover { color: #e94560; }
.rb-ftab.active { border-bottom-color: #e94560; font-weight: 700; }

.rb-form-body {
    flex: 1; overflow-y: auto;
    padding: 18px;
}
.rb-ftab-panel { display: none; }
.rb-ftab-panel.active { display: block; }

/* Photo upload */
.rb-photo-section { margin-bottom: 16px; text-align: center; }
.rb-photo-upload {
    width: 140px; height: 140px;
    border: 3px dashed #d0d4e8; border-radius: 50%;
    cursor: pointer; margin: 0 auto;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; transition: border-color 0.2s;
    background: #f8f9ff;
    position: relative;
}
.rb-photo-upload:hover { border-color: #e94560; }
#rb-photo-placeholder { text-align: center; color: #aaa; font-size: 0.8rem; padding: 10px; }
#rb-photo-placeholder span { font-size: 2rem; display: block; margin-bottom: 5px; }
#rb-photo-preview { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

/* Form fields */
.rb-field-group { margin-bottom: 14px; }
.rb-field-group > label, .rb-field-group > span {
    display: block; font-size: 0.82rem;
    font-weight: 600; color: #555; margin-bottom: 5px;
}
.rb-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rb-input {
    width: 100%; padding: 9px 12px;
    border: 1px solid #dde1f0; border-radius: 8px;
    font-family: 'DM Sans', sans-serif; font-size: 0.87rem;
    color: #333; transition: all 0.2s;
}
.rb-input:focus { border-color: #e94560; outline: none; box-shadow: 0 0 0 3px rgba(233,69,96,0.1); }
.rb-textarea { resize: vertical; min-height: 80px; }

/* Repeater items */
.rb-repeater-item {
    background: #f8f9ff;
    border: 1px solid #e8eaf0;
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 10px;
    position: relative;
}
.rb-repeater-item .rb-delete-item {
    position: absolute; top: 10px; right: 10px;
    background: none; border: none; color: #ccc;
    font-size: 1.1rem; cursor: pointer; line-height: 1;
    transition: color 0.2s;
}
.rb-repeater-item .rb-delete-item:hover { color: #e94560; }
.rb-section-label {
    font-size: 0.8rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1px;
    color: #888; margin-bottom: 10px;
}

/* Skill row */
.rb-skill-row { display: grid; grid-template-columns: 1fr 80px; gap: 8px; align-items: end; }
.rb-skill-row input[type="range"] { width: 100%; margin: 0; }

/* Design tab */
.rb-design-hint { color: #888; font-size: 0.85rem; margin-bottom: 16px; }
.rb-color-swatches h4, .rb-custom-colors h4 {
    font-size: 0.82rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1px;
    color: #666; margin-bottom: 12px;
}
.rb-swatches-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.rb-preset-swatch {
    width: 38px; height: 38px; border-radius: 8px;
    cursor: pointer; border: 2px solid transparent;
    transition: all 0.2s; display: flex;
    align-items: center; justify-content: center;
}
.rb-preset-swatch:hover, .rb-preset-swatch.active { border-color: #1a1a2e; transform: scale(1.1); }
.rb-color-row {
    display: grid; grid-template-columns: 80px 44px 1fr;
    align-items: center; gap: 10px; margin-bottom: 12px;
}
.rb-color-row label { font-size: 0.85rem; font-weight: 600; color: #555; }
.rb-color-ctrl {
    width: 40px; height: 36px; padding: 2px;
    border: 1px solid #ddd; border-radius: 8px;
    cursor: pointer;
}
.rb-color-hex { font-size: 0.82rem; font-family: monospace; }

/* Preview Panel */
.rb-preview-panel {
    background: #e8eaf0;
    display: flex; flex-direction: column;
    overflow: hidden;
}
.rb-preview-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 20px;
    background: #fff; border-bottom: 1px solid #e8eaf0;
}
.rb-preview-zoom { display: flex; align-items: center; gap: 10px; }
.rb-zoom-btn {
    width: 30px; height: 30px; border-radius: 6px;
    border: 1px solid #ddd; background: #fff;
    font-size: 1.1rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.rb-zoom-btn:hover { background: #f5f5f5; border-color: #aaa; }
#rb-zoom-val { font-size: 0.85rem; font-weight: 600; color: #555; min-width: 40px; text-align: center; }

.rb-preview-viewport {
    flex: 1; overflow: auto;
    padding: 24px;
    display: flex; justify-content: center;
}
.rb-preview-scaler {
    transform-origin: top center;
    transition: transform 0.2s;
}
.rb-resume-preview-box {
    width: 850px;
    min-height: 1100px;
    background: #fff;
    box-shadow: 0 8px 40px rgba(0,0,0,0.15);
    position: relative;
}

/* Spinner / Loading */
.rb-loading, .rb-preview-loading {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 60px; color: #aaa; gap: 15px;
}
.rb-spinner {
    width: 36px; height: 36px;
    border: 4px solid #e8eaf0;
    border-top-color: #e94560;
    border-radius: 50%;
    animation: rb-spin 0.8s linear infinite;
}
@keyframes rb-spin { to { transform: rotate(360deg); } }

/* PDF download overlay */
.rb-pdf-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
}
.rb-pdf-modal {
    background: #fff; border-radius: 16px;
    padding: 40px; text-align: center;
    max-width: 360px; width: 90%;
}
.rb-pdf-modal h3 { font-size: 1.2rem; margin-bottom: 10px; }
.rb-pdf-modal .rb-spinner { margin: 20px auto; }

/* Toast */
.rb-toast {
    position: fixed; bottom: 24px; right: 24px;
    background: #1a1a2e; color: #fff;
    padding: 14px 22px; border-radius: 10px;
    font-size: 0.9rem; font-weight: 500;
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
    z-index: 99999;
    animation: rb-slide-in 0.3s ease;
}
.rb-toast.rb-toast-success { border-left: 4px solid #4caf50; }
.rb-toast.rb-toast-error   { border-left: 4px solid #e94560; }
@keyframes rb-slide-in {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

/* Responsive */
@media (max-width: 900px) {
    .rb-editor-wrap { grid-template-columns: 1fr; height: auto; }
    .rb-preview-panel { min-height: 600px; }
    .rb-templates-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); padding: 18px; }
    .rb-step-header { flex-direction: column; gap: 12px; text-align: center; padding: 18px; }
    .rb-category-bar { padding: 12px 18px; }
}

/* Photo drag-over */
.rb-photo-upload.rb-drag-over {
    border-color: #e94560 !important;
    background: rgba(233,69,96,0.06) !important;
}
/* 2-col grid for repeater rows */
.rb-field-row2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
/* Skill row */
.rb-skill-row { display:flex; align-items:center; gap:8px; margin-bottom:6px; }
.rb-skill-row .rb-skill-name { flex:1; }
.rb-slider { width:100%; margin:0; accent-color:#e94560; }
/* Hidden PDF render area */
#rb-pdf-render-area { position:fixed; top:-9999px; left:-9999px; width:794px; z-index:-999; background:#fff; }
/* Del button */
.rb-del-btn { position:absolute; top:10px; right:10px; background:none; border:none; color:#ccc; font-size:1rem; cursor:pointer; transition:color 0.2s; padding:0; line-height:1; }
.rb-del-btn:hover { color:#e94560; }
