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

:root {
    --bg-primary: #0D1117;
    --bg-secondary: #161B22;
    --bg-card: rgba(255, 255, 255, 0.03);
    --bg-card-hover: rgba(255, 255, 255, 0.06);
    --border: rgba(255, 255, 255, 0.08);
    --border-active: rgba(108, 92, 231, 0.4);
    --text-primary: #E6EDF3;
    --text-secondary: #8B949E;
    --text-muted: #636E72;
    --accent: #6C5CE7;
    --accent-light: #A29BFE;
    --accent-glow: rgba(108, 92, 231, 0.2);
    --success: #10B981;
    --danger: #EF4444;
    --radius: 12px;
    --radius-sm: 8px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 1.25rem;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Header */
.app-header {
    text-align: center;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.logo h1 {
    font-size: 1.3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.toolbar-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-right: 0.4rem;
}

.theme-selector {
    display: flex;
    align-items: center;
}

.select {
    padding: 0.35rem 0.6rem;
    font-family: var(--font);
    font-size: 0.75rem;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    outline: none;
}

.select:focus {
    border-color: var(--border-active);
}

.toolbar-actions {
    display: flex;
    gap: 0.35rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem 0.75rem;
    font-family: var(--font);
    font-size: 0.72rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-light);
}

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

.btn-secondary:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.btn-add {
    width: 100%;
    padding: 0.5rem;
    font-size: 0.75rem;
    color: var(--accent);
    background: rgba(108, 92, 231, 0.06);
    border: 1px dashed var(--border-active);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-add:hover {
    background: rgba(108, 92, 231, 0.12);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.08);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 0.3rem 0.5rem;
    font-size: 0.65rem;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.15);
}

/* Main Layout */
.main-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 1rem;
    min-height: calc(100vh - 10rem);
}

/* Editor Panel */
.editor-panel {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: calc(100vh - 10rem);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.editor-panel::-webkit-scrollbar {
    width: 4px;
}

.editor-panel::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

/* Section Tabs */
.section-tabs {
    display: flex;
    gap: 0.2rem;
    padding: 0.2rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
    scrollbar-width: none;
}

.section-tabs::-webkit-scrollbar {
    display: none;
}

.sec-tab {
    flex: 1;
    min-width: fit-content;
    padding: 0.4rem 0.5rem;
    font-family: var(--font);
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.sec-tab:hover {
    color: var(--text-secondary);
}

.sec-tab.active {
    color: #fff;
    background: var(--accent);
}

/* Form Sections */
.form-section {
    display: none;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.form-section.active {
    display: flex;
}

/* Fields */
.field {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.field span {
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.field input,
.field textarea {
    width: 100%;
    padding: 0.4rem 0.5rem;
    font-family: var(--font);
    font-size: 0.78rem;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    outline: none;
    resize: vertical;
    transition: border-color var(--transition);
}

.field input:focus,
.field textarea:focus {
    border-color: var(--border-active);
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
}

/* Item Cards */
.item-card {
    padding: 0.6rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    animation: fadeIn 0.2s ease;
}

.item-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.item-card-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

.items-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

/* Preview Panel */
.preview-panel {
    background: #fff;
    border-radius: var(--radius);
    overflow: auto;
    min-height: 400px;
}

.resume-preview {
    padding: 2rem;
    color: #1a1a1a;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    line-height: 1.6;
}

/* Preview Styles */
.resume-preview h2 {
    font-size: 12px;
    font-weight: 700;
    color: #6C5CE7;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-bottom: 2px solid #6C5CE7;
    padding-bottom: 4px;
    margin: 16px 0 8px;
}

.resume-preview h1 {
    font-size: 24px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 2px;
}

.resume-preview .r-title {
    font-size: 14px;
    color: #636E72;
    margin-bottom: 8px;
}

.resume-preview .r-contact {
    font-size: 11px;
    color: #636E72;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
}

.resume-preview .r-contact a {
    color: #6C5CE7;
    text-decoration: none;
}

.resume-preview .r-summary {
    font-size: 13px;
    color: #333;
    line-height: 1.6;
    margin-bottom: 8px;
}

.resume-preview .r-entry {
    margin-bottom: 10px;
}

.resume-preview .r-entry-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.resume-preview .r-entry-title {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
}

.resume-preview .r-entry-date {
    font-size: 11px;
    color: #8B949E;
}

.resume-preview .r-entry-sub {
    font-size: 12px;
    color: #636E72;
}

.resume-preview .r-entry-desc {
    font-size: 12px;
    color: #444;
    margin-top: 4px;
}

.resume-preview .r-skills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.resume-preview .r-skill-tag {
    padding: 2px 8px;
    font-size: 11px;
    background: #F0EFFF;
    color: #6C5CE7;
    border-radius: 4px;
}

.resume-preview .r-skill-group {
    margin-bottom: 8px;
}

.resume-preview .r-skill-name {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    width: 90%;
    max-width: 500px;
}

.modal h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

.modal textarea {
    width: 100%;
    padding: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    resize: vertical;
    outline: none;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.4rem;
    margin-top: 0.75rem;
}

/* Responsive */
@media (max-width: 900px) {
    .main-layout {
        grid-template-columns: 1fr;
    }

    .editor-panel {
        max-height: none;
    }
}

@media (max-width: 480px) {
    body {
        padding: 0.75rem;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Theme Variants for Preview */
.resume-preview.theme-compact {
    font-size: 11px;
    padding: 1.25rem;
}

.resume-preview.theme-compact h1 {
    font-size: 20px;
}

.resume-preview.theme-compact h2 {
    font-size: 10px;
}

.resume-preview.theme-modern h2 {
    color: #1a1a1a;
    border-bottom: 1px solid #ddd;
    font-size: 14px;
    text-transform: none;
    letter-spacing: 0;
}

.resume-preview.theme-modern .r-skill-tag {
    background: #333;
    color: #fff;
    border-radius: 12px;
}

.resume-preview.theme-classic h2 {
    color: #333;
    border-bottom: 1px solid #333;
    letter-spacing: 0.12em;
}

.resume-preview.theme-classic .r-skill-tag {
    background: #eee;
    color: #333;
}

.resume-preview.theme-minimal {
    padding: 3rem;
}

.resume-preview.theme-minimal h2 {
    border: none;
    color: #888;
    font-weight: 400;
    margin-top: 20px;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Print */
@media print {
    body {
        background: #fff;
        padding: 0;
    }

    .app-header,
    .toolbar,
    .editor-panel,
    .section-tabs,
    .modal-overlay {
        display: none !important;
    }

    .main-layout {
        grid-template-columns: 1fr;
    }

    .preview-panel {
        border-radius: 0;
        box-shadow: none;
    }

    .resume-preview {
        padding: 0;
    }
}