:root {
    --bg-color: #f5f5f7;
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --glass-bg: rgba(255, 255, 255, 0.15);
    --glass-border: rgba(255, 255, 255, 0.4);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    --accent-blue: #0071e3;
    --accent-blue-hover: #0077ed;
    --input-bg: rgba(255, 255, 255, 0.2);
    --input-border: rgba(255, 255, 255, 0.5);
    --danger: #ff3b30;
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
}

[data-theme="dark"] {
    --bg-color: #000000;
    --text-primary: #f5f5f7;
    --text-secondary: #a1a1a6;
    --glass-bg: rgba(28, 28, 30, 0.15);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    --input-bg: rgba(44, 44, 46, 0.2);
    --input-border: rgba(255, 255, 255, 0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-image: radial-gradient(circle at top left, rgba(0, 113, 227, 0.1) 0%, transparent 40%),
                      radial-gradient(circle at bottom right, rgba(162, 59, 218, 0.1) 0%, transparent 40%);
    background-attachment: fixed;
}

/* macOS Top Bar */
.mac-topbar {
    height: 54px;
    background: var(--glass-bg);
    backdrop-filter: saturate(180%) blur(40px);
    -webkit-backdrop-filter: saturate(180%) blur(40px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 16px;
    margin: 16px 20px;
    z-index: 100;
    box-shadow: var(--glass-shadow);
}

.export-section {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
}

.window-controls {
    display: flex;
    gap: 8px;
    width: 100px;
}

.window-controls span {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.window-controls .close { background: #ff5f56; border: 1px solid #e0443e; }
.window-controls .minimize { background: #ffbd2e; border: 1px solid #dea123; }
.window-controls .maximize { background: #27c93f; border: 1px solid #1aab29; }

.topbar-logo {
    width: 150px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

.topbar-logo img {
    height: 38px;
    width: auto;
    object-fit: contain;
    border-radius: 4px;
}

.topbar-title {
    flex: 1;
    text-align: center;
    font-weight: 600;
    font-size: 15px;
    letter-spacing: -0.01em;
}

.topbar-actions {
    width: 150px;
    display: flex;
    justify-content: flex-end;
    gap: 16px;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    transition: opacity 0.2s, transform 0.2s;
}

.icon-btn:hover {
    opacity: 0.7;
    transform: scale(1.1);
}

/* Dropdown Menu */
.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    min-width: 200px;
    z-index: 200;
    padding: 8px 0;
    animation: fadeIn 0.2s ease;
}

.dropdown-content.show {
    display: block;
}

.dropdown-content a {
    color: var(--text-primary);
    padding: 10px 16px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.dropdown-content a i {
    width: 16px;
    text-align: center;
    color: var(--text-secondary);
}

.dropdown-content a:hover {
    background: rgba(0, 113, 227, 0.1);
}

.dropdown-content a:hover i {
    color: var(--accent-blue);
}

.dropdown-content hr {
    border: none;
    border-top: 1px solid var(--glass-border);
    margin: 8px 0;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Menu Overlay for Blur */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 150; /* Above everything except topbar and dropdown */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.menu-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

[data-theme="dark"] .menu-overlay {
    background: rgba(0, 0, 0, 0.4);
}

/* Ensure topbar actions and dropdown stay above the blur */
.mac-topbar {
    position: sticky;
    top: 16px;
    /* ... existing styles ... */
    z-index: 160; /* Higher than menu-overlay */
}

/* Layout */
.app-container {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 24px;
    padding: 24px;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
}

/* Glass Panel Styling */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: saturate(180%) blur(40px);
    -webkit-backdrop-filter: saturate(180%) blur(40px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
}

/* Sidebar / Form */
.sidebar {
    padding: 24px;
    height: calc(100vh - 100px);
    overflow-y: auto;
    scrollbar-width: thin;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}
.sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(0,0,0,0.2);
    border-radius: 10px;
}

.form-section {
    margin-bottom: 32px;
}

.form-section-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

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

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

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

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    transition: all 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.2);
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

/* Dynamic Items */
.dynamic-item {
    background: rgba(0,0,0,0.02);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 16px;
    position: relative;
    transition: all 0.2s;
}

[data-theme="dark"] .dynamic-item {
    background: rgba(255,255,255,0.02);
}

.btn-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--danger);
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    box-shadow: 0 2px 8px rgba(255, 59, 48, 0.3);
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s;
}

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

.btn-add {
    background: transparent;
    color: var(--accent-blue);
    border: 1px dashed var(--accent-blue);
    width: 100%;
    padding: 10px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.btn-add:hover {
    background: rgba(0, 113, 227, 0.05);
}

/* Main Area / Preview */
.preview-area {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
}

.preview-title {
    font-weight: 600;
    font-size: 16px;
}

.btn-primary {
    background: var(--accent-blue);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 100px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    box-shadow: 0 2px 10px rgba(0, 113, 227, 0.3);
}

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

.btn-primary:active {
    transform: translateY(1px);
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    padding: 8px 16px;
    border-radius: 100px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* The Resume Paper (Exact PDF Format) */
.resume-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-y: auto;
    padding: 24px 0;
    scrollbar-width: none;
}

.resume-wrapper::-webkit-scrollbar {
    display: none;
}

.resume-paper {
    background: #ffffff;
    width: 21cm;
    min-height: 29.7cm;
    padding: 1.2cm 1.5cm 1.5cm 1.5cm; /* Top, Right, Bottom, Left */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    color: #000;
    font-family: Arial, Helvetica, sans-serif;
    transform-origin: top center;
    transition: transform 0.3s ease;
    position: relative;
}

/* PDF Resume Typography & Layout */
.rp-header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.rp-header-text {
    flex: 1;
    text-align: center;
}

.rp-name {
    font-size: 22pt;
    font-weight: 800;
    text-transform: uppercase;
    color: #000;
    margin-bottom: 2px;
    letter-spacing: 0.5px;
}

.rp-contact {
    font-size: 9pt;
    color: #000;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 2px;
}

.rp-contact span {
    position: relative;
    display: flex;
    align-items: center;
}
.rp-contact span:not(:last-child)::after {
    content: "•";
    margin-left: 4px;
    font-weight: bold;
}

.rp-qr-code {
    width: 60px;
    height: 60px;
    object-fit: cover;
}

.rp-header-lines {
    border-top: 2px solid #000;
    border-bottom: 1px solid #000;
    height: 3px;
    margin-bottom: 10px;
}

.rp-section-title {
    font-size: 11pt;
    font-weight: 800;
    color: #000;
    text-transform: uppercase;
    border-bottom: 1.5px solid #000;
    padding-bottom: 2px;
    margin-top: 10px;
    margin-bottom: 6px;
}

.rp-summary {
    font-size: 9.5pt;
    line-height: 1.4;
    color: #000;
    text-align: justify;
}

.rp-item {
    margin-bottom: 6px;
}

.rp-item-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 2px;
}

.rp-item-title {
    font-size: 10pt;
    font-weight: 700;
    color: #000;
}

.rp-item-date {
    font-size: 9pt;
    color: #444;
}

.rp-item-subtitle {
    font-size: 9.5pt;
    color: #555;
    margin-bottom: 4px;
}

.rp-item-desc {
    font-size: 9.5pt;
    line-height: 1.4;
    color: #000;
}

.rp-item-desc ul {
    margin: 0;
    padding-left: 15px;
}

.rp-item-desc li {
    margin-bottom: 3px;
}

.rp-skills-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 6px;
    font-size: 9.5pt;
    line-height: 1.4;
}

.rp-skills-category {
    font-weight: 700;
    color: #000;
    color: #000;
}

/* Hide Mobile Bottom Nav on Desktop by default */
.mobile-bottom-nav {
    display: none;
}

@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 1fr;
    }
    .sidebar {
        height: auto;
    }
    .resume-wrapper {
        padding: 16px 0;
        overflow-x: hidden;
        align-items: flex-start;
        justify-content: center;
    }
    .resume-paper {
        width: 21cm !important;
        min-height: 29.7cm !important;
        transform: scale(calc((100vw - 32px) / 794));
        transform-origin: top center;
        margin-bottom: calc(-29.7cm + (29.7cm * ((100vw - 32px) / 794)));
        border-radius: 4px;
    }

    /* Mobile Bottom Navigation Styles */
    .mobile-bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background: rgba(255, 255, 255, 0.85);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-top: 1px solid var(--glass-border);
        box-shadow: 0 -4px 15px rgba(0,0,0,0.05);
        z-index: 1000;
        padding-bottom: env(safe-area-inset-bottom, 0px); /* For iPhone notch */
    }

    .mobile-bottom-nav .nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 12px 0;
        background: transparent;
        border: none;
        color: var(--text-secondary);
        font-size: 12px;
        font-weight: 500;
        gap: 6px;
        transition: 0.3s;
    }

    .mobile-bottom-nav .nav-item i {
        font-size: 20px;
    }

    .mobile-bottom-nav .nav-item.active {
        color: var(--accent-blue);
    }
    
    [data-theme="dark"] .mobile-bottom-nav {
        background: rgba(30, 30, 30, 0.85);
    }

    /* Mobile View Toggling Logic */
    /* By default on mobile, show sidebar (Edit), hide preview */
    .resume-wrapper {
        display: none !important;
    }
    .sidebar {
        display: block !important;
        margin-bottom: 70px; /* Space for bottom nav */
    }

    /* When preview view is active */
    body.show-preview .sidebar {
        display: none !important;
    }
    body.show-preview .resume-wrapper {
        display: flex !important;
        margin-bottom: 70px; /* Space for bottom nav */
    }
    
    /* Ensure footer stays out of the way */
    .app-footer {
        padding-bottom: 80px;
    }
}

/* PDF Export Override Mode */
body.pdf-export-mode {
    width: 1024px !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
}
body.pdf-export-mode .app-container {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
}
body.pdf-export-mode .sidebar, 
body.pdf-export-mode .mac-topbar,
body.pdf-export-mode .preview-header,
body.pdf-export-mode .app-footer,
body.pdf-export-mode .menu-overlay {
    display: none !important;
}
body.pdf-export-mode .resume-wrapper {
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    display: block !important;
}
body.pdf-export-mode .resume-paper {
    transform: none !important;
    margin: 0 !important;
    width: 21cm !important;
    min-height: 29.7cm !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    /* Removed position: absolute to fix blank sheet issue on mobile html2canvas */
}

/* Footer Styling */
.app-footer {
    text-align: center;
    padding: 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: 0;
    border-bottom: none;
    border-left: none;
    border-right: none;
}

.footer-link {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
}

.footer-link:hover {
    color: var(--accent-blue-hover);
    text-decoration: underline;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    width: 450px;
    max-width: 90%;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    transform: translateY(20px);
    transition: transform 0.3s;
    overflow: hidden;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--glass-border);
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.export-option {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border: 2px solid var(--glass-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}

.export-option:hover {
    border-color: var(--accent-blue);
    background: rgba(0, 113, 227, 0.05);
}

.export-option.selected {
    border-color: var(--accent-blue);
    background: rgba(0, 113, 227, 0.1);
    box-shadow: 0 4px 12px rgba(0, 113, 227, 0.15);
}

.opt-icon {
    font-size: 24px;
    color: var(--text-secondary);
}

.export-option.selected .opt-icon {
    color: var(--accent-blue);
}

.opt-details h4 {
    margin: 0 0 4px 0;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.opt-details p {
    margin: 0;
    font-size: 12px;
    color: var(--text-secondary);
}

.badge {
    background: #ff9f0a;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--glass-border);
}

.resume-watermark {
    position: absolute;
    bottom: 20px;
    right: 20px;
    font-family: Arial, sans-serif;
    font-size: 12px;
    color: #999;
    pointer-events: none;
    z-index: 10;
}
@keyframes scaleIn {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}