/* /static/css/resume_builder_premium.css */

:root {
    --primary: #0F172A;
    --accent: #2563EB;
    --success: #10B981;
    --bg-color: #F8FAFC;
    --panel-bg: rgba(255, 255, 255, 0.85);
    --border: rgba(15, 23, 42, 0.1);
    --text-main: #334155;
    --text-muted: #64748B;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body.builder-body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #f8fafc;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ================= HEADER ================= */
.builder-header {
    height: 60px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo-text {
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--primary);
    text-decoration: none;
}

.logo-text span {
    color: var(--accent);
}

.resume-title-editor {
    display: flex;
    align-items: center;
    gap: 5px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 10px;
    transition: var(--transition);
}

.resume-title-editor:hover, .resume-title-editor:focus-within {
    border-color: var(--accent);
}

.resume-title-editor input {
    border: none;
    outline: none;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
    width: 150px;
}

.resume-title-editor i {
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
}

.save-status {
    font-size: 0.8rem;
    color: var(--success);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.header-center {
    display: flex;
    justify-content: center;
}

.ats-score-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    border: 1px solid var(--border);
    padding: 6px 16px;
    border-radius: 30px;
    box-shadow: var(--shadow);
}

.ats-score-badge .score-value {
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--primary);
}

.ats-score-badge .score-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.score-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.score-indicator.red { background-color: #EF4444; }
.score-indicator.yellow { background-color: #F59E0B; }
.score-indicator.green { background-color: #10B981; }

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.nav-btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    border: 1px solid var(--border);
    background: white;
    color: var(--text-main);
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-btn:hover {
    background: #f1f5f9;
}

.nav-btn.primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.nav-btn.primary:hover {
    background: #1d4ed8;
}

.user-menu {
    font-size: 1.5rem;
    color: var(--primary);
    cursor: pointer;
}

/* ================= WORKSPACE ================= */
.builder-workspace {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr) 300px;
    grid-template-rows: minmax(0, 1fr);
    flex: 1;
    height: 0;
    min-height: 0;
    overflow: hidden;
    width: 100vw;
    max-width: 100vw;
}

.panel {
    background: var(--panel-bg);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
}

.panel-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
}

.panel-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

.scrollable {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    min-height: 0;
}

.scrollable::-webkit-scrollbar {
    width: 6px;
}
.scrollable::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 10px;
}

/* LEFT PANEL */
.panel-left {
    border-right: 1px solid var(--border);
    box-shadow: 2px 0 15px rgba(0,0,0,0.02);
    z-index: 10;
}

.editor-section {
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 15px;
    overflow: hidden;
    transition: var(--transition);
}

.section-head {
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    background: #f8fafc;
}

.section-head h3 {
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--primary);
}

.section-head h3 i {
    color: var(--accent);
}

.section-body {
    display: none;
    padding: 15px;
    border-top: 1px solid var(--border);
}

.editor-section.active .section-body {
    display: block;
}

.editor-section.active .section-head {
    border-bottom: 1px solid var(--border);
}

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.form-group input, .form-group textarea, .form-group select {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
    background: #f8fafc;
}

.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    border-color: var(--accent);
    background: white;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.helper-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.ai-assist-box {
    margin-bottom: 15px;
}

.ai-btn {
    width: 100%;
    padding: 8px;
    background: linear-gradient(135deg, #8b5cf6, #3b82f6);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: var(--transition);
}

.ai-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.add-item-btn {
    width: 100%;
    padding: 10px;
    background: transparent;
    border: 1px dashed var(--accent);
    color: var(--accent);
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
    transition: var(--transition);
}

.add-item-btn:hover {
    background: rgba(37, 99, 235, 0.05);
}

/* Photo Upload */
.photo-upload-area {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    margin: 0 auto 20px;
    position: relative;
    cursor: pointer;
    overflow: hidden;
    border: 2px dashed var(--border);
}

.photo-upload-area img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.upload-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
}

.photo-upload-area:hover .upload-overlay {
    opacity: 1;
}

/* Sortable Items */
.sortable-item {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 10px;
    cursor: grab;
    position: relative;
}

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

.item-header {
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
}

.item-delete {
    color: #ef4444;
    cursor: pointer;
}

/* CENTER PANEL */
.panel-center {
    background: transparent;
    position: relative;
    display: flex;
    flex-direction: column;
}

.preview-toolbar {
    position: absolute;
    top: 20px;
    right: 30px;
    background: white;
    border-radius: 30px;
    box-shadow: var(--shadow);
    padding: 5px 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 10;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    transition: color 0.2s;
}

.icon-btn:hover {
    color: var(--accent);
}

.preview-wrapper {
    flex: 1;
    overflow: auto;
    padding: 40px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-width: 0;
    width: 100%;
}

/* Resume Document Container (A4) */
.resume-document {
    width: 210mm;
    min-height: 297mm;
    background: white;
    box-shadow: 0 15px 40px rgba(0,0,0,0.1);
    transform-origin: top center;
    transition: transform 0.2s;
    position: relative;
}

/* RIGHT PANEL */
.panel-right {
    border-left: 1px solid var(--border);
    box-shadow: -2px 0 15px rgba(0,0,0,0.02);
    z-index: 10;
}

.settings-group {
    margin-bottom: 25px;
}

.settings-group h3 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 15px;
    color: var(--primary);
}

.template-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.template-thumb {
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 5px;
    cursor: pointer;
    text-align: center;
    transition: var(--transition);
}

.template-thumb:hover {
    border-color: #cbd5e1;
}

.template-thumb.active {
    border-color: var(--accent);
    background: rgba(37, 99, 235, 0.05);
}

.thumb-img {
    height: 60px;
    border-radius: 4px;
    margin-bottom: 5px;
    border: 1px solid #e2e8f0;
}

.template-thumb span {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.color-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.color-swatch {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s;
}

.color-swatch:hover {
    transform: scale(1.1);
}

.color-swatch.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px white inset;
}

.font-size-controls {
    margin-top: 15px;
}

.font-size-controls input[type="range"] {
    width: 100%;
    margin-top: 8px;
}

/* ATS Analysis */
.ats-breakdown {
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px;
}

.ats-item {
    font-size: 0.85rem;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.ats-item:last-child { margin-bottom: 0; }
.text-green { color: var(--success); }
.text-red { color: #ef4444; }
.text-yellow { color: #f59e0b; }

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(5px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 500px;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

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

.modal-header h2 {
    font-size: 1.2rem;
    color: var(--primary);
}

.close-modal {
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-muted);
}

.modal-body {
    padding: 20px;
}

.ai-generate-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #8b5cf6, #3b82f6);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    margin-top: 10px;
}

.ai-result-box {
    margin-top: 20px;
    padding: 15px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.apply-btn {
    margin-top: 10px;
    padding: 8px 15px;
    background: var(--success);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}

/* Template Specific CSS will be injected into the preview, but some globals are needed */
.resume-document * {
    box-sizing: border-box;
}

/* Skill Tags */
.skill-tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.skill-tag {
    background: #e2e8f0;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

.skill-tag i {
    cursor: pointer;
    color: #64748b;
}

.skill-tag i:hover {
    color: #ef4444;
}

@media (max-width: 1024px) {
    body.builder-body {
        height: auto !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }
    
    .builder-workspace {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        width: 100vw !important;
        max-width: 100vw !important;
        overflow: visible !important;
    }
    
    .panel {
        width: 100vw !important;
        max-width: 100vw !important;
        height: auto !important;
        position: static !important;
        border: none !important;
        border-bottom: 1px solid var(--border) !important;
    }
    
    .panel-left { order: 1; border-right: none !important; }
    .panel-right { order: 2; border-left: none !important; }
    .panel-center { 
        order: 3; 
        min-height: 800px !important;
        border-bottom: none !important;
    }
    
    .scrollable {
        overflow-y: visible !important;
        padding: 15px !important;
    }
    
    .preview-wrapper {
        padding: 20px 10px !important;
        overflow-x: auto !important;
        justify-content: flex-start !important;
        -webkit-overflow-scrolling: touch;
        width: 100vw !important;
        box-sizing: border-box !important;
    }
    
    .preview-toolbar {
        position: static !important;
        margin: 15px auto !important;
        justify-content: center !important;
        width: max-content !important;
        box-shadow: 0 4px 15px rgba(0,0,0,0.1) !important;
    }
}

@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    .template-grid {
        grid-template-columns: 1fr 1fr;
    }
}
