/* ===========================================
   AI FEATURES CSS — Clean & Engaging
   Works with existing HTML · Green theme
   =========================================== */

/* ── Overlay ──────────────────────────────── */
.skills-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 18, 30, 0.55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    /* Push down so popup never touches site header */
    padding: 20px 20px 20px 20px;
    animation: aiFadeIn 0.2s ease;
    cursor: pointer;
}

/* ── Card ─────────────────────────────────── */
.skills-popup-card {
    background: #ffffff;
    border-radius: 20px;
    box-shadow:
        0 0 0 1px rgba(0,0,0,0.06),
        0 8px 24px rgba(0,0,0,0.08),
        0 32px 64px rgba(0,0,0,0.10);
    width: min(880px, 96vw);
    max-width: 880px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    position: relative;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    color: #ffffff;
    animation: aiSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
    cursor: default;
}

/* ── Card heading ─────────────────────────── */
.skills-popup-card h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0 0 4px 0;
    letter-spacing: -0.03em;
    color: #0f172a;
    padding: 28px 28px 0 28px;
}

/* ── Close button ─────────────────────────── */
.close-popup-btn {
    position: absolute !important;
    top: 12px !important;
    right: 12px !important;
    width: 30px !important;
    height: 30px !important;
    border-radius: 8px !important;
    background: #f1f5f9 !important;
    border: none !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.15s, transform 0.15s !important;
    font-size: 0 !important;
    color: transparent !important;
    z-index: 100 !important;
    flex-shrink: 0 !important;
}

.close-popup-btn::before {
    content: '✕' !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    color: #94a3b8 !important;
    line-height: 1 !important;
    transition: color 0.15s !important;
}

.close-popup-btn:hover { background: #fee2e2 !important; transform: scale(1.08) !important; }
.close-popup-btn:hover::before { color: #ef4444 !important; }

/* ── Tabs ─────────────────────────────────── */
.popup-tabs {
    display: flex;
    gap: 2px;
    padding: 16px 28px 0 28px;
    border-bottom: 1.5px solid #f1f5f9;
    flex-shrink: 0;
    background: #fff;
}

.tab-btn {
    padding: 10px 18px;
    background: transparent;
    border: none;
    border-bottom: 2.5px solid transparent;
    margin-bottom: -1.5px;
    font-size: 13.5px;
    font-weight: 600;
    color: #94a3b8;
    cursor: pointer;
    transition: color 0.18s, border-color 0.18s;
    white-space: nowrap;
    letter-spacing: -0.01em;
}

.tab-btn:hover { color: #10b981; }

.tab-btn.active {
    color: #059669;
    border-bottom-color: #10b981;
}

/* ── Tab content — HIDDEN by default ─────── */
.tab-content {
    display: none !important;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Only the active tab shows */
.tab-content.active {
    display: flex !important;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    animation: aiFadeIn 0.18s ease;
}

/* ── Generate tab inner layout ────────────── */
#generateTab {
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

#generateTab.active {
    display: flex !important;
}

/* Labels inside generate tab */
#generateTab > label,
#generateTab label.input-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    margin: 20px 28px 6px 28px;
    letter-spacing: 0.01em;
    text-transform: uppercase;
    font-size: 11px;
}

/* First label — less top margin since h3 is above tabs */
#generateTab > label:first-of-type {
    margin-top: 20px;
}

/* Inputs inside generate tab */
#generateTab #popupJobTitle,
#generateTab input.popup-input {
    display: block;
    width: calc(100% - 56px);
    margin: 0 28px 4px 28px;
    padding: 11px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    color: #0f172a;
    background: #fafafa;
    transition: border-color 0.18s, box-shadow 0.18s;
    box-sizing: border-box;
}

#generateTab #popupJobTitle:focus,
#generateTab input.popup-input:focus {
    outline: none;
    border-color: #10b981;
    background: #fff;
    box-shadow: 0 0 0 3.5px rgba(16,185,129,0.12);
}

/* Textarea inside generate tab */
#generateTab #popupJobDescription,
#generateTab textarea.popup-textarea {
    display: block;
    width: calc(100% - 56px);
    margin: 0 28px;
    padding: 11px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    color: #0f172a;
    background: #fafafa;
    resize: vertical;
    min-height: 130px;
    transition: border-color 0.18s, box-shadow 0.18s;
    box-sizing: border-box;
    line-height: 1.6;
    flex-shrink: 0;
}

#generateTab #popupJobDescription:focus,
#generateTab textarea.popup-textarea:focus {
    outline: none;
    border-color: #10b981;
    background: #fff;
    box-shadow: 0 0 0 3.5px rgba(16,185,129,0.12);
}

/* Results div — scrollable */
#aiResults {
    flex: 1;
    overflow-y: auto;
    padding: 16px 28px;
    min-height: 0;
}

/* Job desc popup results */
#jobDescResults {
    flex: 1;
    overflow-y: auto;
    padding: 16px 28px;
    min-height: 0;
}

/* Library tab inner */
#libraryTab {
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

#libraryTab.active {
    display: flex !important;
}

/* Library steps — hidden by default */
.library-step {
    display: none !important;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.library-step.active {
    display: flex !important;
}

/* ── Step label — fix alignment & color ──── */
.library-step h4,
[id^="libraryStep"] h4,
.step-label {
    font-size: 11px !important;
    font-weight: 800 !important;
    letter-spacing: 0.08em !important;
    text-transform: uppercase !important;
    color: #64748b !important;
    margin: 16px 0 12px 0 !important;
    padding: 0 28px !important;          /* matches card side padding */
    border: none !important;
    background: none !important;
    display: block !important;
}

/* Also catch any raw text nodes wrapped in a <p> acting as step label */
#librarySummariesResults > p:first-child,
#librarySkillsResults > p:first-child,
#libraryBulletsResults > p:first-child,
[id^="libraryStep"] > p:first-child {
    font-size: 11px !important;
    font-weight: 800 !important;
    letter-spacing: 0.08em !important;
    text-transform: uppercase !important;
    color: #64748b !important;
    padding: 0 28px !important;
    margin: 0 0 12px 0 !important;
}

/* ── Job desc popup — section title alignment  */
#jobDescPopup .section-title,
#jobDescPopup .library-section .section-title,
#jobDescPopup .section-header {
    padding-left: 0 !important;   /* already inside padded container */
}

/* The job-title group label (e.g. "RTYRTY") inside library */
#libraryBulletsResults .library-section .section-header {
    padding: 0 !important;
    margin-bottom: 12px !important;
}

/* Scrollable containers — consistent 28px side padding */
#aiResults,
#jobDescResults,
#librarySummariesResults,
#librarySkillsResults,
#libraryBulletsResults {
    flex: 1;
    overflow-y: auto;
    padding: 16px 28px !important;
    min-height: 0;
}

/* "For: [title]" subtitle under job desc popup heading */
#currentJobTitleDisplay,
#jobDescPopup .popup-subtitle {
    font-size: 13px !important;
    color: #64748b !important;
    font-weight: 400 !important;
    padding: 4px 28px 0 28px !important;
    margin: 0 !important;
    display: block !important;
}
#librarySummariesResults,
#librarySkillsResults,
#libraryBulletsResults {
    flex: 1;
    overflow-y: auto;
    padding: 16px 28px;
    min-height: 0;
}

/* Library steps */
.library-step { display: none; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
.library-step.active { display: flex; }

/* ── Step label ───────────────────────────── */
.step-label,
/* Also style the uppercase text labels already in the HTML */
#generateTab > p,
#libraryTab > p {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #10b981;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 28px;
    margin: 16px 0 0 0;
}

/* ── Action bar ───────────────────────────── */
.action-buttons {
    display: flex;
    gap: 10px;
    padding: 16px 28px;
    border-top: 1.5px solid #f1f5f9;
    background: #fafafa;
    border-radius: 0 0 20px 20px;
    flex-shrink: 0;
}

.action-buttons button { flex: 1; }

/* ── Generate button (primary-btn full width) */
#generateSummarySkillsBtn,
#generateJobDescBtn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: calc(100% - 56px);
    margin: 16px 28px;
    padding: 13px 24px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    border: none;
    border-radius: 11px;
    font-size: 14.5px;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: -0.01em;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(16,185,129,0.2), 0 6px 20px rgba(16,185,129,0.12);
    flex-shrink: 0;
    box-sizing: border-box;
    line-height: 1;                   /* prevent icon/text vertical drift */
    vertical-align: middle;
}

#generateSummarySkillsBtn svg,
#generateJobDescBtn svg,
#generateSummarySkillsBtn .ai-icon,
#generateJobDescBtn .ai-icon {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 18px !important;
    height: 18px !important;
    flex-shrink: 0 !important;
    position: relative !important;
    top: 0 !important;               /* reset any inherited offset */
    vertical-align: middle !important;
}

#generateSummarySkillsBtn:hover:not(:disabled),
#generateJobDescBtn:hover:not(:disabled) {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16,185,129,0.28), 0 10px 28px rgba(16,185,129,0.15);
}

#generateSummarySkillsBtn:disabled,
#generateJobDescBtn:disabled {
    background: #e2e8f0;
    color: #94a3b8;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* ── Primary / secondary buttons ─────────── */
.primary-btn,
.btn-apply {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: -0.01em;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(16,185,129,0.2);
}

.primary-btn:hover:not(:disabled),
.btn-apply:hover:not(:disabled) {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(16,185,129,0.3);
}

.primary-btn:disabled,
.btn-apply:disabled {
    background: #e2e8f0;
    color: #94a3b8;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.secondary-btn,
.btn-cancel {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 20px;
    background: #fff;
    color: #475569;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
}

.secondary-btn:hover,
.btn-cancel:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    color: #0f172a;
}

/* ── Justified text — ALL screens ────────── */
.item-content,
.summary-card p,
.bullets-options .item-content {
    font-size: 12.5px !important;
    line-height: 1.65 !important;
    text-align: justify !important;
    text-justify: inter-word !important;
    hyphens: auto !important;
    -webkit-hyphens: auto !important;
    word-break: break-word !important;
}

.summary-card {
    background: #fafafa;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.summary-card:hover {
    border-color: #6ee7b7;
    background: #f7fffe;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16,185,129,0.1);
}

.summary-card.selected {
    border-color: #10b981;
    background: #f0fdf4;
    box-shadow: 0 0 0 3px rgba(16,185,129,0.12);
}

.summary-card input[type="radio"] {
    display: none !important;
}

.summary-card p {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.65;
    color: #1e293b;
}

/* ── Skills grid ──────────────────────────── */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 9px;
}

/* ── Skill chip ───────────────────────────── */
.skill-item {
    background: #fafafa;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 13px;
    cursor: pointer;
    transition: all 0.18s ease;
    display: flex;
    align-items: center;
    gap: 9px;
    user-select: none;
}

.skill-item:hover {
    border-color: #6ee7b7;
    background: #f0fdf4;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(16,185,129,0.1);
}

.skill-item.selected {
    border-color: #10b981;
    background: #f0fdf4;
    box-shadow: 0 0 0 2.5px rgba(16,185,129,0.18);
}

.skill-check {
    width: 18px;
    height: 18px;
    min-width: 18px;
    border-radius: 5px;
    border: 2px solid #cbd5e1;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.18s;
    flex-shrink: 0;
}

.skill-item.selected .skill-check {
    background: #10b981;
    border-color: #10b981;
}

.skill-item.selected .skill-check::after {
 
    display: block;
    width: 9px;
    height: 5px;
    border-left: 2.5px solid #fff;
    border-bottom: 2.5px solid #fff;
    transform: rotate(-45deg) translateY(-1px);
}

.skill-item input[type="checkbox"] { display: none !important; }
.skill-item label { display: contents; pointer-events: none; }

.skill-text {
    font-size: 13px;
    font-weight: 500;
    color: #1e293b;
    line-height: 1.3;
}

.skill-item.selected .skill-text { color: #065f46; font-weight: 600; }

/* ── Library items ────────────────────────── */
.library-section { margin-bottom: 24px; }

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1.5px solid #f1f5f9;
}

.section-title {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #64748b;
    margin: 0;
}

.section-count {
    font-size: 11px;
    font-weight: 700;
    color: #059669;
    background: #dcfce7;
    padding: 3px 10px;
    border-radius: 20px;
}

.library-items { display: flex; flex-direction: column; gap: 8px; }

.library-item {
    background: #fafafa;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.library-item:hover {
    border-color: #6ee7b7;
    background: #f7fffe;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16,185,129,0.08);
}

.library-item.selected {
    border-color: #10b981;
    background: #f0fdf4;
    box-shadow: 0 0 0 3px rgba(16,185,129,0.12);
}

.item-content {
    font-size: 13.5px;
    line-height: 1.65;
    color: #1e293b;
    margin-bottom: 8px;
}

.item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11.5px;
    color: #94a3b8;
}

.usage-count {
    background: #eff6ff;
    color: #2563eb;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 11px;
}

.item-date { margin-left: auto; }

/* ── Loading ──────────────────────────────── */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 52px 24px;
    gap: 14px;
    color: #64748b;
    font-size: 14px;
    font-weight: 500;
}

.loading-spinner {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid #e2e8f0;
    border-top-color: #10b981;
    animation: aiSpin 0.75s linear infinite;
}

/* ── Empty state ──────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
}

.empty-icon {
    font-size: 40px;
    margin-bottom: 14px;
    opacity: 0.5;
    display: block;
}

.empty-title {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 8px;
}

.empty-description {
    font-size: 13.5px;
    color: #94a3b8;
    line-height: 1.6;
    margin: 0;
    max-width: 280px;
}

/* ── Error ────────────────────────────────── */
.error-message {
    background: #fef2f2;
    border: 1.5px solid #fca5a5;
    color: #dc2626;
    padding: 14px 16px;
    border-radius: 10px;
    font-size: 13.5px;
    line-height: 1.5;
}

/* ── Gold AI trigger buttons ──────────────── */
.ai-btn-base,
.ai-fill-btn,
.ai-fill-btn-sm,
.ai-btn-large,
.ai-btn-pulse,
.ai-btn-tooltip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    height: 36px;
    background: linear-gradient(135deg, #d4af37, #fbbf24);
    color: #0f172a;
    border: 1px solid rgba(212,175,55,0.4);
    border-radius: 8px;
    font-weight: 700;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(212,175,55,0.2);
    transition: all 0.18s ease;
    position: relative;
    overflow: hidden;
}

.ai-btn-large { padding: 10px 18px; height: 42px; font-size: 14px; }
.ai-btn-pulse { animation: none; }

.ai-btn-base:hover:not(:disabled),
.ai-fill-btn:hover:not(:disabled),
.ai-fill-btn-sm:hover:not(:disabled),
.ai-btn-large:hover:not(:disabled) {
    background: linear-gradient(135deg, #b08c2a, #d4af37);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(212,175,55,0.3);
}

.ai-btn-base:disabled,
.ai-fill-btn:disabled,
.ai-fill-btn-sm:disabled,
.ai-btn-large:disabled {
    background: #e2e8f0;
    border-color: #e2e8f0;
    color: #94a3b8;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.ai-icon {
    width: 15px;
    height: 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-icon svg { width: 100%; height: 100%; stroke: currentColor; fill: none; stroke-width: 2.5; }

/* ── Add button ───────────────────────────── */
.add-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 20px;
    width: 100%;
    background: #fff;
    color: #059669;
    border: 1.5px dashed #6ee7b7;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    margin-top: 16px;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.add-btn:hover {
    background: #f0fdf4;
    border-color: #10b981;
    border-style: solid;
    color: #047857;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(16,185,129,0.12);
}

/* ── Textarea with AI btn ─────────────────── */
.textarea-with-ai { position: relative; }
.textarea-with-ai textarea { padding-right: 100px; }
.textarea-with-ai .ai-fill-btn-sm { position: absolute; top: 11px; right: 11px; }

/* ── Toast ────────────────────────────────── */
.ai-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #0f172a;
    color: #fff;
    padding: 13px 18px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2), 0 0 0 1px rgba(255,255,255,0.06) inset;
    z-index: 10001;
    font-size: 13.5px;
    font-weight: 600;
    border-left: 3px solid #10b981;
    animation: aiToastIn 0.3s cubic-bezier(0.16,1,0.3,1), aiToastOut 0.25s ease 2.75s forwards;
    pointer-events: none;
    max-width: 320px;
}

.toast-content { display: flex; align-items: center; gap: 10px; }

/* ── Simple message popup ─────────────────── */
.simple-message-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10,18,30,0.5);
    backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10002;
    animation: aiFadeIn 0.2s ease;
    padding: 16px;
}

.simple-message-popup {
    background: #fff;
    border-radius: 16px;
    max-width: 380px;
    width: 100%;
    box-shadow: 0 20px 50px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.06);
    animation: aiScaleIn 0.25s cubic-bezier(0.16,1,0.3,1);
    overflow: hidden;
}

.simple-message-header {
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
    padding: 20px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.simple-message-header h4 { margin: 0; font-size: 17px; font-weight: 700; }
.simple-message-icon { font-size: 22px; }

.simple-message-body { padding: 20px 22px 8px; }

.simple-message-body p {
    margin: 0;
    font-size: 14px;
    line-height: 1.65;
    color: #475569;
    text-align: center;
}

.simple-message-actions { padding: 14px 22px 20px; }

.simple-ok-btn {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 12px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(16,185,129,0.2);
}

.simple-ok-btn:hover {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(16,185,129,0.3);
}

/* ── Spacing between results ──────────────── */
#aiResults,
#jobDescResults,
#librarySummariesResults,
#librarySkillsResults,
#libraryBulletsResults {
    flex: 1;
    overflow-y: auto;
    padding: 20px 28px !important;
    min-height: 0;
}

.summary-options { gap: 14px; }
.library-items   { gap: 12px; }
.bullets-options { display: flex; flex-direction: column; gap: 12px; }

/* Margin between each AI result card */
.summary-options .summary-card + .summary-card {
    margin-top: 4px;
}
#aiResults::-webkit-scrollbar,
#jobDescResults::-webkit-scrollbar,
#librarySummariesResults::-webkit-scrollbar,
#librarySkillsResults::-webkit-scrollbar,
#libraryBulletsResults::-webkit-scrollbar { width: 5px; }

#aiResults::-webkit-scrollbar-track,
#jobDescResults::-webkit-scrollbar-track,
#librarySummariesResults::-webkit-scrollbar-track,
#librarySkillsResults::-webkit-scrollbar-track,
#libraryBulletsResults::-webkit-scrollbar-track { background: transparent; }

#aiResults::-webkit-scrollbar-thumb,
#jobDescResults::-webkit-scrollbar-thumb,
#librarySummariesResults::-webkit-scrollbar-thumb,
#librarySkillsResults::-webkit-scrollbar-thumb,
#libraryBulletsResults::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}

/* ── Animations ───────────────────────────── */
@keyframes aiFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes aiSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

@keyframes aiSpin { to { transform: rotate(360deg); } }

@keyframes aiToastIn {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

@keyframes aiToastOut {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(8px); }
}

@keyframes aiScaleIn {
    from { transform: scale(0.92); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

/* ── Mobile ≤ 640px ───────────────────────── */
@media (max-width: 640px) {
    .skills-popup-overlay {
        padding: 12px 12px 12px 12px;  /* top offset clears header */
        align-items: center;            /* vertically centered */
        justify-content: center;
    }

    .skills-popup-card {
        width: 100%;
        max-width: 100%;
        max-height: calc(100vh - 80px);
        border-radius: 16px;
    }

    /* Smaller font on mobile for items */
    .item-content {
        font-size: 12.5px !important;
        line-height: 1.7 !important;
    }

    .summary-card p {
        font-size: 12.5px !important;
        line-height: 1.7 !important;
    }

    /* Skill text */
    .skill-text { font-size: 12px !important; }

    /* Section count badge */
    .section-count { font-size: 11px !important; }

    .skills-popup-card h3 { padding: 22px 18px 0; font-size: 1.1rem; }

    .popup-tabs { padding: 12px 18px 0; overflow-x: auto; scrollbar-width: none; }
    .popup-tabs::-webkit-scrollbar { display: none; }
    .tab-btn { padding: 10px 14px; font-size: 13px; flex-shrink: 0; }

    #generateTab > label,
    #generateTab label.input-label { margin: 16px 18px 6px; }

    #generateTab #popupJobTitle,
    #generateTab input.popup-input {
        width: calc(100% - 36px);
        margin: 0 18px 4px;
    }

    #generateTab #popupJobDescription,
    #generateTab textarea.popup-textarea {
        width: calc(100% - 36px);
        margin: 0 18px;
        font-size: 16px;
        min-height: 100px;
    }

    #generateSummarySkillsBtn,
    #generateJobDescBtn {
        width: calc(100% - 36px);
        margin: 14px 18px;
    }

    #aiResults,
    #jobDescResults,
    #librarySummariesResults,
    #librarySkillsResults,
    #libraryBulletsResults { padding: 14px 18px; }

    .skills-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .skill-item { padding: 9px 10px; }
    .skill-text { font-size: 12px; }

    .action-buttons {
        padding: 14px 18px;
        flex-direction: column-reverse;
        border-radius: 0;
    }

    .primary-btn, .btn-apply,
    .secondary-btn, .btn-cancel { width: 100%; }

    .ai-toast { bottom: 12px; right: 12px; left: 12px; max-width: none; }
}

/* ── Tablet 641–900px ─────────────────────── */
@media (min-width: 641px) and (max-width: 900px) {
    .skills-popup-card { width: min(700px, 96vw); }
    .skills-grid { grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); }
}


/* FIND this block at the bottom of ai-features.css: */
.ai-section-btn {
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    padding: 10px 18px !important;
    margin-top: 16px !important;
    background: linear-gradient(135deg, #0f172a, #1e293b) !important;
    color: #34d399 !important;
    border: 1px solid rgba(52, 211, 153, 0.2) !important;
    border-radius: 10px !important;
    font-size: 13.5px !important;
    font-weight: 700 !important;
    height: 38px !important;
    cursor: pointer !important;
    font-family: inherit !important;
    letter-spacing: -0.01em !important;
    box-shadow: 0 2px 10px rgba(15,23,42,0.25) !important;
    transition: all 0.2s ease !important;
}

.ai-section-btn:hover {
    border-color: rgba(52, 211, 153, 0.45) !important;
    box-shadow: 0 4px 16px rgba(15,23,42,0.3), 0 0 20px rgba(52,211,153,0.1) !important;
    transform: translateY(-1px) !important;
}

.ai-section-btn svg {
    stroke: currentColor !important;
    flex-shrink: 0 !important;
}


/* REPLACE with this: */
@keyframes aiShimmer {
    0%   { background-position: 200% center; }
    100% { background-position: -200% center; }
}

@keyframes aiPulseGlow {
    0%, 100% { box-shadow: 0 2px 10px rgba(15,23,42,0.25), 0 0 0px rgba(52,211,153,0); }
    50%       { box-shadow: 0 2px 10px rgba(15,23,42,0.25), 0 0 14px rgba(52,211,153,0.22); }
}

.ai-section-btn {
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    padding: 10px 18px !important;
    margin-top: 16px !important;
    background: linear-gradient(
        270deg,
        #0f172a 0%,
        #1e293b 30%,
        #0d2818 50%,
        #1e293b 70%,
        #0f172a 100%
    ) !important;
    background-size: 300% 100% !important;
    animation: aiShimmer 4s linear infinite, aiPulseGlow 2.8s ease-in-out infinite !important;
    color: #34d399 !important;
    border: 1px solid rgba(52, 211, 153, 0.2) !important;
    border-radius: 10px !important;
    font-size: 13.5px !important;
    font-weight: 700 !important;
    height: 38px !important;
    cursor: pointer !important;
    font-family: inherit !important;
    letter-spacing: -0.01em !important;
    transition: border-color 0.2s ease, transform 0.2s ease !important;
    position: relative !important;
    overflow: hidden !important;
}

/* Moving green sparkle sweep */
.ai-section-btn::before {
    content: '' !important;
    position: absolute !important;
    top: 0 !important; left: -100% !important;
    width: 60% !important; height: 100% !important;
    background: linear-gradient(
        120deg,
        transparent 0%,
        rgba(52, 211, 153, 0.07) 40%,
        rgba(52, 211, 153, 0.13) 50%,
        rgba(52, 211, 153, 0.07) 60%,
        transparent 100%
    ) !important;
    animation: aiSweep 3s ease-in-out infinite !important;
    pointer-events: none !important;
}

@keyframes aiSweep {
    0%   { left: -60%; }
    60%  { left: 140%; }
    100% { left: 140%; }
}

.ai-section-btn:hover {
    border-color: rgba(52, 211, 153, 0.5) !important;
    transform: translateY(-1px) !important;
    animation: aiPulseGlow 1.2s ease-in-out infinite !important;
}

.ai-section-btn svg {
    stroke: currentColor !important;
    flex-shrink: 0 !important;
    position: relative !important;
    z-index: 1 !important;
}

/* Keep text above the shimmer layer */
.ai-section-btn span,
.ai-section-btn > * {
    position: relative !important;
    z-index: 1 !important;
}

/* ===========================================
   STREAMING UI — Progress Bar, Typing, Skeletons
   Add this to the BOTTOM of ai-features.css
   =========================================== */

/* ── Progress bar wrapper ─────────────────── */
.stream-progress-wrapper {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f1f5f9;
}

/* Track */
.stream-progress-bar-track {
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    border-radius: 20px;
    overflow: hidden;
}

/* Fill — animated green bar */
.stream-progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #10b981, #34d399, #10b981);
    background-size: 200% 100%;
    border-radius: 20px;
    transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
    animation: streamBarShimmer 2s linear infinite;
}

@keyframes streamBarShimmer {
    0%   { background-position: 200% center; }
    100% { background-position: -200% center; }
}

/* Label below bar */
.stream-progress-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    font-size: 12.5px;
    font-weight: 600;
    color: #64748b;
    letter-spacing: -0.01em;
}

.stream-progress-label.stream-progress-done {
    color: #059669;
    font-weight: 700;
}

/* Mini spinner */
.stream-progress-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #e2e8f0;
    border-top-color: #10b981;
    border-radius: 50%;
    animation: aiSpin 0.7s linear infinite;
    flex-shrink: 0;
}

/* ── Skeleton card ────────────────────────── */
.summary-card.stream-skeleton {
    opacity: 0.45;
    pointer-events: none;
    background: #fafafa;
    border-color: #e2e8f0;
}

.summary-card.stream-skeleton .skeleton-line {
    display: block;
    height: 13px;
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    border-radius: 6px;
    margin-bottom: 9px;
    animation: streamShimmer 1.8s ease-in-out infinite;
}

.summary-card.stream-skeleton .skeleton-line:last-child {
    margin-bottom: 0;
}

@keyframes streamShimmer {
    0%   { background-position: 200% center; }
    100% { background-position: -200% center; }
}

/* ── Typing card ──────────────────────────── */
.summary-card.stream-typing {
    opacity: 1;
    pointer-events: none;
    border-color: #6ee7b7;
    background: linear-gradient(135deg, #f0fdf4, #fafafa);
    box-shadow: 0 0 0 3px rgba(16,185,129,0.08);
    animation: streamFadeIn 0.3s ease forwards;
}

@keyframes streamFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0);   }
}

/* Blinking cursor */
.stream-cursor {
    display: inline-block;
    width: 2px;
    height: 15px;
    background: #10b981;
    margin-left: 1px;
    vertical-align: text-bottom;
    animation: streamBlink 0.6s step-end infinite;
    border-radius: 1px;
}

@keyframes streamBlink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0; }
}

.summary-card.stream-typing p {
    font-size: 13.5px !important;
    line-height: 1.65 !important;
    color: #1e293b;
    margin: 0;
    word-break: break-word;
}

/* ── Completed card ───────────────────────── */
.summary-card.stream-complete {
    opacity: 1;
    pointer-events: auto;
    cursor: pointer;
    animation: streamCompleteIn 0.3s ease forwards;
}

@keyframes streamCompleteIn {
    from { opacity: 0.7; transform: scale(0.99); }
    to   { opacity: 1;   transform: scale(1);    }
}

/* ── Streaming card container ─────────────── */
#streamingSummaries {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ── Card entrance (Back from skills) ─────── */
.summary-card.stream-card-entrance {
    opacity: 0;
    transform: translateY(8px);
    animation: streamCardEntrance 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes streamCardEntrance {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0)   scale(1);    }
}

/* ── Mobile ───────────────────────────────── */
@media (max-width: 640px) {
    .stream-progress-wrapper {
        margin-bottom: 14px;
        padding-bottom: 12px;
    }

    .stream-progress-label {
        font-size: 11.5px;
    }

    .summary-card.stream-typing p {
        font-size: 12.5px !important;
    }

    .stream-cursor {
        height: 13px;
    }
}


/* ===========================================================
   POPUP REFINEMENTS  (consolidated)
   Single source of truth for the AI Summary/Skills + Library
   popup layout. Replaces the earlier stacked patches — every
   selector appears once. Horizontal spacing is driven by the
   --ai-gutter token: change it in one place to retune the
   whole popup.
   =========================================================== */

/* ── Gutter token ─────────────────────────────────────────── */
.skills-popup-card { --ai-gutter: 28px; }                       /* desktop: comfortable */
@media (max-width: 640px) { .skills-popup-card { --ai-gutter: 0px; } }  /* phone: edge-to-edge */

/* ── Card: hug content, grow & scroll only when tall ──────── */
.skills-popup-card {
    height: auto !important;
    min-height: 0 !important;
}
@media (max-width: 640px) {
    .skills-popup-card { max-height: calc(100dvh - 24px) !important; }
    .skills-popup-card h3 { padding-top: 18px !important; }
}

/* ── Tab + step wrappers hug content (no dead stretch) ────── */
.tab-content,
.tab-content.active,
#generateTab,
#generateTab.active,
#libraryTab,
#libraryTab.active,
.library-step,
.library-step.active {
    flex: 0 1 auto !important;
    min-height: 0 !important;
}

/* ── Heading + tabs: slim gutter, tidy top rhythm ─────────── */
.skills-popup-card h3 { padding: 24px var(--ai-gutter) 8px !important; }
.popup-tabs           { padding: 16px var(--ai-gutter) 0 !important; }
.tab-btn:first-child  { padding-left: 0 !important; }   /* align 1st tab with heading */

/* ── Section / step labels: flush at the gutter ───────────── */
#generateTab > p,
#libraryTab > p,
.step-label,
.library-step h4,
[id^="libraryStep"] h4 {
    margin: 22px 0 14px !important;
    padding: 0 var(--ai-gutter) !important;
    display: block !important;
}
#currentJobTitleDisplay,
#jobDescPopup .popup-subtitle {
    padding: 0 var(--ai-gutter) !important;
}

/* ── Field labels ─────────────────────────────────────────── */
#generateTab > label,
#generateTab label.input-label {
    margin: 22px var(--ai-gutter) 10px !important;
}

/* ── Inputs, textarea, primary buttons: full width − gutter ─ */
#generateTab #popupJobTitle,
#generateTab input.popup-input,
#generateTab #popupJobDescription,
#generateTab textarea.popup-textarea,
#generateSummarySkillsBtn,
#generateJobDescBtn {
    width: calc(100% - (var(--ai-gutter) * 2)) !important;
    margin-left: var(--ai-gutter) !important;
    margin-right: var(--ai-gutter) !important;
    box-sizing: border-box !important;
}

/* ── Job-description box: taller + reclaim reserved right gap ─ */
#generateTab #popupJobDescription,
#generateTab textarea.popup-textarea {
    min-height: 185px !important;
    padding-right: 14px !important;
}
@media (max-width: 640px) {
    /* gutter is 0 on phones, so trim the field's inner left padding too —
       keeps the input text aligned with the flush labels */
    #generateTab #popupJobTitle,
    #generateTab input.popup-input,
    #generateTab #popupJobDescription,
    #generateTab textarea.popup-textarea {
        padding-left: 4px !important;
    }
    #generateTab #popupJobDescription,
    #generateTab textarea.popup-textarea { min-height: 150px !important; }
}

/* Optional textarea wrapper (harmless if not present in markup) */
#generateTab .textarea-with-ai {
    display: block !important;
    width: calc(100% - (var(--ai-gutter) * 2)) !important;
    margin-left: var(--ai-gutter) !important;
    margin-right: var(--ai-gutter) !important;
}
#generateTab .textarea-with-ai textarea {
    width: 100% !important;
    margin: 0 !important;
    padding-right: 14px !important;
}

/* ── Generate button: compact 32px bar ────────────────────── */
#generateSummarySkillsBtn,
#generateJobDescBtn {
    height: 32px !important;
    min-height: 32px !important;
    margin-top: 24px !important;
    margin-bottom: 22px !important;
    padding: 0 22px !important;
    font-size: 14px !important;
    line-height: 1 !important;
}

/* ── Scrollable result areas: scroll when long, collapse empty ─ */
#aiResults,
#jobDescResults,
#librarySummariesResults,
#librarySkillsResults,
#libraryBulletsResults {
    flex: 0 1 auto !important;
    max-height: min(54vh, 500px) !important;
    overflow-y: auto !important;
    min-height: 0 !important;
    padding-left: var(--ai-gutter) !important;
    padding-right: var(--ai-gutter) !important;
}
@media (max-width: 640px) {
    #aiResults,
    #jobDescResults,
    #librarySummariesResults,
    #librarySkillsResults,
    #libraryBulletsResults {
        max-height: min(48vh, 420px) !important;
        padding-top: 14px !important;
        padding-bottom: 14px !important;
    }
}
#aiResults:empty,
#jobDescResults:empty,
#librarySummariesResults:empty,
#librarySkillsResults:empty,
#libraryBulletsResults:empty {
    max-height: 0 !important;
    min-height: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    overflow: hidden !important;
}

/* ── Action bar: slim gutter; hidden when it has no button ─── */
.action-buttons {
    padding-left: var(--ai-gutter) !important;
    padding-right: var(--ai-gutter) !important;
}
.action-buttons:empty,
.action-buttons:not(:has(button)) {
    display: none !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
}

/* ── Empty state: compact ─────────────────────────────────── */
.empty-state { padding: 28px 24px !important; }
@media (max-width: 640px) {
    .empty-state { padding: 22px 18px !important; }
}
/* Summary options share one headline (built from the resume): quieter, so the differences stand out */
.summary-card p .sum-head { color: #667085; }
.summary-card.selected p .sum-head { color: #475467; }
.skill-src-post { color: #B54708 !important; }
.summary-card .sum-angle { display: block; width: max-content; margin: 0 0 6px; padding: 2px 8px; border-radius: 999px; background: #F2F4F7; color: #344054; font-size: 11.5px; font-weight: 600; line-height: 16px; letter-spacing: .01em; }
.summary-card.selected .sum-angle { background: #E4E7EC; color: #101828; }
.sum-head-note { margin-top: 6px; font-size: 12.5px; line-height: 18px; color: #667085; }

/* A skill their own resume shows (pre-ticked); the others are offered for them to choose */
.skill-item .skill-src { display: block; margin-top: 2px; font-size: 10.5px; font-weight: 500; line-height: 13px; color: #0B7A53; }
