/* CSS Variables - Clean Slate Design */
:root {
    --primary: #6366F1;
    --primary-hover: #4F46E5;
    --secondary: #F8FAFC;
    --destructive: #EF4444;
    --destructive-hover: #DC2626;
    --success: #16a34a;
    --success-hover: #15803d;
    --warning: #f59e0b;
    --background: #FFFFFF;
    --surface: #F8FAFC;
    --sidebar-bg: #0F172A;
    --sidebar-text: #94A3B8;
    --sidebar-text-active: #FFFFFF;
    --sidebar-active-indicator: #6366F1;
    --text-primary: #0F172A;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;
    --border: #E2E8F0;
    --border-focus: #6366F1;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    height: 100vh;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
}

.sidebar .logo {
    padding: 0 4px 32px;
}

.sidebar .logo .logo-full {
    width: 160px;
    height: auto;
    display: block;
}

.sidebar .logo .logo-icon {
    display: none;
}

.nav-links {
    list-style: none;
    padding: 0;
    flex: 1;
}

.nav-links li {
    margin-bottom: 4px;
}

.nav-links li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.nav-links li a:hover {
    background: rgba(255, 255, 255, 0.05);
}

.nav-links li a.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--sidebar-text-active);
}

.nav-links li a svg {
    flex-shrink: 0;
}

.sidebar-build {
    padding: 12px 12px 0;
    margin-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.7rem;
    color: rgba(148, 163, 184, 0.5);
    line-height: 1.5;
}

.sidebar-build a {
    color: rgba(148, 163, 184, 0.5);
    text-decoration: none;
}

.sidebar-build a:hover {
    color: rgba(148, 163, 184, 0.8);
}

/* Main Content */
.content {
    margin-left: 240px;
    flex: 1;
    padding: 40px 48px;
    min-height: 100vh;
    background: var(--background);
}

.page {
    display: none;
    max-width: 800px;
    overflow: hidden;
}

.page.active {
    display: block;
}

/* Allow wider pages for generator (two-column) and dashboard */
#generator-page,
#tester-page,
#applications-page,
#dashboard-page {
    max-width: 100%;
}

/* Generator page: fit within viewport (only when active) */
#generator-page.active {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 80px);
    overflow: hidden;
}

#generator-page > h1 {
    flex-shrink: 0;
}

#generator-page > .role-fit-match,
#generator-page > .role-fit-warning {
    flex-shrink: 0;
}

#generator-page > .generator-layout {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

h1 {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin-bottom: 6px;
}

h1 + p,
h1 + .info-text {
    margin-bottom: 24px;
}

h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

/* Section descriptions */
.merged-profile-section p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-top: 6px;
    margin-bottom: 16px;
}

/* Form Elements */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 14px;
    color: var(--text-primary);
}

.form-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 150px;
}

input[type="text"],
input[type="url"],
input[type="file"],
textarea,
select {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #FFFFFF;
    color: var(--text-primary);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]:focus,
input[type="url"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

textarea {
    resize: vertical;
    min-height: 120px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    overflow-x: hidden;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 400;
    color: var(--text-primary);
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    accent-color: var(--primary);
}

/* Buttons */
.btn {
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

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

.btn:active {
    transform: translateY(0);
}

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

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

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

.btn-secondary:hover {
    background: var(--surface);
}

.btn-success {
    background: var(--success);
    color: #FFFFFF;
}

.btn-success:hover {
    background: var(--success-hover);
}

.btn-danger {
    background: transparent;
    color: var(--destructive);
    border: 1px solid #FECACA;
}

.btn-danger:hover {
    background: #FEF2F2;
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-large {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
}

.button-group {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    align-items: center;
}

.checkbox-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
}

/* Cards / Sections */
.card-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* Generator Layout */
.generator-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

#generator-page > .generator-layout {
    grid-template-rows: 1fr;
    align-items: stretch;
}

#generator-page > .generator-layout > .input-section,
#generator-page > .generator-layout > .output-section {
    min-height: 0;
    max-height: 100%;
}

/* Info Text */
.info-text {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 16px;
    line-height: 1.5;
}

@media (max-width: 1200px) {
    .generator-layout {
        grid-template-columns: 1fr;
    }
}

.input-section,
.output-section {
    background: var(--surface);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* Generator page sections: scroll internally, keep buttons visible */
#generator-page .input-section {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#generator-page .input-section-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

#generator-page .input-section #job-ad {
    min-height: 120px;
    max-height: 200px;
}

#generator-page .input-section > .button-group {
    flex-shrink: 0;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    margin-top: 16px;
}

#generator-page .output-section {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#generator-page .output-section .tab-content.active {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#generator-page .output-section .tab-content textarea {
    flex: 1;
    min-height: 100px;
}

#generator-page .output-section .save-section {
    flex-shrink: 0;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}

.tab-btn {
    padding: 10px 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    transition: color 0.2s ease, border-color 0.2s ease;
    margin-bottom: -1px;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.output-header h3 {
    font-size: 14px;
    font-weight: 600;
}

.analysis-box {
    background: #FFFFFF;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    white-space: pre-wrap;
    font-size: 14px;
    max-height: 400px;
    overflow-y: auto;
}

.refinement-section {
    margin-top: 16px;
    padding: 16px;
    background: #FFFFFF;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.refinement-section label {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 500;
}

.refinement-section input {
    flex: 1;
}

.save-section {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

/* Profile Layout */
.profile-tabs-container {
    background: var(--surface);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.profile-tab-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.merged-profile-section,
.preferences-section,
.profile-sources-section {
    min-width: 0;
}

/* Profile Sources Section (compact) */
.profile-sources-section h3 {
    margin-bottom: 12px;
}

.profile-sources-row {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.upload-compact {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hidden-file-input {
    display: none;
}

.upload-status-inline {
    font-size: 13px;
    color: var(--text-secondary);
}

.upload-status-inline.success {
    color: var(--success);
}

.upload-status-inline.error {
    color: var(--destructive);
}

.additional-content-compact {
    display: flex;
    flex: 1;
    gap: 8px;
    min-width: 200px;
}

.additional-content-compact input {
    flex: 1;
}

.language-compact {
    display: flex;
    align-items: center;
    gap: 8px;
}

.language-compact label {
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.language-compact select {
    padding: 8px 12px;
    font-size: 14px;
}

/* Preferences Section */
.preferences-section h3 {
    margin-bottom: 8px;
}

.preferences-section > p {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

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

.preference-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.preference-group select,
.preference-group input,
.preference-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
}

.preference-group select:focus,
.preference-group input:focus,
.preference-group textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.preference-group small {
    display: block;
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 4px;
}

/* Tag Input */
.tag-input-container {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    padding: 8px;
}

.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.tags-list:empty {
    margin-bottom: 0;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: var(--primary-light, #EEF2FF);
    color: var(--primary);
    border-radius: 4px;
    font-size: 13px;
}

.tag-remove {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--primary);
    opacity: 0.7;
    display: flex;
    align-items: center;
}

.tag-remove:hover {
    opacity: 1;
}

.tag-input-row {
    display: flex;
    gap: 8px;
}

.tag-input-row input {
    flex: 1;
    border: none;
    padding: 6px 8px;
    font-size: 14px;
    background: transparent;
}

.tag-input-row input:focus {
    outline: none;
}

.tag-input-container:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.preference-details {
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.preference-details summary {
    padding: 12px 16px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-primary);
    user-select: none;
}

.preference-details summary:hover {
    background: var(--surface);
}

.preference-details[open] summary {
    border-bottom: 1px solid var(--border);
}

.preference-content {
    padding: 16px;
}

.preferences-section .button-group {
    margin-top: 20px;
}

#preferences-status {
    margin-top: 12px;
    font-size: 14px;
}

.file-upload {
    display: flex;
    gap: 12px;
    align-items: center;
}

textarea.profile-display {
    background: #FFFFFF;
    padding: 14px 16px;
    border-radius: 8px;
    white-space: pre-wrap;
    font-size: 14px;
    min-height: 300px;
    margin-bottom: 16px;
    width: 100%;
    border: 1px solid var(--border);
    resize: vertical;
    font-family: inherit;
    line-height: 1.5;
}

textarea.profile-display:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Applications Table */
.filters-section {
    background: var(--surface);
    padding: 20px 24px;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.filters-section .form-row {
    align-items: flex-end;
}

.applications-table-container {
    background: var(--surface);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* Mobile applications list - hidden on desktop */
.applications-mobile-list {
    display: none;
}

.applications-table {
    width: 100%;
    border-collapse: collapse;
}

.applications-table th,
.applications-table td {
    padding: 14px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.applications-table th {
    background: #FFFFFF;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.applications-table tr:hover {
    background: #FFFFFF;
}

.applications-table tr:last-child td {
    border-bottom: none;
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
}

.status-applied {
    background: #EEF2FF;
    color: #4338CA;
}

.status-intro {
    background: #FEF3C7;
    color: #92400E;
}

.status-interview {
    background: #D1FAE5;
    color: #065F46;
}

.status-rejected {
    background: #FEE2E2;
    color: #991B1B;
}

.status-offer {
    background: #DCFCE7;
    color: #166534;
}

.status-withdrawn {
    background: #F3F4F6;
    color: #4B5563;
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--background);
    padding: 32px;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.close-modal {
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.15s ease;
}

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

/* Dashboard */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.stat-card h3 {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
    letter-spacing: 0;
}

.stat-value {
    font-size: 32px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.chart-card {
    background: var(--surface);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.chart-card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
}

/* Pipeline Board */
.pipeline-section {
    background: var(--surface);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.pipeline-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-top: 16px;
}

@media (max-width: 900px) {
    .pipeline-board {
        grid-template-columns: repeat(2, 1fr);
    }
}

.pipeline-column {
    background: #FFFFFF;
    border-radius: 8px;
    padding: 16px;
    min-height: 200px;
    border: 1px solid var(--border);
}

.pipeline-column h4 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.pipeline-card {
    background: var(--surface);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.pipeline-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.pipeline-card .company {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.pipeline-card .job-title {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Documents List */
.documents-list {
    display: grid;
    gap: 12px;
}

.document-card {
    background: var(--surface);
    padding: 16px 20px;
    border-radius: 12px;
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.document-info h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.document-info p {
    font-size: 13px;
    color: var(--text-secondary);
}

.document-actions {
    display: flex;
    gap: 8px;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-overlay p {
    margin-top: 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

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

/* Toast */
.toast {
    position: fixed;
    bottom: 32px;
    right: 32px;
    padding: 14px 20px;
    background: var(--text-primary);
    color: #FFFFFF;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transform: translateY(12px);
    transition: all 0.3s ease;
    z-index: 3000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--destructive);
}

/* Role Fit Match Summary */
.role-fit-match {
    background: #F0FDF4;
    border: 1px solid #86EFAC;
    border-left: 4px solid var(--success);
    border-radius: 8px;
    padding: 20px 24px;
    margin-bottom: 24px;
}

.role-fit-match h3 {
    color: var(--success);
    font-size: 16px;
    margin-bottom: 12px;
}

/* Match percentage bar */
.match-percentage-section {
    margin-bottom: 16px;
}

.match-percentage-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.match-percentage-value {
    font-size: 20px;
    font-weight: 700;
}

.match-percentage-bar {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.match-percentage-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
}

.match-percentage-fill.pct-high { background: var(--success); }
.match-percentage-fill.pct-mid  { background: var(--warning); }
.match-percentage-fill.pct-low  { background: var(--destructive); }

.match-category-text {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* Match detail sections (matches & gaps) */
.match-detail-section {
    margin-top: 12px;
}

.match-detail-heading {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
}

.match-heading {
    color: var(--success);
}

.gap-heading {
    color: #B45309;
}

.match-detail-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.match-detail-list li {
    font-size: 13px;
    padding: 4px 10px;
    border-radius: 9999px;
    background: #DCFCE7;
    color: #166534;
    font-weight: 500;
}

.match-detail-list.gap-list li {
    background: #FEF3C7;
    color: #92400E;
}

/* Role Fit Warning */
.role-fit-warning {
    background: #FEF2F2;
    border: 1px solid #FCA5A5;
    border-left: 4px solid var(--destructive);
    border-radius: 8px;
    padding: 20px 24px;
    margin-bottom: 24px;
}

.role-fit-warning h3 {
    color: var(--destructive);
    font-size: 16px;
    margin-bottom: 12px;
}

.role-fit-warning ul {
    margin: 0 0 12px 20px;
    color: #991B1B;
    font-size: 14px;
    line-height: 1.7;
}

.role-fit-category {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.role-fit-actions {
    display: flex;
    gap: 8px;
}

/* URL Fetch Input */
.url-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.url-input-row input[type="url"] {
    flex: 1;
}

.url-fetch-status {
    font-size: 13px;
    margin-top: 6px;
}

.url-fetch-status.loading { color: var(--text-secondary); }
.url-fetch-status.error { color: var(--destructive); }
.url-fetch-status.success { color: var(--success); }

.url-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 12px 0 4px;
    color: var(--text-muted);
    font-size: 13px;
}

.url-divider::before,
.url-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* Mobile hide utility */
.mobile-hide {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    /* Bottom nav bar with icons only */
    .sidebar {
        width: 100%;
        height: auto;
        position: fixed;
        bottom: 0;
        left: 0;
        top: auto;
        padding: 0;
        z-index: 900;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    .sidebar .logo {
        display: none;
    }

    .sidebar-build {
        display: none;
    }

    .content {
        margin-left: 0;
        padding: 16px 12px;
        padding-bottom: 72px; /* space for bottom nav */
    }

    /* On mobile, allow generator page to scroll naturally */
    #generator-page.active {
        height: auto;
        overflow: visible;
    }

    .nav-links {
        display: flex;
        justify-content: space-around;
        padding: 0;
        gap: 0;
    }

    .nav-links li {
        flex: 1;
        margin-bottom: 0;
    }

    .nav-links li a {
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 2px;
        padding: 10px 4px 8px;
        font-size: 10px;
        border-radius: 0;
        white-space: nowrap;
        text-align: center;
    }

    .nav-links li a svg {
        display: block;
        width: 22px;
        height: 22px;
    }

    .nav-links li a.active {
        background: rgba(99, 102, 241, 0.2);
    }

    h1 {
        font-size: 22px;
    }

    /* Generator: single column, tighter spacing */
    .generator-layout {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    /* On mobile, allow page to scroll naturally */
    #generator-page.active {
        height: auto;
        overflow: visible;
    }

    #generator-page > .generator-layout {
        overflow: visible;
    }

    .input-section,
    .output-section {
        padding: 16px;
        max-height: none;
        overflow: visible;
    }

    /* Stack form rows vertically */
    .form-row {
        flex-direction: column;
        gap: 0;
    }

    /* Full-width generate button with larger tap target */
    #generator-page .button-group {
        flex-direction: column;
    }

    #generator-page .button-group .btn {
        width: 100%;
        justify-content: center;
        padding: 14px;
        font-size: 16px;
    }

    /* Shorter textarea on mobile - URL is primary input */
    #job-ad {
        min-height: 80px;
    }

    /* Stack save section fields vertically */
    .save-section .form-row {
        flex-direction: column;
    }

    /* Tabs: prevent overflow */
    .tabs {
        overflow-x: auto;
    }

    /* Toast: above bottom nav */
    .toast {
        left: 16px;
        right: 16px;
        bottom: 72px;
    }

    /* Profile sections: tighter padding */
    .profile-tabs-container {
        padding: 16px;
    }

    /* Stack profile sources vertically on mobile */
    .profile-sources-row {
        flex-direction: column;
        align-items: stretch;
    }

    .additional-content-compact {
        min-width: 0;
    }

    /* Hide filters on mobile - takes up too much space */
    .filters-section {
        display: none;
    }

    /* Hide Add Application button row on mobile - move to fab style later if needed */
    #applications-page > div[style*="justify-content: flex-end"] {
        display: none;
    }

    /* Hide desktop table on mobile */
    .applications-table-container {
        display: none;
    }

    /* Show mobile applications list */
    .applications-mobile-list {
        display: flex !important;
        flex-direction: column;
        gap: 12px;
        width: 100%;
    }

    .application-card {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 12px;
        padding: 16px;
        display: flex !important;
        align-items: center;
        gap: 12px;
        width: 100%;
        box-sizing: border-box;
    }

    .application-card-info {
        flex: 1 1 0;
        width: 0;
        min-width: 0;
    }

    .application-card-company,
    .application-card-title {
        display: block;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    .application-card-company {
        font-weight: 600;
        font-size: 15px;
        color: var(--text-primary);
        margin-bottom: 2px;
    }

    .application-card-title {
        font-size: 13px;
        color: var(--text-secondary);
    }

    .application-card > .btn {
        flex: 0 0 auto;
        padding: 10px 16px;
    }

    /* Prevent horizontal scroll on applications page */
    #applications-page {
        overflow-x: hidden;
        max-width: 100vw;
    }

    /* Stats grid: 2 columns on mobile */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-value {
        font-size: 24px;
    }

    /* Pipeline: single column on narrow screens */
    .pipeline-board {
        grid-template-columns: 1fr;
    }

    /* Generator page mobile: hide entire output section by default */
    #generator-page .output-section {
        display: none;
    }

    /* Show output section on mobile only when CV has been generated (JS adds this class) */
    #generator-page .output-section.has-content {
        display: block;
        background: transparent;
        border: none;
        padding: 0;
        box-shadow: none;
        margin-top: 8px;
    }

    /* Hide tabs and content on mobile - only show save section */
    #generator-page .output-section.has-content .tabs,
    #generator-page .output-section.has-content .tab-content,
    #generator-page .output-section.has-content .refinement-section {
        display: none !important;
    }

    /* Style save section as a card on mobile */
    #generator-page .output-section.has-content .save-section {
        margin-top: 0;
        padding: 16px;
        border-top: none;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 12px;
    }

    /* Hide hiring manager/recruiter fields on mobile */
    #generator-page .output-section.has-content .save-section .form-row {
        display: none;
    }

    /* Full-width save button */
    #generator-page .output-section.has-content .save-section .btn-success {
        width: 100%;
        justify-content: center;
        padding: 14px;
        font-size: 16px;
    }

    /* Slightly taller job advert textarea on mobile */
    #generator-page #job-ad {
        min-height: 100px;
    }
}

/* Login Page */
.login-page {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sidebar-bg);
    z-index: 1000;
}

.login-card {
    background: var(--background);
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

.login-card h2 {
    margin-bottom: 24px;
    text-align: center;
}

.login-logo {
    display: block;
    width: 180px;
    margin: 0 auto 24px;
    background: var(--sidebar-bg);
    padding: 12px 20px;
    border-radius: 8px;
}

.login-error {
    color: var(--destructive);
    font-size: 0.85rem;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: rgba(239, 68, 68, 0.08);
    border-radius: 6px;
}

/* Sidebar user section */
.sidebar-user {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    margin-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-user-info {
    font-size: 0.8rem;
    color: var(--sidebar-text);
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user-info:hover {
    color: var(--sidebar-text-active);
}

.sidebar-logout-btn {
    background: none;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.sidebar-logout-btn:hover {
    color: var(--destructive);
    background: rgba(255, 255, 255, 0.05);
}

/* Application Detail Page */
.page-header {
    margin-bottom: 16px;
}

.application-detail-header {
    margin-bottom: 24px;
}

.application-detail-header h1 {
    margin-bottom: 4px;
}

.company-subtitle {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.application-detail-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.detail-left-column,
.detail-right-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.detail-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
}

.detail-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.detail-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.detail-info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-info-item label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.detail-info-item span,
.detail-info-item a {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.detail-info-item a {
    color: var(--primary);
    text-decoration: none;
}

.detail-info-item a:hover {
    text-decoration: underline;
}

.status-select-large {
    width: 100%;
    min-width: 0;
    padding: 8px 12px;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--background);
    cursor: pointer;
}

.detail-info-item select {
    min-width: 0;
    width: 100%;
}

/* Documents section */
.documents-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.document-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.document-group:last-child {
    border-bottom: none;
}

.document-label {
    font-weight: 500;
    min-width: 100px;
    font-size: 0.9rem;
}

.no-documents {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-style: italic;
}

/* Updates section */
.updates-card {
    flex: 1;
    min-height: 300px;
}

.add-update-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.add-update-section textarea {
    resize: vertical;
    min-height: 70px;
}

.add-update-section .btn {
    align-self: flex-end;
}

.updates-timeline {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.update-item {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
}

.update-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.update-timestamp {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.update-delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    opacity: 0.5;
    transition: opacity 0.2s ease, color 0.2s ease;
}

.update-delete-btn:hover {
    opacity: 1;
    color: var(--destructive);
}

.update-note {
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.5;
    white-space: pre-wrap;
}

.no-updates {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-style: italic;
    text-align: center;
    padding: 24px 0;
}

/* Match summary */
.match-summary-text {
    font-family: inherit;
    font-size: 0.85rem;
    line-height: 1.6;
    white-space: pre-wrap;
    color: var(--text-secondary);
    margin: 0;
}

/* Collapsible card */
.collapsible-card summary {
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.collapsible-card summary::after {
    content: '+';
    font-size: 1.25rem;
    color: var(--text-secondary);
}

.collapsible-card[open] summary::after {
    content: '−';
}

.collapsible-card summary::-webkit-details-marker {
    display: none;
}

.job-ad-text {
    margin-top: 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
}

/* Responsive adjustments for application detail page */
@media (max-width: 1024px) {
    .application-detail-layout {
        grid-template-columns: 1fr;
    }

    .detail-info-grid {
        grid-template-columns: 1fr;
    }
}

/* Onboarding Wizard */
.onboarding-wizard {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--sidebar-bg);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 40px 20px;
}

.onboarding-container {
    background: var(--background);
    border-radius: 16px;
    padding: 48px;
    max-width: 560px;
    width: 100%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.onboarding-header {
    text-align: center;
    margin-bottom: 32px;
}

.onboarding-logo {
    width: 180px;
    margin-bottom: 24px;
}

.onboarding-header h1 {
    font-size: 24px;
    margin-bottom: 8px;
}

.onboarding-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Progress Indicator */
.onboarding-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 40px;
    gap: 8px;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.step-label {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.progress-step.active .step-number {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.progress-step.completed .step-number {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.progress-line {
    width: 40px;
    height: 2px;
    background: var(--border);
    margin-bottom: 20px;
}

/* Steps */
.onboarding-step {
    display: none;
}

.onboarding-step.active {
    display: block;
}

.onboarding-step h2 {
    font-size: 20px;
    margin-bottom: 8px;
}

.step-description {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
}

.onboarding-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 32px;
    gap: 12px;
}

.onboarding-actions .btn:only-child {
    margin-left: auto;
}

/* CV Upload Zone */
.cv-upload-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    transition: all 0.2s ease;
    cursor: pointer;
}

.cv-upload-zone:hover,
.cv-upload-zone.drag-over {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.cv-upload-zone svg {
    color: var(--text-muted);
    margin-bottom: 16px;
}

.cv-upload-zone p {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.cv-upload-zone .file-hint {
    display: block;
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

.cv-upload-zone.uploaded {
    border-color: var(--success);
    background: rgba(22, 163, 74, 0.05);
}

.hidden-file-input {
    display: none;
}

.upload-status {
    margin-top: 12px;
    font-size: 13px;
    text-align: center;
}

.upload-status.loading {
    color: var(--text-secondary);
}

.upload-status.success {
    color: var(--success);
}

.upload-status.error {
    color: var(--destructive);
}

/* Form hint text */
.form-hint {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-muted);
}

/* Tag input styling for onboarding */
.tag-input-container {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    background: var(--surface);
}

.tag-input-row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.tag-input-row input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 14px;
}

.tag-input-row input:focus {
    outline: none;
    border-color: var(--border-focus);
}

.btn-small {
    padding: 8px 12px;
    font-size: 13px;
}

.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 24px;
}

.tags-list .tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--primary);
    color: white;
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 13px;
}

.tags-list .tag-remove {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
    opacity: 0.7;
}

.tags-list .tag-remove:hover {
    opacity: 1;
}

/* Summary Card */
.summary-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 24px;
}

.summary-section {
    margin-bottom: 20px;
}

.summary-section:last-child {
    margin-bottom: 0;
}

.summary-section h4 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.summary-section p {
    font-size: 14px;
    margin-bottom: 4px;
}

.btn-large {
    padding: 14px 28px;
    font-size: 15px;
}

/* Responsive for onboarding */
@media (max-width: 600px) {
    .onboarding-container {
        padding: 32px 24px;
    }

    .onboarding-progress {
        gap: 4px;
    }

    .progress-line {
        width: 20px;
    }

    .step-label {
        font-size: 10px;
    }

    .cv-upload-zone {
        padding: 24px;
    }
}

/* ==============================
   Feedback FAB & Admin Page
   ============================== */

/* Floating action button */
.feedback-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 100;
    transition: background 0.2s ease, transform 0.2s ease;
    display: none; /* shown via JS when logged in */
}

.feedback-fab:hover {
    background: var(--primary-hover);
    transform: scale(1.08);
}

/* Admin feedback page */
.feedback-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.feedback-filter-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.feedback-filter-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.feedback-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.feedback-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    transition: border-color 0.2s ease;
}

.feedback-card.unread {
    border-left: 3px solid var(--primary);
}

.feedback-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    gap: 12px;
}

.feedback-card-meta {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
}

.feedback-card-meta strong {
    color: var(--text-primary);
}

.feedback-card-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.feedback-card-actions button {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s ease;
}

.feedback-card-actions button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.feedback-card-actions button.btn-delete:hover {
    border-color: var(--destructive);
    color: var(--destructive);
}

.feedback-card-message {
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.feedback-page-badge {
    display: inline-block;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.feedback-empty {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-muted);
}

/* Mobile adjustments for FAB */
@media (max-width: 768px) {
    .feedback-fab {
        bottom: 16px;
        right: 16px;
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .feedback-card-header {
        flex-direction: column;
    }

    .feedback-card-actions {
        align-self: flex-end;
    }
}
