/**
 * Enhanced Job Details - Page Layout CSS
 * Ported from legacy root-level job-details.css into the ejd module.
 * Contains: modal styles, job header, meta tags, apply button,
 * sidebar, skeleton loading, error states, and responsive design.
 */

/* Salary Snapshot Widget Styles */
#salarySnapshotWidgetContainer .section-title {
    margin-bottom: 0.75rem;
}

#salarySnapshotContent p {
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
}

#salarySnapshotContent p strong {
    color: var(--text-primary);
}

#salarySnapshotContent .btn-sm {
    font-size: 0.8rem;
    padding: 0.25rem 0.75rem;
}

#salaryComparisonText {
    color: var(--text-secondary);
}

#salarySnapshotError p {
    font-size: 0.85rem;
}

/* Comparable Job Title Salary Widget Styles */
#comparableJobSalaryWidgetContainer .section-title {
    margin-bottom: 0.75rem;
}

#comparableJobSalaryContent p {
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
}

#comparableJobSalaryContent p strong {
    color: var(--text-primary);
}

#comparableJobSalaryContent .text-muted.small {
    font-size: 0.8rem;
}

#comparableJobSalaryError p {
    font-size: 0.85rem;
}


/* Modern Job Details Styling */

/* Container Width */
@media (min-width: 1200px) {
    .container, .container-lg, .container-md, .container-sm, .container-xl {
        max-width: 80%;
    }
}

/* Bookmark and Views */
.bookmark-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.views-count {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #6c757d;
    font-size: 0.9rem;
}

.views-count i {
    font-size: 0.9rem;
}

/* ================================
   Modal Styles (CRITICAL - hides modals by default)
   ================================ */
.application-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow-y: auto;
}

.application-modal.show {
    display: block;
    padding-top: 150px;
}

.application-modal-content {
    background: white;
    max-width: 600px;
    margin: 40px auto;
    padding: 30px;
    border-radius: 8px;
    position: relative;
}

/* Auth Modal Styles */
.auth-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow-y: auto;
}

.auth-modal.show {
    display: block;
    padding-top: 50px;
}

.auth-modal-content {
    background: white;
    max-width: 500px;
    margin: 40px auto;
    padding: 30px;
    border-radius: 8px;
    position: relative;
}

.auth-modal-header {
    text-align: center;
    margin-bottom: 20px;
}

.auth-modal-header h3 {
    margin-bottom: 10px;
}

.auth-modal-message {
    text-align: center;
    margin-bottom: 20px;
    color: #666;
}

.auth-benefits {
    margin-top: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    text-align: left;
}

.auth-benefits h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: #343a40;
}

.auth-benefits ul {
    list-style-type: none;
    padding-left: 0;
    margin-bottom: 0;
}

.auth-benefits li {
    font-size: 0.9rem;
    color: #495057;
    margin-bottom: 8px;
    display: flex;
    align-items: flex-start;
}

.auth-benefits li:last-child {
    margin-bottom: 0;
}

.auth-benefits i {
    color: #28a745;
    margin-right: 10px;
    margin-top: 3px;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.close-modal:hover {
    color: #333;
}

/* Form Styles */
.application-form label {
    font-weight: 600;
    margin-bottom: 8px;
}

.application-form .form-control {
    margin-bottom: 20px;
}

.application-status {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
    display: none;
}

.application-status.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.application-status.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* ================================
   Page-level design tokens
   Uses gestalt variables where available, with fallbacks
   ================================ */
:root {
    --ejd-primary-color: var(--color-primary, #0066FF);
    --ejd-primary-light: var(--color-primary-light, #E5F0FF);
    --ejd-success-color: #00C853;
    --ejd-accent-color: #7747FF;
    --ejd-text-primary: var(--color-text, #1A1A1A);
    --ejd-text-secondary: var(--color-text-muted, #666666);
    --ejd-background-light: var(--color-background, #F8FAFC);
    --ejd-border-color: var(--color-border, #E5E7EB);
    /* No gradients on buttons — use solid primary color */
}

/* Breadcrumb */
.ejd-breadcrumb {
    margin-bottom: var(--space-lg);
}

.ejd-breadcrumb ol {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    background: transparent;
    padding: 0;
    margin: 0;
    font-size: var(--font-sm);
    gap: var(--space-xs);
}

.ejd-breadcrumb li {
    display: inline-flex;
    align-items: center;
}

.ejd-breadcrumb li + li::before {
    content: '/';
    color: var(--color-text-light);
    margin-right: var(--space-xs);
}

.ejd-breadcrumb a {
    color: var(--color-primary);
    text-decoration: none;
}

.ejd-breadcrumb a:hover {
    text-decoration: underline;
}

.ejd-breadcrumb__active {
    color: var(--color-text-secondary);
}

.ejd-breadcrumb a:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Job Header Section */
.job-header {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--ejd-border-color);
}

.job-header-top {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.job-title-section {
    flex: 1;
}

.company-logo {
    width: 110px;
    height: 110px;
    max-height: 110px;
    border-radius: 8px;
    object-fit: contain;
    background: white;
    border: 1px solid #e9ecef;
    margin-right: 1rem;
}

.job-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--ejd-text-primary);
    margin: 0 0 6px 0;
    line-height: 1.3;
}

.company-name {
    font-size: 15px;
    color: var(--ejd-text-secondary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
}

.bookmark-button {
    background: transparent;
    border: 1px solid var(--ejd-border-color);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ejd-text-secondary);
    transition: all 0.2s ease;
    padding: 0;
}

.bookmark-button:hover {
    background: var(--ejd-primary-light);
    color: var(--ejd-primary-color);
    border-color: var(--ejd-primary-color);
}

/* Meta Information */
.job-meta-1 {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.meta-tag {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    background: var(--ejd-background-light);
    border-radius: 6px;
    font-size: 14px;
    color: var(--ejd-text-secondary);
    gap: 6px;
    border: 1px solid var(--ejd-border-color);
}

.meta-tag i {
    color: var(--ejd-primary-color);
    font-size: 14px;
}

/* Salary Estimate Note */
.salary-estimate-note {
    font-size: 0.85rem;
    color: #666;
    margin-top: 4px;
    font-style: italic;
}

/* Job Description Section */
.job-description {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    padding: 20px;
    margin-bottom: 70px;
    border: 1px solid var(--ejd-border-color);
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--ejd-text-primary);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--ejd-border-color);
    display: flex;
    align-items: center;
}

.formatted-content {
    font-size: 14px;
    line-height: 1.6;
    color: var(--ejd-text-secondary);
}

/* Map Styles */
#job-location-map {
    height: 300px;
    border-radius: 8px;
    margin-top: 10px;
}

/* Similar Jobs Section */
.similar-jobs-section {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--ejd-border-color);
}

.similar-job {
    display: flex;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--ejd-border-color);
    border-radius: 8px;
    margin-bottom: 10px;
    transition: all 0.2s ease;
    cursor: pointer;
    background: var(--ejd-background-light);
}

.similar-job:hover {
    border-color: var(--ejd-primary-color);
    background: white;
}

.similar-job:last-child {
    margin-bottom: 0;
}

.similar-job-logo {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    color: var(--ejd-primary-color);
    border: 1px solid var(--ejd-border-color);
}

.similar-job-info {
    flex: 1;
    min-width: 0;
}

.similar-job-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--ejd-text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.similar-job-company {
    font-size: 13px;
    color: var(--ejd-text-secondary);
    margin-bottom: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Apply Button */
.apply-button-wrapper {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    padding: 20px 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    border-top: 1px solid var(--ejd-border-color);
}

.apply-button-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    max-width: 800px;
    margin: 0 auto;
}

.apply-button {
    background-color: var(--ejd-primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 16px 32px;
    font-size: 18px;
    font-weight: 600;
    transition: all 0.2s ease;
    min-width: 250px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.apply-button small {
    font-size: 11px;
    font-weight: 400;
    opacity: 0.9;
}

.apply-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 102, 255, 0.2);
}

.apply-external {
    background-color: #007bff;
}

.apply-internal {
    background-color: #28a745;
}

/* Loading States */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--ejd-background-light) 25%,
        #f0f0f0 50%,
        var(--ejd-background-light) 75%
    );
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 4px;
}

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
    width: 100%;
}

.skeleton-text.short {
    width: 60%;
}

.skeleton-circle {
    width: 60px;
    height: 60px;
    border-radius: 8px;
}

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

/* Error States */
.error-state {
    text-align: center;
    padding: 40px 20px;
    background: white;
    border-radius: 12px;
    border: 1px solid var(--ejd-border-color);
}

.error-icon {
    font-size: 40px;
    color: var(--ejd-text-secondary);
    margin-bottom: 12px;
}

.error-title {
    font-size: 20px;
    color: var(--ejd-text-primary);
    margin-bottom: 8px;
    font-weight: 600;
}

.error-message {
    color: var(--ejd-text-secondary);
    font-size: 14px;
    max-width: 400px;
    margin: 0 auto;
}

.error-actions {
    max-width: 400px;
    margin: 0 auto;
}

.error-actions h3 {
    font-size: 16px;
    color: var(--ejd-text-primary);
    margin-bottom: 16px;
    font-weight: 600;
}

.error-actions .btn {
    width: 100%;
    padding: 12px 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.error-actions .btn i {
    font-size: 16px;
}

.error-actions .btn-primary {
    background-color: var(--ejd-primary-color);
    border: none;
}

.error-actions .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 102, 255, 0.2);
}

.error-actions .btn-secondary {
    background: white;
    border: 1px solid var(--ejd-border-color);
    color: var(--ejd-text-secondary);
}

.error-actions .btn-secondary:hover {
    border-color: var(--ejd-primary-color);
    color: var(--ejd-primary-color);
    background: var(--ejd-primary-light);
}

/* ================================
   Responsive Design
   ================================ */
@media (max-width: 768px) {
    .job-header, .job-description, .similar-jobs-section {
        padding: 16px;
        border-radius: 10px;
    }

    .job-header-top {
        flex-direction: column;
    }

    .d-flex.align-items-start.flex-grow-1 {
        flex-direction: column;
    }

    .job-meta {
        gap: 6px;
    }

    .meta-tag {
        padding: 6px 12px;
        font-size: 13px;
        width: 100%;
        justify-content: flex-start;
    }

    .apply-button {
        width: calc(100% - 32px);
        margin: 0 16px;
        font-size: 16px;
        padding: 14px 24px;
    }

    .similar-job {
        padding: 10px;
    }

    .job-title {
        font-size: 18px;
        margin-top: 0.5rem;
    }

    .company-logo {
        width: 80px;
        height: auto;
        max-height: 80px;
        margin-bottom: 0.5rem;
    }

    .bookmark-container {
        margin-top: 1rem;
        width: 100%;
        justify-content: space-between;
    }

    /* Job Description Mobile Styles */
    .job-description .formatted-content {
        font-size: 13px;
        line-height: 1.5;
    }

    .job-description .formatted-content p,
    .job-description .formatted-content ul,
    .job-description .formatted-content ol {
        margin-bottom: 0.75rem;
    }

    .job-description .formatted-content li {
        margin-bottom: 0.4rem;
    }
}

@media (max-width: 576px) {
    .job-header, .job-description, .similar-jobs-section {
        padding: 14px;
        margin-bottom: 15px;
    }

    .company-logo {
        width: 60px;
        height: auto;
        max-height: 60px;
    }

    .job-title {
        font-size: 16px;
    }

    .company-name {
        font-size: 13px;
    }

    /* Job Description Mobile Styles */
    .job-description .formatted-content {
        font-size: 12px;
        line-height: 1.4;
    }

    .job-description .formatted-content p,
    .job-description .formatted-content ul,
    .job-description .formatted-content ol {
        margin-bottom: 0.6rem;
        padding-left: 1.2rem;
    }

    .job-description .formatted-content li {
        margin-bottom: 0.35rem;
    }

    .job-description .section-title {
        font-size: 14px;
        margin-bottom: 12px;
        padding-bottom: 10px;
    }

    .meta-tag {
        font-size: 12px;
        padding: 5px 10px;
        background: rgba(120, 166, 200, 0.1);
    }

    .meta-tag i {
        font-size: 12px;
        width: 16px;
        text-align: center;
    }

    .apply-button {
        font-size: 14px;
        padding: 12px 20px;
    }

    .similar-job-title {
        font-size: 13px;
    }

    .similar-job-company {
        font-size: 12px;
    }
}

@media (max-width: 375px) {
    .job-header, .job-description, .similar-jobs-section {
        padding: 12px;
        margin-bottom: 12px;
    }

    .company-logo {
        width: 50px;
        height: auto;
        max-height: 50px;
    }

    .job-title {
        font-size: 15px;
    }

    .company-name {
        font-size: 12px;
    }

    .meta-tag {
        font-size: 11px;
        padding: 4px 8px;
    }

    .meta-tag i {
        font-size: 11px;
    }

    .job-description .formatted-content {
        font-size: 11px;
        line-height: 1.35;
    }

    .apply-button {
        font-size: 13px;
        padding: 10px 16px;
    }
}
