/* Analysis Extension CSS */

.jobsoegning-analysis {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
}

.analysis-header {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 20px;
    text-align: center;
}

.analysis-header h2 {
    margin: 0 0 8px 0;
    font-size: 24px;
    font-weight: 600;
}

.analysis-header p {
    margin: 0;
    opacity: 0.9;
    font-size: 14px;
}

.analysis-container {
    position: relative;
    height: calc(100% - 80px);
    overflow: hidden;
}

/* Lock body scroll when modal is open - ROBUST for iOS and Android */
body.analysis-modal-open,
html.analysis-modal-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
    -webkit-overflow-scrolling: auto !important;
    overscroll-behavior: none !important;
    touch-action: none !important;
}

body.analysis-modal-open {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
    body.analysis-modal-open {
        position: fixed !important;
        overflow: hidden !important;
    }
}

.analysis-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: white;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.analysis-content {
    height: 100%;
    display: flex;
    background: white;
}

/* Three-column layout */
.analysis-columns {
    display: flex;
    height: 100%;
    position: relative;
}

.analysis-column {
    flex: 1;
    border-right: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.analysis-column:last-child {
    border-right: none;
}

.column-header {
    background: #f8f9fa;
    padding: 16px;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
    font-size: 16px;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 8px;
}

.column-content {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    position: relative;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

/* CV Column */
.cv-column .column-header {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
}

.cv-item {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.cv-item:hover {
    border-color: #28a745;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.1);
    transform: translateY(-1px);
}

.cv-item.selected {
    border-color: #28a745;
    background: #f8fff9;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.2);
}

.cv-item-title {
    font-weight: 600;
    color: #495057;
    margin-bottom: 4px;
    font-size: 14px;
}

.cv-item-content {
    color: #6c757d;
    font-size: 13px;
    line-height: 1.4;
}

.cv-category-header {
    font-weight: 600;
    color: #495057;
    margin: 16px 0 8px 0;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cv-category-header:first-child {
    margin-top: 0;
}

/* Job Column */
.job-column .column-header {
    background: linear-gradient(135deg, #dc3545, #fd7e14);
    color: white;
}

.job-item {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.job-item:hover {
    border-color: #dc3545;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.1);
    transform: translateY(-1px);
}

.job-item.selected {
    border-color: #dc3545;
    background: #fff8f8;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.2);
}

.job-item-title {
    font-weight: 600;
    color: #495057;
    margin-bottom: 4px;
    font-size: 14px;
}

.job-item-content {
    color: #6c757d;
    font-size: 13px;
    line-height: 1.4;
}

.job-item-importance {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-top: 4px;
}

.job-item-importance.high {
    background: #dc3545;
    color: white;
}

.job-item-importance.medium {
    background: #ffc107;
    color: #212529;
}

.job-item-importance.low {
    background: #6c757d;
    color: white;
}

/* Application Column */
.application-column .column-header {
    background: linear-gradient(135deg, #007bff, #6f42c1);
    color: white;
}

.application-section {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 16px;
    position: relative;
}

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

.application-section-title {
    font-weight: 600;
    color: #495057;
    font-size: 16px;
    margin: 0;
}

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

.application-section-content {
    color: #495057;
    line-height: 1.6;
    font-size: 14px;
    white-space: pre-wrap;
    margin-bottom: 12px;
}

.application-section-stats {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: #6c757d;
    border-top: 1px solid #e9ecef;
    padding-top: 8px;
}

.application-section-highlights {
    margin-top: 8px;
}

.application-section-highlights h4 {
    font-size: 12px;
    color: #6c757d;
    margin: 0 0 4px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.application-section-highlights ul {
    margin: 0;
    padding-left: 16px;
    font-size: 12px;
    color: #495057;
}

/* Connections */
.analysis-connections {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
}

.connection-line {
    position: absolute;
    pointer-events: auto;
    cursor: pointer;
    transition: all 0.3s ease;
}

.connection-line:hover {
    stroke-width: 4;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.connection-line.full-match {
    stroke: #28a745;
    stroke-width: 3;
}

.connection-line.partial-match {
    stroke: #ffc107;
    stroke-width: 3;
}

.connection-line.missing-requirement {
    stroke: #dc3545;
    stroke-width: 3;
    stroke-dasharray: 5,5;
}

.connection-line.transferable-skill {
    stroke: #007bff;
    stroke-width: 3;
}

/* Connection tooltips */
.connection-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    max-width: 200px;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.connection-tooltip.show {
    opacity: 1;
}

.connection-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
}

/* Analysis controls */
.analysis-controls {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    gap: 8px;
    z-index: 20;
}

.analysis-control-btn {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.analysis-control-btn:hover {
    background: #f8f9fa;
    border-color: #007bff;
}

.analysis-control-btn.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

/* Filter toggles */
.filter-toggles {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
}

.filter-toggle {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.filter-toggle:hover {
    background: #f8f9fa;
}

.filter-toggle.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.filter-toggle.full-match {
    border-color: #28a745;
    color: #28a745;
}

.filter-toggle.full-match.active {
    background: #28a745;
    color: white;
}

.filter-toggle.partial-match {
    border-color: #ffc107;
    color: #ffc107;
}

.filter-toggle.partial-match.active {
    background: #ffc107;
    color: #212529;
}

.filter-toggle.missing-requirement {
    border-color: #dc3545;
    color: #dc3545;
}

.filter-toggle.missing-requirement.active {
    background: #dc3545;
    color: white;
}

.filter-toggle.transferable-skill {
    border-color: #007bff;
    color: #007bff;
}

.filter-toggle.transferable-skill.active {
    background: #007bff;
    color: white;
}

/* Analysis summary */
.analysis-summary {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 16px;
}

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

.analysis-summary-title {
    font-weight: 600;
    color: #495057;
    margin: 0;
}

.analysis-score {
    font-size: 24px;
    font-weight: 700;
    color: #28a745;
}

.analysis-summary-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.analysis-stat {
    text-align: center;
    padding: 8px;
    background: white;
    border-radius: 4px;
    border: 1px solid #e9ecef;
}

.analysis-stat-number {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.analysis-stat-number.full-match {
    color: #28a745;
}

.analysis-stat-number.partial-match {
    color: #ffc107;
}

.analysis-stat-number.missing-requirement {
    color: #dc3545;
}

.analysis-stat-number.transferable-skill {
    color: #007bff;
}

.analysis-stat-label {
    font-size: 11px;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Recommendations */
.analysis-recommendations {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 16px;
}

.analysis-recommendations h4 {
    color: #856404;
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
}

.recommendation-item {
    background: white;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 8px;
    font-size: 13px;
    line-height: 1.4;
}

.recommendation-item:last-child {
    margin-bottom: 0;
}

.recommendation-priority {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    margin-right: 8px;
}

.recommendation-priority.high {
    background: #dc3545;
    color: white;
}

.recommendation-priority.medium {
    background: #ffc107;
    color: #212529;
}

.recommendation-priority.low {
    background: #6c757d;
    color: white;
}

/* Responsive design */
@media (max-width: 1200px) {
    .analysis-columns {
        flex-direction: column;
    }
    
    .analysis-column {
        border-right: none;
        border-bottom: 1px solid #e9ecef;
        height: 33.333%;
    }
    
    .analysis-column:last-child {
        border-bottom: none;
    }
}

@media (max-width: 768px) {
    .analysis-header {
        padding: 16px;
    }
    
    .analysis-header h2 {
        font-size: 20px;
    }
    
    .analysis-controls {
        position: static;
        justify-content: center;
        margin: 16px 0;
    }
    
    .analysis-summary-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Fix body scroll on mobile - iOS and Android optimized */
    .jobsoegning-analysis {
        position: fixed !important;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        max-height: -webkit-fill-available !important; /* iOS Safari fix */
        z-index: 999999;
        overflow: hidden !important;
        overscroll-behavior: none !important;
        -webkit-overflow-scrolling: auto;
    }
    
    .analysis-container {
        height: calc(100vh - 80px) !important;
        max-height: calc(100vh - 80px) !important;
        overflow-y: scroll !important; /* Force scrollbar on iOS */
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior-y: contain;
        overscroll-behavior-x: none;
        position: relative;
        touch-action: pan-y pinch-zoom;
        will-change: scroll-position;
    }
    
    /* iOS Safari specific container fixes */
    @supports (-webkit-touch-callout: none) {
        .analysis-container {
            height: calc(100vh - 80px) !important;
            min-height: -webkit-fill-available;
        }
        
        .jobsoegning-analysis {
            min-height: -webkit-fill-available;
        }
    }
    
    /* Mobile: Stack columns vertically */
    .analysis-layout {
        flex-direction: column !important;
        gap: 16px !important;
        padding: 12px !important;
        height: auto !important;
        min-height: calc(100vh - 80px);
    }
    
    .analysis-column {
        flex: none !important;
        width: 100% !important;
        height: auto !important;
        min-height: 400px;
        margin-bottom: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        position: relative;
        touch-action: pan-y pinch-zoom;
        -webkit-transform: translateZ(0); /* Hardware acceleration for iOS */
        transform: translateZ(0);
    }
    
    /* Stack all flex containers with justify-content: space-between */
    .analysis-column > div[style*="justify-content"],
    div[style*="justify-content: space-between"] {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px;
    }
    
    .analysis-column h3 {
        font-size: 18px !important;
    }
    
    /* Stack buttons and form elements */
    .analysis-section-header {
        flex-direction: column !important;
        align-items: flex-start !important;
    }
    
    .analysis-section-actions {
        width: 100%;
        flex-direction: column !important;
    }
    
    .analysis-section-actions button,
    .analysis-section-actions .button {
        width: 100% !important;
        margin-bottom: 8px;
    }
    
    /* Stack all inline flex divs within columns */
    .analysis-column div[style*="display: flex"] {
        flex-wrap: wrap !important;
    }
    
    /* Stack section control buttons */
    .analysis-column div[style*="gap: 5px"],
    .analysis-column div[style*="gap: 10px"] {
        flex-direction: column !important;
        width: 100% !important;
    }
    
    .analysis-column div[style*="gap: 5px"] button,
    .analysis-column div[style*="gap: 10px"] button {
        width: 100% !important;
        margin-bottom: 8px;
    }
    
    /* Stack filter toggles */
    .filter-toggles {
        flex-wrap: wrap;
    }
    
    /* Stack analysis summary stats */
    .analysis-summary-stats {
        grid-template-columns: 1fr !important;
    }
    
    /* Adjust column content padding */
    .column-content {
        padding: 12px;
    }
    
    /* Make all buttons full width on mobile */
    .analysis-column button,
    .analysis-column .button,
    .analysis-column input[type="button"],
    .analysis-column input[type="submit"] {
        width: 100% !important;
        max-width: none !important;
        margin-bottom: 8px;
    }
    
    /* Adjust move buttons container */
    div[style*="flex-direction: column"][style*="gap: 2px"] {
        flex-direction: row !important;
        gap: 8px !important;
        width: 100% !important;
        justify-content: center !important;
    }
    
    div[style*="flex-direction: column"][style*="gap: 2px"] button {
        flex: 1 !important;
        width: auto !important;
    }
    
    /* Mobile adjustments for section library modal */
    .section-library-content {
        width: 95%;
        max-height: 90%;
    }
    
    .section-library-header,
    .section-library-body,
    .section-library-footer {
        padding: 16px;
    }
    
    .section-library-footer {
        flex-direction: column;
    }
    
    .section-library-footer button {
        width: 100%;
    }
    
    /* Stack modal footer buttons */
    div[style*="justify-content: flex-end"] {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    
    div[style*="justify-content: flex-end"] button {
        width: 100% !important;
    }
    
    /* Ensure textarea and input fields are full width */
    .analysis-column textarea,
    .analysis-column input[type="text"],
    .analysis-column input[type="email"] {
        width: 100% !important;
        box-sizing: border-box;
    }
    
    /* Adjust section header spacing */
    .analysis-column > div > h3 {
        margin-bottom: 12px !important;
    }
    
    /* Modal adjustments for mobile */
    div[id$="-modal"] > div {
        width: 95% !important;
        max-width: none !important;
        flex-direction: column !important;
    }
    
    /* Make labels stack vertically */
    label[style*="display: flex"] {
        flex-direction: column !important;
        align-items: flex-start !important;
    }
    
    /* Adjust padding for better mobile viewing */
    .analysis-column {
        padding: 12px !important;
    }
    
    /* Ensure content areas have proper spacing and scrolling - iOS & Android */
    #cv-content,
    #application-content,
    #job-content {
        padding: 8px !important;
        overflow-y: scroll !important; /* scroll instead of auto for iOS */
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior-y: contain;
        overscroll-behavior-x: none;
        max-height: 500px;
        flex: 1;
        position: relative;
        touch-action: pan-y pinch-zoom;
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        will-change: scroll-position;
    }
    
    /* Make sure column content is scrollable - iOS & Android */
    .analysis-column > div[id$="-content"] {
        overflow-y: scroll !important; /* scroll instead of auto for iOS */
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior-y: contain;
        overscroll-behavior-x: none;
        flex: 1;
        min-height: 300px;
        position: relative;
        touch-action: pan-y pinch-zoom;
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        will-change: scroll-position;
    }
    
    /* Additional iOS Safari fixes */
    @supports (-webkit-touch-callout: none) {
        #cv-content,
        #application-content,
        #job-content,
        .analysis-column > div[id$="-content"] {
            -webkit-overflow-scrolling: touch !important;
            overflow-y: scroll !important;
        }
    }
    
    /* Hide connections on mobile as they won't render properly */
    .analysis-connections {
        display: none;
    }
    
    .connection-line {
        display: none;
    }
}

/* Additional mobile-specific breakpoint for very small screens */
@media (max-width: 480px) {
    .analysis-header h2 {
        font-size: 18px;
    }
    
    .analysis-header p {
        font-size: 12px;
    }
    
    .analysis-column {
        padding: 8px !important;
    }
    
    .cv-item,
    .job-item,
    .application-section {
        padding: 10px;
    }
    
    button,
    .button {
        font-size: 14px !important;
        padding: 10px 16px !important;
    }
    
    /* Smaller font sizes for very small screens */
    .cv-item-title,
    .job-item-title,
    .application-section-title {
        font-size: 13px;
    }
    
    .cv-item-content,
    .job-item-content,
    .application-section-content {
        font-size: 12px;
    }
}

/* Animation for connections */
@keyframes drawConnection {
    from {
        stroke-dashoffset: 1000;
    }
    to {
        stroke-dashoffset: 0;
    }
}

.connection-line.animate {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: drawConnection 2s ease-in-out forwards;
}

/* Section library modal */
.section-library-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.section-library-modal.show {
    display: flex;
}

.section-library-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 80%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.section-library-header {
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-library-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.section-library-footer {
    padding: 20px;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.section-library-item {
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.section-library-item:hover {
    border-color: #007bff;
    background: #f8f9fa;
}

.section-library-item.selected {
    border-color: #007bff;
    background: #e7f3ff;
}

.section-library-item-title {
    font-weight: 600;
    color: #495057;
    margin-bottom: 8px;
}

.section-library-item-content {
    color: #6c757d;
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 8px;
}

.section-library-item-meta {
    display: flex;
    gap: 16px;
    font-size: 11px;
    color: #6c757d;
}
