/* 
 * NEON DARK THEME: THE KINETIC BLUEPRINT
 * Complete rewrite - fixed missing :root selector that broke all CSS variables.
 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Space+Grotesk:wght@400;500;700;900&display=swap');

/* =============================================
   ROOT: DARK MODE DEFAULTS (CSS Variables)
   ============================================= */
:root {
    --surface: #0e0e0e;
    --surface-container-low: #131313;
    --surface-container-high: #201f1f;
    --surface-container-highest: rgba(38, 38, 38, 0.85);
    --surface-container-lowest: #050505;

    --text-color: #ffffff;
    --on-surface-variant: #adaaaa;

    --primary-color: #afffd1;       /* Neon Mint */
    --primary-container: #00ffaa;
    --secondary-color: #7799ff;     /* Electric Blue */

    --bg-color: #0e0e0e;
    --card-bg: #131313;
    --border-color: #333333;

    --font-size-base: 17px;
    --font-size-input: 1rem;
}

/* =============================================
   LIGHT MODE OVERRIDES
   ============================================= */
body:not(.dark-mode) {
    --surface: #f5f5f5;
    --surface-container-low: #ffffff;
    --surface-container-high: #eaeaea;
    --surface-container-highest: rgba(200, 200, 200, 0.5);
    --surface-container-lowest: #ffffff;

    --text-color: #111111;
    --on-surface-variant: #555555;

    --primary-color: #006b45;
    --primary-container: #00a36c;
    --secondary-color: #1a56db;

    --bg-color: #f5f5f5;
    --card-bg: #ffffff;
    --border-color: #d1d5db;
}

/* =============================================
   BODY & GLOBAL RESET
   ============================================= */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    font-size: var(--font-size-base);
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
}

body.dark-mode {
    background-color: var(--bg-color);
    color: var(--text-color);
}

h1, h2, h3, h4, .heading {
    font-family: 'Space Grotesk', sans-serif;
}

/* =============================================
   THEME TOGGLE (Moon/Sun Switch)
   ============================================= */
.theme-switch-wrapper {
    position: fixed;
    top: 20px;
    right: 24px;
    z-index: 9999;
}

.switch {
    font-size: 17px;
    position: relative;
    display: inline-block;
    width: 4em;
    height: 2.2em;
    border-radius: 30px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #555;
    transition: 0.4s;
    border-radius: 30px;
    overflow: hidden;
}
.slider:before {
    position: absolute;
    content: "";
    height: 1.2em;
    width: 1.2em;
    border-radius: 20px;
    left: 0.5em;
    bottom: 0.5em;
    transition: 0.4s;
    box-shadow: inset 8px -4px 0px 0px #fff;
}
.switch input:checked + .slider { background-color: var(--primary-container); }
.switch input:checked + .slider:before {
    transform: translateX(1.8em);
    box-shadow: inset 15px -4px 0px 15px #ffcf48;
}

/* =============================================
   HEADER
   ============================================= */
.header {
    width: 100%;
    text-align: center;
    padding: 70px 20px 40px;
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0;
}

.header h1 {
    font-size: 3.5rem;
    font-weight: 900;
    letter-spacing: -2px;
    text-transform: uppercase;
    color: var(--primary-color);
    margin: 0;
}

.header p {
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 5px;
    text-transform: uppercase;
    color: var(--on-surface-variant);
    margin-top: 8px;
}

/* =============================================
   APP LAYOUT & CONTAINERS
   ============================================= */
#app {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.page {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: center;
}

.page.active {
    display: flex;
}

.container {
    width: 100%;
    max-width: 100%;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
}

.draggable-sections-container {
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* =============================================
   TEMPLATE PICKER HEADER
   ============================================= */
.template-picker-head {
    text-align: center;
    padding: 40px 20px 0;
    width: 100%;
}

.template-picker-head h2 {
    font-size: 2.4rem !important;
    font-weight: 800 !important;
    color: var(--text-color) !important;
    border: none !important;
    margin-bottom: 10px !important;
    display: block !important;
    justify-content: unset !important;
}

.template-picker-head p {
    font-size: 1rem;
    color: var(--on-surface-variant);
    margin-bottom: 16px;
}

.template-count-pill {
    background: var(--primary-color);
    color: var(--surface-container-lowest);
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-block;
    margin-top: 8px;
}

/* =============================================
   TEMPLATE GRID (3 IN A ROW)
   ============================================= */
.template-preview,
#template-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 28px;
    padding: 32px 5%;
    width: 100%;
    box-sizing: border-box;
}

/* =============================================
   TEMPLATE CARDS
   ============================================= */
.template-card {
    background: var(--surface-container-low) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 16px !important;
    padding: 0 !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3) !important;
    transition: transform 0.25s ease, box-shadow 0.25s ease !important;
    overflow: hidden;
    cursor: pointer;
}

.template-card:hover {
    transform: translateY(-6px) !important;
    box-shadow: 0 16px 40px rgba(0,0,0,0.5) !important;
}

/* =============================================
   FORM SECTIONS (After template selection)
   ============================================= */
#form-sections {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.template-status-bar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 8%;
    background: var(--surface-container-high);
    border-bottom: 1px solid var(--border-color);
    box-sizing: border-box;
}

/* =============================================
   CARDS (Form Sections)
   ============================================= */
.card, .draggable-section {
    background: transparent !important;
    border: none !important;
    border-bottom: 1px solid var(--border-color) !important;
    border-radius: 0 !important;
    padding: 36px 8% !important;
    box-shadow: none !important;
    width: 100%;
    box-sizing: border-box;
}

.card .heading {
    font-size: 1.4rem !important;
    font-weight: 700 !important;
    color: var(--text-color) !important;
    margin: 0 0 24px 0 !important;
    border-bottom: none !important;
    display: flex !important;
    justify-content: space-between;
    align-items: center;
}

/* =============================================
   SECTION HANDLE (Draggable)
   ============================================= */
.section-handle {
    background: var(--surface-container-high) !important;
    color: var(--secondary-color) !important;
    padding: 5px 12px !important;
    border-radius: 6px !important;
    font-size: 11px !important;
    text-transform: uppercase !important;
    letter-spacing: 1px !important;
    font-weight: 700 !important;
    cursor: grab;
    border: 1px solid var(--border-color) !important;
    white-space: nowrap;
}

/* =============================================
   MATERIAL INPUTS (Floating Label)
   ============================================= */
.material-input {
    position: relative;
    margin-bottom: 20px;
    width: 100%;
}

.material-input input,
.material-input textarea {
    width: 100% !important;
    padding: 22px 16px 10px !important;
    background: #0d0d0d !important;            /* DARKER than entry container for contrast */
    border: 1px solid #2a2a2a !important;
    border-radius: 8px !important;
    font-size: var(--font-size-input) !important;
    color: var(--text-color) !important;
    outline: none !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
    box-sizing: border-box !important;
    font-family: 'Inter', sans-serif !important;
    resize: vertical;
}

.material-input input:focus,
.material-input textarea:focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 3px rgba(175, 255, 209, 0.12) !important;
}

.material-input label {
    position: absolute;
    top: 50%;
    left: 16px;
    transform: translateY(-50%);
    color: var(--on-surface-variant) !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.8px !important;
    pointer-events: none;
    transition: all 0.15s ease;
    background: transparent;
    padding: 0 2px;
}

.material-input textarea ~ label {
    top: 22px;
    transform: none;
}

.material-input input:focus ~ label,
.material-input input:not(:placeholder-shown) ~ label,
.material-input textarea:focus ~ label,
.material-input textarea:not(:placeholder-shown) ~ label {
    top: 6px !important;
    transform: none !important;
    font-size: 9px !important;
    color: var(--primary-color) !important;
    letter-spacing: 1px !important;
}

/* =============================================
   ENTRY ROWS (Education, Experience, etc.)
   Containers use mid-dark background. Inputs
   inside use a DARKER bg for clear contrast.
   ============================================= */
.education-entry, .experience-entry,
.project-entry, .achievement-entry, .blueprint-entry {
    display: flex !important;
    flex-direction: column !important;
    background: #1c1c24 !important;            /* Container: mid-dark */
    border: 1px solid var(--border-color) !important;
    border-left: 3px solid var(--primary-color) !important;
    border-radius: 10px !important;
    padding: 20px !important;
    margin-bottom: 16px !important;
    box-sizing: border-box;
    width: 100%;
    gap: 0;
}

.education-entry:hover, .experience-entry:hover,
.project-entry:hover, .achievement-entry:hover {
    box-shadow: 0 4px 20px rgba(175, 255, 209, 0.06) !important;
    border-left-color: var(--primary-container) !important;
}

/* =============================================
   INPUT ROW HELPER
   ============================================= */
.input-row {
    display: flex;
    gap: 14px;
    width: 100%;
    margin-bottom: 0;
}

.input-row > .material-input { flex: 1; }

/* =============================================
   BUTTONS
   ============================================= */
.btn-primary, #generate-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-container)) !important;
    color: #0a0a0a !important;
    font-family: 'Space Grotesk', sans-serif !important;
    font-weight: 800 !important;
    font-size: 1rem !important;
    text-transform: uppercase !important;
    letter-spacing: 1.5px !important;
    border: none !important;
    border-radius: 8px !important;
    padding: 16px 48px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 0 20px rgba(0, 255, 170, 0.25) !important;
}

.btn-primary:hover, #generate-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 0 40px rgba(0, 255, 170, 0.5) !important;
}

.btn-secondary, .add-btn, .remove-btn, #change-template-btn {
    background: transparent !important;
    color: var(--primary-color) !important;
    border: 1px solid var(--primary-color) !important;
    border-radius: 8px !important;
    padding: 9px 20px !important;
    font-weight: 700 !important;
    font-size: 11px !important;
    text-transform: uppercase !important;
    letter-spacing: 1px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    font-family: 'Inter', sans-serif !important;
}

.btn-secondary:hover, .add-btn:hover, #change-template-btn:hover {
    background: var(--primary-color) !important;
    color: #0a0a0a !important;
}

.remove-btn {
    color: #ff6b6b !important;
    border-color: #ff6b6b !important;
}

.remove-btn:hover {
    background: #ff6b6b !important;
    color: white !important;
}

/* =============================================
   FORMAT SELECTOR
   ============================================= */
.format-selector {
    display: flex;
    gap: 6px;
    background: var(--surface-container-high);
    padding: 6px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.format-selector button {
    padding: 8px 24px;
    font-size: 12px;
    transition: all 0.2s ease;
}

.format-selector button.active {
    background: var(--primary-color) !important;
    color: #0a0a0a !important;
    border-color: transparent !important;
    box-shadow: 0 0 15px rgba(175, 255, 209, 0.25);
}

/* =============================================
   DOWNLOAD AREA
   ============================================= */
.download-area {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 40px 0 80px;
    border-top: 1px solid var(--border-color);
    margin-top: 20px;
}

/* =============================================
   MODAL (Preview)
   ============================================= */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 10000;
    overflow-y: auto;
    padding: 40px 20px;
    box-sizing: border-box;
    backdrop-filter: blur(6px);
}

.modal-content {
    max-width: 860px;
    margin: 0 auto;
    position: relative;
}

.close-modal {
    position: fixed;
    top: 20px;
    right: 30px;
    font-size: 2.5rem;
    color: white;
    cursor: pointer;
    z-index: 10001;
    line-height: 1;
}

.close-modal:hover { color: var(--primary-color); }

#template-preview-content {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0,0,0,0.6);
}

/* =============================================
   LOADER
   ============================================= */
#loader-screen {
    background: rgba(0,0,0,0.92) !important;
    backdrop-filter: blur(12px) !important;
}

/* =============================================
   SCROLLBAR
   ============================================= */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--surface-container-low); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-color); }

/* =============================================
   LIGHT MODE SPECIFIC OVERRIDES
   ============================================= */
body:not(.dark-mode) .material-input input,
body:not(.dark-mode) .material-input textarea {
    background: #ffffff !important;
    border-color: #d1d5db !important;
    color: #111111 !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06) !important;
}

body:not(.dark-mode) .education-entry,
body:not(.dark-mode) .experience-entry,
body:not(.dark-mode) .project-entry,
body:not(.dark-mode) .achievement-entry,
body:not(.dark-mode) .blueprint-entry {
    background: #f0f2f5 !important;        /* Light grey container */
    border-color: #d1d5db !important;
    border-left-color: var(--primary-color) !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05) !important;
}

body:not(.dark-mode) .template-card {
    background: #ffffff !important;
    border-color: #e5e7eb !important;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08) !important;
}

body:not(.dark-mode) .card,
body:not(.dark-mode) .draggable-section {
    border-bottom-color: #e5e7eb !important;
}

body:not(.dark-mode) .section-handle {
    background: #f3f4f6 !important;
    color: var(--secondary-color) !important;
    border-color: #e5e7eb !important;
}

body:not(.dark-mode) .template-status-bar {
    background: #f9fafb;
    border-bottom-color: #e5e7eb;
}
