/* ============================================
   Resume Builder — Design System
   Dark theme matching NetaJobs
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* =====================
   Variables
   ===================== */
:root {
    --bg-primary: #0b1120;
    --bg-secondary: #101a2e;
    --bg-card: rgba(16, 26, 46, 0.85);
    --bg-glass: rgba(255, 255, 255, 0.05);
    --bg-glass-hover: rgba(255, 255, 255, 0.08);
    --bg-input: rgba(255, 255, 255, 0.06);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #e87722;
    --accent-hover: #f59035;
    --accent-glow: rgba(232, 119, 34, 0.3);
    --accent-gradient: linear-gradient(135deg, #e87722 0%, #f5a623 100%);
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --topbar-height: 56px;
    --editor-width: 480px;
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
}

/* =====================
   Reset
   ===================== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
    min-height: 100vh;
    overflow: hidden;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-hover);
}

/* =====================
   Top Bar
   ===================== */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: rgba(11, 17, 32, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
}

.topbar-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-primary);
    text-decoration: none;
}

.topbar-logo-img {
    height: 30px;
    width: auto;
}

.logo-accent {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.topbar-divider {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 0.5rem;
}

.topbar-title {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-tool {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-tool:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.1rem;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-lg);
    color: white;
    font-family: var(--font-family);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: 0 4px 15px rgba(232, 119, 34, 0.3);
}

.btn-download:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(232, 119, 34, 0.4);
}

/* =====================
   Main Layout
   ===================== */
.builder-layout {
    display: flex;
    height: calc(100vh - var(--topbar-height));
    margin-top: var(--topbar-height);
}

/* =====================
   Editor Panel (Left)
   ===================== */
.editor-panel {
    width: var(--editor-width);
    min-width: var(--editor-width);
    height: 100%;
    overflow-y: auto;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.editor-panel::-webkit-scrollbar {
    width: 6px;
}

.editor-panel::-webkit-scrollbar-track {
    background: transparent;
}

.editor-panel::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.editor-panel::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

/* Customization Bar */
.customize-bar {
    display: flex;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.customize-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
    min-width: 100px;
}

.customize-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.customize-select {
    padding: 0.35rem 0.5rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.8rem;
    cursor: pointer;
    outline: none;
    transition: border var(--transition-fast);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%2394a3b8' d='M5 7L1 3h8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
    padding-right: 22px;
}

.customize-select option {
    background: var(--bg-secondary);
}

.customize-select:focus {
    border-color: var(--accent);
}

.customize-color {
    width: 100%;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: transparent;
    padding: 2px;
}

.customize-color::-webkit-color-swatch-wrapper {
    padding: 0;
}

.customize-color::-webkit-color-swatch {
    border: none;
    border-radius: 3px;
}

/* Editor Sections */
.editor-sections {
    flex: 1;
    padding: 0.5rem 0;
}

.editor-section {
    border-bottom: 1px solid var(--border);
}

.section-toggle {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.85rem 1.25rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-fast);
    text-align: left;
}

.section-toggle:hover {
    background: var(--bg-glass);
}

.section-icon {
    font-size: 1rem;
}

.toggle-arrow {
    margin-left: auto;
    transition: transform var(--transition-base);
    color: var(--text-muted);
}

.editor-section.open .toggle-arrow {
    transform: rotate(180deg);
}

.section-body {
    display: none;
    padding: 0 1.25rem 1rem;
    animation: fadeDown 0.2s ease;
}

.editor-section.open .section-body {
    display: block;
}

@keyframes fadeDown {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Form Fields */
.field {
    margin-bottom: 0.75rem;
}

.field label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

.field input,
.field textarea {
    width: 100%;
    padding: 0.5rem 0.7rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.85rem;
    outline: none;
    transition: border var(--transition-fast), box-shadow var(--transition-fast);
}

.field input:focus,
.field textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.field input::placeholder,
.field textarea::placeholder {
    color: var(--text-muted);
}

.field textarea {
    resize: vertical;
    min-height: 70px;
    line-height: 1.5;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

/* Repeater (Experience, Education, etc.) */
.repeater-item {
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin-bottom: 0.75rem;
    position: relative;
    transition: border var(--transition-fast);
}

.repeater-item:hover {
    border-color: var(--border-hover);
}

.repeater-remove {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 26px;
    height: 26px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    line-height: 1;
    transition: all var(--transition-fast);
}

.repeater-remove:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--danger);
    color: var(--danger);
}

.btn-add {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    color: var(--accent);
    font-family: var(--font-family);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    width: 100%;
    justify-content: center;
}

.btn-add:hover {
    background: var(--bg-glass);
    border-color: var(--accent);
}

/* =====================
   Preview Panel (Right)
   ===================== */
.preview-panel {
    flex: 1;
    overflow-y: auto;
    background: #121d32;
    display: flex;
    justify-content: center;
    padding: 2rem;
}

.preview-panel::-webkit-scrollbar {
    width: 8px;
}

.preview-panel::-webkit-scrollbar-track {
    background: transparent;
}

.preview-panel::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.preview-container {
    width: 100%;
    max-width: 794px;
    /* A4 width in px at 96dpi */
}

/* =====================
   Resume Page (the actual resume)
   ===================== */
.resume-page {
    width: 100%;
    min-height: 1123px;
    /* A4 height approx */
    background: #ffffff;
    color: #1a1a2e;
    border-radius: 4px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    padding: 2.5rem;
    font-size: 10pt;
    line-height: 1.5;
    position: relative;
}

/* Resume Internal Styles */
.resume-page .r-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
}

.resume-page .r-name {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 0.2rem;
}

.resume-page .r-jobtitle {
    font-size: 1rem;
    font-weight: 500;
    opacity: 0.7;
    margin-bottom: 0.5rem;
}

.resume-page .r-contact {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.8rem;
    opacity: 0.6;
}

.resume-page .r-contact span {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.resume-page .r-section {
    margin-bottom: 1.25rem;
}

.resume-page .r-section-title {
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.6rem;
    padding-bottom: 0.3rem;
    border-bottom: 2px solid currentColor;
}

.resume-page .r-summary {
    font-size: 0.85rem;
    line-height: 1.6;
    opacity: 0.8;
}

.resume-page .r-item {
    margin-bottom: 0.85rem;
}

.resume-page .r-item-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.resume-page .r-item-title {
    font-size: 0.9rem;
    font-weight: 700;
}

.resume-page .r-item-subtitle {
    font-size: 0.82rem;
    font-weight: 500;
    opacity: 0.7;
}

.resume-page .r-item-date {
    font-size: 0.78rem;
    opacity: 0.55;
    font-weight: 500;
}

.resume-page .r-item-desc {
    font-size: 0.82rem;
    line-height: 1.55;
    opacity: 0.75;
    margin-top: 0.25rem;
    white-space: pre-line;
}

.resume-page .r-skills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.resume-page .r-skill-tag {
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 500;
}

.resume-page .r-languages {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.82rem;
}

/* Template: Modern */
.resume-page.template-modern .r-header {
    border-bottom: 3px solid var(--resume-accent, #e87722);
}

.resume-page.template-modern .r-name {
    color: var(--resume-accent, #e87722);
}

.resume-page.template-modern .r-section-title {
    color: var(--resume-accent, #e87722);
    border-color: var(--resume-accent, #e87722);
}

.resume-page.template-modern .r-skill-tag {
    /* Fallback for html2canvas compatibility (no color-mix support) */
    background: rgba(232, 119, 34, 0.12);
    color: var(--resume-accent, #e87722);
}

/* Template: Classic */
.resume-page.template-classic {
    font-family: 'Georgia', serif;
}

.resume-page.template-classic .r-header {
    text-align: center;
    border-bottom: 1px solid #ddd;
}

.resume-page.template-classic .r-name {
    font-size: 2rem;
    color: #1a1a2e;
}

.resume-page.template-classic .r-contact {
    justify-content: center;
}

.resume-page.template-classic .r-section-title {
    text-align: center;
    border-bottom: 1px solid #999;
    color: #333;
}

.resume-page.template-classic .r-skill-tag {
    background: #f0f0f0;
    color: #333;
}

/* Template: Minimal */
.resume-page.template-minimal .r-header {
    border-bottom: none;
    padding-bottom: 0.5rem;
}

.resume-page.template-minimal .r-name {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1a1a2e;
}

.resume-page.template-minimal .r-section-title {
    border-bottom: 1px solid #e2e8f0;
    color: #475569;
    font-size: 0.85rem;
    letter-spacing: 0.12em;
}

.resume-page.template-minimal .r-skill-tag {
    background: transparent;
    border: 1px solid #cbd5e1;
    color: #475569;
}

/* =====================
   Mobile Preview Toggle
   ===================== */
.mobile-preview-toggle {
    display: none;
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--accent-gradient);
    border: none;
    border-radius: 50px;
    color: white;
    font-family: var(--font-family);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    z-index: 200;
    box-shadow: 0 4px 20px rgba(232, 119, 34, 0.4);
    align-items: center;
    gap: 0.5rem;
    transition: transform var(--transition-fast);
}

.mobile-preview-toggle:hover {
    transform: scale(1.05);
}

/* =====================
   Responsive
   ===================== */
@media (max-width: 900px) {
    .editor-panel {
        width: 100%;
        min-width: 100%;
    }

    .preview-panel {
        position: fixed;
        inset: 0;
        top: var(--topbar-height);
        z-index: 150;
        display: none;
        padding: 1rem;
    }

    .preview-panel.mobile-visible {
        display: flex;
    }

    .mobile-preview-toggle {
        display: flex;
    }

    .btn-tool-text {
        display: none;
    }

    .customize-bar {
        gap: 0.5rem;
    }

    .customize-group {
        min-width: 80px;
    }

    .field-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .topbar {
        padding: 0 0.75rem;
    }

    .topbar-divider {
        display: none;
    }

    .topbar-title {
        display: none;
    }

    .customize-bar {
        flex-direction: column;
        gap: 0.5rem;
    }

    .customize-group {
        min-width: auto;
    }

    .resume-page {
        padding: 1.5rem;
    }
}

/* =====================
   Print / PDF
   ===================== */
@media print {
    body {
        background: white;
        overflow: visible;
    }

    .topbar,
    .editor-panel,
    .mobile-preview-toggle {
        display: none !important;
    }

    .builder-layout {
        display: block;
        height: auto;
        margin: 0;
    }

    .preview-panel {
        display: block !important;
        overflow: visible;
        background: white;
        padding: 0;
    }

    .resume-page {
        box-shadow: none;
        border-radius: 0;
        min-height: auto;
    }
}

/* =====================
   Placeholder State
   ===================== */
.resume-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    text-align: center;
    opacity: 0.4;
}

.resume-placeholder svg {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.resume-placeholder h3 {
    font-size: 1.1rem;
    margin-bottom: 0.3rem;
    color: #999;
}

.resume-placeholder p {
    font-size: 0.85rem;
    color: #aaa;
}