/* ============================================
   CV MAKER - STYLES
   Modern, Premium, Fully Responsive
============================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Variables ── */
:root {
    --primary: #1e293b;
    --primary-light: #334155;
    --primary-dark: #0f172a;
    --accent: #10b981;
    --accent-hover: #059669;
    --accent-light: #d1fae5;
    --text: #1e293b;
    --text-light: #64748b;
    --text-muted: #94a3b8;
    --bg: #f1f5f9;
    --bg-card: #ffffff;
    --border: #e2e8f0;
    --border-focus: #3b82f6;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.15);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset & Base ── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Setup Screen ── */
.setup-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
    position: relative;
    overflow: hidden;
}

.setup-wrapper::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 50%, rgba(16, 185, 129, 0.08) 0%, transparent 50%),
                radial-gradient(circle at 70% 30%, rgba(59, 130, 246, 0.06) 0%, transparent 50%);
    animation: bgFloat 20s ease-in-out infinite;
}

@keyframes bgFloat {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-2%, 2%); }
}

#setup-screen {
    width: 100%;
    max-width: 640px;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 40px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    position: relative;
    z-index: 1;
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideOut {
    to {
        opacity: 0;
        transform: translateY(-10px);
        height: 0;
        margin: 0;
        padding: 0;
        overflow: hidden;
    }
}

.setup-header {
    text-align: center;
    margin-bottom: 28px;
}

.setup-header .logo-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--accent), #059669);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 28px;
    color: white;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.setup-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 6px;
}

.setup-header p {
    font-size: 14px;
    color: var(--text-light);
}

/* ── Step Indicator ── */
.step-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 32px;
}

.step-indicator .step {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    background: var(--bg);
    transition: var(--transition);
}

.step-indicator .step.active {
    background: var(--accent-light);
}

.step-indicator .step.active .step-num {
    background: var(--accent);
    color: white;
}

.step-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    transition: var(--transition);
}

.step-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
}

.step-line {
    width: 24px;
    height: 2px;
    background: var(--border);
    margin: 0 4px;
}

/* ── Form Steps ── */
.form-step {
    display: none;
}

.form-step.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.step-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border);
}

/* ── Step Navigation ── */
.step-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.btn-next,
.btn-prev {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.btn-next {
    background: linear-gradient(135deg, var(--accent), #059669);
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.btn-next:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.btn-prev {
    background: var(--bg);
    color: var(--text-light);
    border: 1px solid var(--border);
}

.btn-prev:hover {
    background: #e2e8f0;
    color: var(--text);
}

/* ── Form Groups ── */
.form-group {
    margin-bottom: 16px;
}

.form-group label.group-label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 6px;
    color: var(--primary);
    letter-spacing: -0.01em;
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row .form-group {
    flex: 1;
}

.form-input,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--text);
    transition: var(--transition);
}

.form-input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--text);
    transition: var(--transition);
    resize: vertical;
    min-height: 60px;
}

.form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.form-textarea::placeholder {
    color: var(--text-muted);
}

.form-group select {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px;
}

/* ── Checkbox Group ── */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    user-select: none;
}

.checkbox-item:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

.checkbox-item.checked,
.checkbox-item:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-light);
}

/* ── Education Level Checkboxes ── */
.education-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.education-group .checkbox-item {
    text-align: center;
    justify-content: flex-start;
}

/* ── Dynamic Entries ── */
.dynamic-entry {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 12px;
    animation: slideUp 0.3s ease;
}

.entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.entry-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
}

.entry-title-sm {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
}

.btn-remove {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-remove:hover {
    background: #fee2e2;
    color: #ef4444;
}

.btn-add {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 12px;
}

.btn-add:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.btn-add-sm {
    padding: 8px;
    font-size: 13px;
    margin-bottom: 0;
    margin-top: 8px;
}

/* ── Mini Entry (Projects, Certs, Languages) ── */
.mini-entry {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 8px;
    animation: slideUp 0.3s ease;
}

/* ── Optional Section Detail Cards ── */
.optional-detail {
    margin-bottom: 16px;
}

.detail-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
}

.detail-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 12px;
}

/* ── Validation Error ── */
.validation-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 12px;
    animation: slideUp 0.3s ease;
}

/* ── Generate Button ── */
.btn-generate {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(135deg, var(--accent), #059669);
    color: white;
    border: none;
    padding: 14px 28px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.btn-generate:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
}

.btn-generate:active {
    transform: translateY(0);
}

.btn-generate .btn-icon {
    font-size: 18px;
}

/* ── CV Screen ── */
#cv-screen {
    display: none;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ── Toolbar ── */
.toolbar {
    background: var(--primary-dark);
    color: white;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toolbar-center {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    gap: 6px;
}

.toolbar-center .hint-icon {
    font-size: 16px;
}

.toolbar button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-back {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
}

.btn-back:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-pdf {
    background: linear-gradient(135deg, var(--accent), #059669);
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.btn-pdf:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

/* ── CV Container (A4) ── */
.cv-wrapper {
    padding: 30px 20px;
    display: flex;
    justify-content: center;
}

.cv-container {
    width: 210mm;
    min-height: 297mm;
    background: white;
    padding: 20mm;
    box-sizing: border-box;
    box-shadow: var(--shadow-lg);
    border-radius: 2px;
    position: relative;
}

/* ── Editable Fields ── */
[contenteditable="true"] {
    padding: 3px 4px;
    border: 1.5px solid transparent;
    border-radius: 4px;
    transition: var(--transition);
    outline: none;
}

[contenteditable="true"]:hover {
    background-color: #f8fafc;
    border-color: #cbd5e1;
}

[contenteditable="true"]:focus {
    background-color: #ffffff;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ── CV Typography ── */
.cv-container h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    margin: 0 0 4px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cv-container h2 {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary);
    margin: 22px 0 10px 0;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cv-container h3 {
    font-size: 14px;
    font-weight: 600;
    margin: 10px 0 2px 0;
    color: var(--text);
}

.contact-info {
    font-size: 13px;
    margin-bottom: 18px;
    color: var(--text-light);
    line-height: 1.8;
}

.contact-info span {
    margin-right: 6px;
}

.contact-separator {
    color: var(--text-muted);
    margin: 0 4px;
}

.job-title {
    font-style: italic;
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 5px;
}

.date {
    float: right;
    font-style: normal;
    font-size: 13px;
    color: var(--text-light);
    font-weight: 500;
}

.cv-container p,
.cv-container li {
    font-size: 13px;
    margin-bottom: 5px;
    line-height: 1.65;
}

.cv-container ul {
    margin: 0 0 15px 0;
    padding-left: 20px;
}

.cv-container li::marker {
    color: var(--accent);
}

/* ── PDF Modal ── */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: white;
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 440px;
    width: 100%;
    box-shadow: var(--shadow-xl);
    animation: modalSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg);
    border-radius: 50%;
    font-size: 18px;
    color: var(--text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: #e2e8f0;
    color: var(--text);
}

.modal-description {
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 24px;
    line-height: 1.5;
}

.modal-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-option {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 18px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    background: white;
    text-align: left;
    font-family: inherit;
    width: 100%;
}

.modal-option:hover {
    border-color: var(--accent);
    background: #f0fdf4;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.modal-option:active {
    transform: translateY(0);
}

.option-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.option-icon.direct {
    background: linear-gradient(135deg, var(--accent), #059669);
    color: white;
}

.option-icon.custom {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
}

.option-content h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.option-content p {
    font-size: 13px;
    color: var(--text-light);
    line-height: 1.45;
}

/* Loading state for direct save */
.modal-option.loading {
    pointer-events: none;
    opacity: 0.7;
}

.modal-option.loading .option-icon {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ── Print Styles ── */
@media print {
    body {
        background: white !important;
    }

    .setup-wrapper,
    #setup-screen,
    .toolbar,
    .modal-overlay {
        display: none !important;
    }

    #cv-screen {
        display: block !important;
    }

    .cv-wrapper {
        padding: 0;
    }

    .cv-container {
        margin: 0;
        padding: 10mm;
        width: 100%;
        min-height: auto;
        box-shadow: none;
        border-radius: 0;
    }

    [contenteditable="true"],
    [contenteditable="true"]:hover,
    [contenteditable="true"]:focus {
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
        padding: 0 !important;
    }

    .cv-container h2 {
        break-after: avoid;
    }

    .cv-container h3 {
        break-after: avoid;
    }
}

/* ── Responsive: Tablet ── */
@media (max-width: 900px) {
    .cv-wrapper {
        padding: 20px 10px;
    }

    .cv-container {
        width: 100%;
        min-height: auto;
        padding: 15mm;
    }
}

/* ── Responsive: Mobile ── */
@media (max-width: 640px) {
    /* Setup Screen */
    .setup-wrapper {
        padding: 16px;
        padding-top: 20px;
    }

    #setup-screen {
        padding: 24px 20px;
        border-radius: var(--radius-lg);
    }

    .setup-header h1 {
        font-size: 20px;
    }

    .setup-header p {
        font-size: 13px;
    }

    .form-input,
    .form-group select {
        font-size: 14px;
        padding: 10px 12px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .checkbox-item {
        padding: 9px 10px;
        font-size: 13px;
    }

    .education-group {
        grid-template-columns: 1fr;
    }

    .step-indicator {
        flex-wrap: wrap;
        gap: 4px;
    }

    .step-label {
        display: none;
    }

    .step-line {
        width: 16px;
    }

    .btn-generate {
        padding: 14px;
        font-size: 15px;
        width: 100%;
    }

    /* Toolbar */
    .toolbar {
        padding: 10px 14px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .toolbar-center {
        display: none;
    }

    .toolbar-left,
    .toolbar-right {
        gap: 8px;
    }

    .toolbar button {
        padding: 9px 14px;
        font-size: 12px;
    }

    .toolbar button .btn-text {
        display: inline;
    }

    /* CV on Mobile */
    .cv-wrapper {
        padding: 12px 8px;
    }

    .cv-container {
        padding: 8mm;
        border-radius: var(--radius-sm);
    }

    .cv-container h1 {
        font-size: 22px;
    }

    .cv-container h2 {
        font-size: 14px;
        margin: 18px 0 8px 0;
    }

    .cv-container h3 {
        font-size: 13px;
    }

    .contact-info {
        font-size: 12px;
        line-height: 1.9;
    }

    .date {
        float: none;
        display: block;
        font-size: 12px;
        margin-top: 2px;
    }

    .cv-container p,
    .cv-container li {
        font-size: 12px;
    }

    .job-title {
        font-size: 12px;
    }

    /* Modal on Mobile */
    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .modal {
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        padding: 24px 20px 32px;
        max-width: 100%;
        animation: modalSlideUpMobile 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    }

    @keyframes modalSlideUpMobile {
        from {
            opacity: 0;
            transform: translateY(100%);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .modal-header h2 {
        font-size: 18px;
    }

    .modal-option {
        padding: 14px;
    }

    .option-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .option-content h3 {
        font-size: 14px;
    }

    .option-content p {
        font-size: 12px;
    }
}

/* ── Responsive: Very Small Mobile ── */
@media (max-width: 380px) {
    #setup-screen {
        padding: 20px 16px;
    }

    .setup-header h1 {
        font-size: 18px;
    }

    .cv-container {
        padding: 6mm;
    }

    .cv-container h1 {
        font-size: 20px;
    }

    .toolbar button {
        padding: 8px 10px;
        font-size: 11px;
    }
}
