:root {
    --primary: #3f2478;
    --primary-hover: #2f175c;
    --secondary: #10B981;
    --danger: #EF4444;
    --bg-color: #F3F4F6;
    --sidebar-bg: rgba(255, 255, 255, 0.85);
    --text-main: #1F2937;
    --text-muted: #6B7280;
    --border-color: #E5E7EB;
    
    /* Resume specific colors (Legacy fallback) */
    --res-bg: #FFFFFF;
    --res-text: #333333;
    --res-heading: #111827;
    --res-accent: #3f2478;
    
    /* Granular Design Variables */
    --name-color: #111827;
    --name-size: 40px;
    --title-color: #3f2478;
    --title-size: 19px;
    --contact-color: #555555;
    --contact-size: 14px;
    --icon-color: #3f2478;
    --icon-size: 14px;
    --header-color: #111827;
    --header-size: 19px;
    --itemtitle-color: #111827;
    --itemtitle-size: 17px;
    --subtitle-color: #3f2478;
    --subtitle-size: 15px;
    --body-color: #444444;
    --body-size: 14px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    background-image: radial-gradient(circle at 10% 20%, rgb(239, 246, 255) 0%, rgb(219, 228, 255) 100%);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ---------------------------------
   SIDEBAR (LEFT PANEL)
-----------------------------------*/
.sidebar {
    width: 400px;
    min-width: 400px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(10px);
    border-right: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 4px 0 15px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
}

.sidebar-header h1 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.sidebar-content::-webkit-scrollbar {
    width: 6px;
}
.sidebar-content::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 4px;
}

details.form-section {
    background: #fff;
    border-radius: 12px;
    padding: 0;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
    border: 1px solid var(--border-color);
    overflow: hidden;
    list-style: none;
    transition: all 0.3s ease;
}
details.form-section[open] {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
}
summary.form-section-title {
    padding: 20px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
    background: #fff;
    user-select: none;
}
details.form-section[open] summary.form-section-title {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.02);
}
summary.form-section-title::-webkit-details-marker {
    display: none;
}
summary.form-section-title::after {
    content: '\f078';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: transform 0.3s ease;
}
details.form-section[open] summary.form-section-title::after {
    transform: rotate(180deg);
    color: var(--primary);
}
details.form-section > :not(summary) {
    padding: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-muted);
}

.form-group input, 
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    background: #f9fafb;
}

.form-group input:focus, 
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    background: #fff;
}

.sidebar-footer {
    padding: 20px;
    background: #fff;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
}

/* ---------------------------------
   ADVANCED DESIGN CONTROLS
-----------------------------------*/
.design-group {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(229, 231, 235, 0.8);
    border-radius: 12px;
    margin-bottom: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
    transition: all 0.3s ease;
}
.design-group:hover {
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 6px 12px rgba(0,0,0,0.05);
}

.design-group summary {
    padding: 14px 18px;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
    cursor: pointer;
    list-style: none; /* Hide default arrow */
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    border-radius: 12px;
}

.design-group summary::-webkit-details-marker {
    display: none;
}

.design-group summary::after {
    content: '\f078'; /* FontAwesome chevron-down */
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: transform 0.3s ease;
}

.design-group[open] summary::after {
    transform: rotate(180deg);
}

.design-controls {
    padding: 0 18px 18px 18px;
    border-top: 1px solid rgba(0,0,0,0.05);
    margin-top: 5px;
    padding-top: 15px;
}

.control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    border: 1px solid #f3f4f6;
}
.control-row:last-child {
    margin-bottom: 0;
}
.control-row span {
    width: 80px;
    font-size: 0.85rem;
    color: var(--text-main);
    font-weight: 500;
}

.control-inputs {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
}

/* Color Picker Styling */
input[type="color"] {
    -webkit-appearance: none;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    background: transparent;
}
input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}
input[type="color"]::-webkit-color-swatch {
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.1);
}

/* Range Slider Styling */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
}
input[type="range"]:focus {
    outline: none;
}
input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: #e5e7eb;
    border-radius: 10px;
}
input[type="range"]::-webkit-slider-thumb {
    height: 18px;
    width: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    -webkit-appearance: none;
    margin-top: -6px;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.3);
    transition: transform 0.1s;
}
input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

/* ---------------------------------
   BUTTONS
-----------------------------------*/
.btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.btn-primary {
    background: var(--primary);
    color: white;
    flex: 1;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

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

.btn-secondary:hover {
    background: #e5e7eb;
}

.btn-danger {
    background: #fee2e2;
    color: var(--danger);
}

.btn-danger:hover {
    background: #fecaca;
}

.btn-outline {
    background: transparent;
    border: 1px dashed var(--primary);
    color: var(--primary);
    width: 100%;
    padding: 12px;
    margin-top: 10px;
}

.btn-outline:hover {
    background: rgba(79, 70, 229, 0.05);
}

/* ---------------------------------
   DYNAMIC LIST ITEMS (Sortable)
-----------------------------------*/
.dynamic-item {
    background: #f9fafb;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    position: relative;
    cursor: grab;
}

.dynamic-item:active {
    cursor: grabbing;
}

.dynamic-item .remove-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 4px;
    opacity: 0.6;
    transition: 0.2s;
}

.dynamic-item .remove-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.dynamic-item-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}
.dynamic-item-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

/* ---------------------------------
   PREVIEW AREA (RIGHT PANEL)
-----------------------------------*/
.preview-area {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 40px;
    overflow-y: auto;
    background-image: radial-gradient(#d1d5db 1px, transparent 1px);
    background-size: 20px 20px;
}

.resume-wrapper {
    width: 100%;
    max-width: 800px; /* A4 aspect ratio approximation width */
    background: white;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border-radius: 4px; /* Real paper usually has sharp corners, but slight rounding is nice */
}

.resume-document {
    padding: 40px 50px;
    min-height: 1131px; /* A4 height proportional to 800px width */
    background: var(--res-bg);
    color: var(--body-color);
    font-size: var(--body-size);
    line-height: 1.5;
}

/* ---------------------------------
   RESUME TYPOGRAPHY & LAYOUT
-----------------------------------*/
.resume-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--res-accent);
    padding-bottom: 20px;
    margin-bottom: 20px;
    page-break-inside: avoid;
    break-inside: avoid;
}

.header-left {
    flex: 1;
}

.header-right {
    margin-left: 20px;
}

#res-name {
    font-size: var(--name-size);
    font-weight: 700;
    color: var(--name-color);
    margin-bottom: 5px;
    line-height: 1.1;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#res-title {
    font-size: var(--title-size);
    font-weight: 400;
    color: var(--title-color);
    margin-bottom: 15px;
}

.resume-contact {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    font-size: var(--contact-size);
    color: var(--contact-color);
}

.resume-contact span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.resume-contact i {
    color: var(--icon-color);
    font-size: var(--icon-size);
}

.resume-image-container {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--res-accent);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.resume-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.resume-body {
    display: flex;
    gap: 30px;
}

.resume-main {
    flex: 2;
}

.resume-sidebar {
    flex: 1;
}

.resume-section {
    margin-bottom: 25px;
}
.resume-sidebar .resume-section {
    page-break-inside: avoid;
    break-inside: avoid;
}

.section-title {
    font-size: var(--header-size);
    font-weight: 600;
    color: var(--header-color);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 15px;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 5px;
    page-break-inside: avoid;
    break-inside: avoid;
    page-break-after: avoid;
    break-after: avoid;
}

/* Resume Experience / Education Items (Migrated to Tailwind utilities) */


.skills-list {
    list-style: none;
    padding: 0;
}

.skills-list li {
    background: #f3f4f6;
    padding: 6px 12px;
    border-radius: 4px;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--body-color);
    font-size: var(--body-size);
    border-left: 3px solid var(--subtitle-color);
    page-break-inside: avoid;
    break-inside: avoid;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: 50vh;
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.5);
    }
    .preview-area {
        height: 50vh;
        padding: 20px;
    }
    .resume-wrapper {
        transform: scale(0.8);
        transform-origin: top center;
    }
}

/* ====================================================
   PRELOADER
   ==================================================== */
#app-preloader {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: linear-gradient(135deg, #1a0d3a 0%, #3f2478 50%, #6a3db8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#app-preloader.preloader-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.preloader-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.preloader-logo {
    animation: preloader-pulse 2s ease-in-out infinite;
}

.preloader-icon {
    width: 72px;
    height: 72px;
    border-radius: 16px;
    box-shadow: 0 0 40px rgba(163, 120, 255, 0.6);
    filter: drop-shadow(0 4px 16px rgba(100,60,200,0.5));
}

@keyframes preloader-pulse {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 4px 16px rgba(100,60,200,0.5)); }
    50%       { transform: scale(1.08); filter: drop-shadow(0 8px 32px rgba(163,120,255,0.9)); }
}

.preloader-spinner {
    display: flex;
    gap: 8px;
}

.preloader-spinner span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255,255,255,0.85);
    animation: preloader-bounce 1.2s ease-in-out infinite;
}
.preloader-spinner span:nth-child(1) { animation-delay: 0s; }
.preloader-spinner span:nth-child(2) { animation-delay: 0.15s; }
.preloader-spinner span:nth-child(3) { animation-delay: 0.3s; }
.preloader-spinner span:nth-child(4) { animation-delay: 0.45s; }

@keyframes preloader-bounce {
    0%, 100% { transform: translateY(0); opacity: 0.5; }
    50%       { transform: translateY(-14px); opacity: 1; }
}

.preloader-text {
    color: rgba(255,255,255,0.75);
    font-size: 0.9rem;
    letter-spacing: 0.06em;
    font-weight: 500;
    animation: preloader-fade 1.8s ease-in-out infinite;
}

@keyframes preloader-fade {
    0%, 100% { opacity: 0.5; }
    50%       { opacity: 1; }
}


/* ====================================================
   WELCOME MODAL
   ==================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(20, 10, 50, 0.75);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    /* hidden by default */
}

.modal-overlay.modal-visible {
    display: flex;
    animation: modal-overlay-in 0.35s ease;
}

.modal-overlay.modal-closing .modal-box {
    animation: modal-box-out 0.35s ease forwards;
}

@keyframes modal-overlay-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes modal-box-out {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to   { opacity: 0; transform: translateY(30px) scale(0.96); }
}

.modal-box {
    background: rgba(255,255,255,0.98);
    border-radius: 20px;
    box-shadow: 0 32px 80px rgba(63,36,120,0.25), 0 0 0 1px rgba(63,36,120,0.08);
    width: 100%;
    max-width: 500px;
    overflow: hidden;
    animation: modal-box-in 0.38s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modal-box-in {
    from { opacity: 0; transform: translateY(40px) scale(0.94); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    background: linear-gradient(135deg, #1a0d3a 0%, #3f2478 60%, #6a3db8 100%);
    padding: 28px 28px 22px;
    text-align: center;
    position: relative;
}

.modal-logo {
    display: block;
    width: 52px;
    height: 52px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    margin: 0 auto 12px;
}

.modal-header h2 {
    color: #fff;
    font-size: 1.45rem;
    font-weight: 700;
    margin: 0 0 6px;
    letter-spacing: -0.02em;
}

.modal-subtitle {
    color: rgba(255,255,255,0.72);
    font-size: 0.875rem;
}

.modal-subtitle strong {
    color: rgba(255,255,255,0.95);
}

.modal-body {
    padding: 24px 28px 16px;
}

.modal-steps {
    list-style: none;
    padding: 0;
    margin: 0 0 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal-steps li {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.step-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #3f2478, #6a3db8);
    color: #fff !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    box-shadow: 0 2px 8px rgba(63,36,120,0.3);
    margin-top: 2px;
}

.step-icon i,
.step-icon svg {
    color: #fff !important;
    fill: #fff !important;
}

.modal-steps li div {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.modal-steps li strong {
    font-size: 0.9rem;
    color: #1a0d3a;
    font-weight: 600;
}

.modal-steps li span {
    font-size: 0.82rem;
    color: #6b7280;
    line-height: 1.4;
}

.modal-note {
    background: #f5f3ff;
    border: 1px solid #e0d7f5;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 0.82rem;
    color: #5b21b6;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-note i {
    font-size: 0.9rem;
    color: #7c3aed;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px 24px;
    border-top: 1px solid #f3f4f6;
    gap: 12px;
    flex-wrap: wrap;
}

.modal-dont-show {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.82rem;
    color: #6b7280;
    cursor: pointer;
    user-select: none;
}

.modal-dont-show input[type="checkbox"] {
    width: 16px !important;
    height: 16px;
    accent-color: #3f2478;
    cursor: pointer;
    margin: 0;
}

#modal-close-btn {
    padding: 10px 22px;
    font-size: 0.9rem;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #3f2478, #6a3db8);
    border: none;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 4px 14px rgba(63,36,120,0.4);
}

#modal-close-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(63,36,120,0.55);
}

@media (max-width: 520px) {
    .modal-header { padding: 22px 20px 18px; }
    .modal-body   { padding: 20px 20px 12px; }
    .modal-footer { padding: 14px 20px 20px; }
    .modal-box    { border-radius: 16px; }
}
