/**
 * Modal Styles
 * Consolidated styles for JobModals and other modal components
 */

/* ============================================================
   CONFIRM DIALOG ANIMATIONS
   ============================================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

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

/* ============================================================
   GENERIC MODAL OVERLAY (for JS-created modals)
   ============================================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal, 10000);
}

/* Show modal when .show, .active, or .visible class is added */
.modal-overlay.show,
.modal-overlay.active,
.modal-overlay.visible {
    display: flex;
}

.modal-overlay--dark {
    background: rgba(0, 0, 0, 0.6);
}

.modal-overlay--high {
    z-index: 10001;
}

/* ============================================================
   JOB MODAL OVERLAY
   ============================================================ */
.job-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal, 10000);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.job-modal-overlay.job-modal--visible {
    opacity: 1;
    pointer-events: auto;
}

/* ============================================================
   MODAL CONTENT
   Standard sizes: small (400px), medium (600px), large (900px)
   ============================================================ */
.job-modal-content,
.modal-content {
    background: var(--color-surface, #ffffff);
    border-radius: var(--radius-lg, 12px);
    max-width: 600px; /* Standard medium size */
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl, 0 20px 60px rgba(0, 0, 0, 0.3));
    transform: scale(0.9);
    transition: transform 0.2s ease;
}

.job-modal--visible .job-modal-content,
.modal-overlay.show .modal-content {
    transform: scale(1);
}

/* Size variants */
.job-modal--small .job-modal-content,
.modal-content.modal--small {
    max-width: 400px;
}

.job-modal--wide .job-modal-content,
.job-modal--medium .job-modal-content,
.modal-content.modal--medium {
    max-width: 600px;
}

.job-modal--large .job-modal-content,
.modal-content.modal--large {
    max-width: 900px;
}

/* Profile modal - prevent double scrollbars by using flex layout */
.modal-content.profile-modal {
    overflow: hidden !important;
    display: flex;
    flex-direction: column;
}

/* ============================================================
   MODAL HEADER
   ============================================================ */
.job-modal-header,
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-lg, 20px) var(--spacing-xl, 24px);
    border-bottom: 2px solid var(--color-border, #e9ecef);
}

.job-modal-header h3,
.job-modal-header h2,
.modal-header h2,
.modal-header h3 {
    margin: 0;
    font-size: var(--font-size-lg, 1.25rem);
    font-weight: var(--font-weight-semibold, 600);
    color: var(--color-text, #2c3e50);
}

.job-modal-close,
.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-text-muted, #95a5a6);
    padding: 0;
    width: 44px;
    height: 44px;
    min-width: 44px; /* WCAG 2.5.5 touch target minimum */
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    line-height: 1;
    transition: all 0.2s;
}

.job-modal-close:hover,
.modal-close:hover {
    background: var(--color-bg-light, #f5f5f5);
    color: var(--color-text, #2c3e50);
}

/* ============================================================
   MODAL BODY
   ============================================================ */
.job-modal-body,
.modal-body {
    padding: var(--spacing-xl, 24px);
    overflow-y: auto;
    flex: 1;
}

.job-modal-body p,
.modal-body p {
    margin: 0 0 var(--spacing-md, 16px) 0;
    color: var(--color-text-secondary, #555);
    line-height: 1.6;
}

.job-modal-body p:last-child,
.modal-body p:last-child {
    margin-bottom: 0;
}

/* ============================================================
   MODAL INPUT
   ============================================================ */
.job-modal-input {
    width: 100%;
    padding: var(--spacing-sm, 12px);
    border: 2px solid var(--color-border, #e9ecef);
    border-radius: var(--radius-md, 8px);
    font-size: var(--font-size-md, 1rem);
    transition: border-color 0.2s;
}

.job-modal-input:focus {
    outline: none;
    border-color: var(--color-primary, #3498db);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

.job-modal-input.is-invalid {
    border-color: var(--color-error, #e74c3c);
}

/* ============================================================
   MODAL FOOTER
   ============================================================ */
.job-modal-footer,
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm, 12px);
    padding: var(--spacing-md, 16px) var(--spacing-xl, 24px);
    border-top: 2px solid var(--color-border, #e9ecef);
    background: var(--color-background, #f8f9fa);
    border-radius: 0 0 var(--radius-lg, 12px) var(--radius-lg, 12px);
}

/* ============================================================
   MODAL BUTTONS (standard styling)
   ============================================================ */
.modal-btn,
.btn-modal-primary,
.btn-modal-secondary {
    padding: 12px 24px;
    border-radius: var(--radius-md, 8px);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-modal-primary {
    background: var(--color-primary, #3498db);
    color: white;
    border: none;
}

.btn-modal-primary:hover {
    background: var(--color-primary-dark, #2980b9);
    transform: translateY(-1px);
}

.btn-modal-secondary {
    background: white;
    color: var(--color-text, #555);
    border: 1px solid var(--color-border, #ddd);
}

.btn-modal-secondary:hover {
    background: var(--color-bg-light, #f5f5f5);
}

/* ============================================================
   JOB DETAILS GRID
   ============================================================ */
.job-details-grid {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md, 16px);
}

.job-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: var(--spacing-sm, 12px);
    border-bottom: 1px solid var(--color-border-light, #eee);
}

.job-detail-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.job-detail-label {
    font-weight: var(--font-weight-semibold, 600);
    color: var(--color-text-muted, #7f8c8d);
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.job-toast {
    position: fixed;
    bottom: var(--spacing-lg, 20px);
    right: var(--spacing-lg, 20px);
    background: var(--color-surface, #ffffff);
    padding: var(--spacing-md, 16px) var(--spacing-xl, 24px);
    border-radius: var(--radius-md, 8px);
    box-shadow: var(--shadow-lg, 0 4px 20px rgba(0, 0, 0, 0.15));
    z-index: var(--z-toast, 10001);
    animation: slideInRight 0.3s ease;
    max-width: 400px;
}

.job-toast--success {
    border-left: 4px solid var(--color-success, #27ae60);
}

.job-toast--error {
    border-left: 4px solid var(--color-error, #e74c3c);
}

.job-toast--warning {
    border-left: 4px solid var(--color-warning, #f39c12);
}

.job-toast--info {
    border-left: 4px solid var(--color-info, #3498db);
}

.job-toast__content {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm, 12px);
}

.job-toast__icon {
    font-size: 1.2rem;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 767px) {
    .job-modal-content {
        width: 95%;
        max-height: 85vh;
    }

    .job-modal--wide .job-modal-content {
        max-width: 95%;
    }

    .job-modal-header,
    .job-modal-body,
    .job-modal-footer {
        padding-left: var(--spacing-md, 16px);
        padding-right: var(--spacing-md, 16px);
    }

    .job-toast {
        left: var(--spacing-md, 16px);
        right: var(--spacing-md, 16px);
        max-width: none;
    }

    .job-detail-row {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-xs, 4px);
    }

    /* Split-view becomes stacked on mobile */
    #availability-split-view,
    #jobs-split-view {
        grid-template-columns: 1fr !important;
    }

    #availability-calendar,
    #jobs-calendar {
        position: relative !important;
        top: 0 !important;
    }
}

/* ============================================================
   AVAILABILITY & JOBS CALENDAR - CARD HIGHLIGHT
   ============================================================ */
.availability-card-highlight,
.job-card-highlight {
    animation: highlightPulse 1.5s ease-out;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.5), 0 4px 20px rgba(52, 152, 219, 0.3) !important;
}

@keyframes highlightPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(52, 152, 219, 0.7), 0 4px 20px rgba(52, 152, 219, 0.5);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(52, 152, 219, 0), 0 4px 20px rgba(52, 152, 219, 0.3);
    }
    100% {
        box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.5), 0 4px 20px rgba(52, 152, 219, 0.3);
    }
}

/* ============================================================
   INVOICE MODAL
   ============================================================ */
.invoice-modal {
    display: flex !important;
}

.invoice-modal-content {
    background: white;
    border-radius: var(--radius-lg, 12px);
    max-width: 500px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl, 0 10px 40px rgba(0,0,0,0.15));
    animation: slideUp 0.3s ease;
}

.invoice-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-lg, 20px);
    border-bottom: 1px solid var(--color-border, #e0e0e0);
}

.invoice-modal .modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--color-text-primary, #2c3e50);
}

.invoice-modal .modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-text-muted, #6b7b7c);
    padding: 0;
    line-height: 1;
}

.invoice-modal .modal-close:hover {
    color: var(--color-text-primary, #2c3e50);
}

.invoice-modal .modal-body {
    padding: var(--spacing-lg, 20px);
}

.invoice-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-md, 12px);
    margin-bottom: var(--spacing-lg, 20px);
}

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

.invoice-info-item .label {
    font-size: 0.8rem;
    color: var(--color-text-muted, #6b7b7c);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.invoice-info-item .value {
    font-weight: 500;
    color: var(--color-text-primary, #2c3e50);
}

.invoice-amounts {
    background: var(--color-background, #f8f9fa);
    border-radius: var(--radius-md, 8px);
    padding: var(--spacing-md, 12px);
}

.invoice-amounts .amount-row {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-sm, 8px) 0;
    border-bottom: 1px solid var(--color-border-light, #e0e0e0);
}

.invoice-amounts .amount-row:last-child {
    border-bottom: none;
}

.invoice-amounts .amount-row.total {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--color-success, #27ae60);
    border-top: 2px solid var(--color-border, #e0e0e0);
    margin-top: var(--spacing-sm, 8px);
    padding-top: var(--spacing-md, 12px);
}

.invoice-modal .modal-footer {
    display: flex;
    gap: var(--spacing-sm, 8px);
    justify-content: flex-end;
    padding: var(--spacing-lg, 20px);
    border-top: 1px solid var(--color-border, #e0e0e0);
}

/* Invoice button styling for job cards */
.btn-job-invoice {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
    color: white;
}

.btn-job-invoice:hover {
    background: linear-gradient(135deg, #8e44ad, #7d3c98);
}

/* Status badge for completed jobs */
.job-status-badge.status-completed {
    background: var(--color-success-bg, rgba(39, 174, 96, 0.1));
    color: var(--color-success, #27ae60);
}

@media (max-width: 767px) {
    .invoice-modal-content {
        width: 95%;
        max-height: 90vh;
    }

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

    .invoice-modal .modal-footer {
        flex-direction: column;
    }

    .invoice-modal .modal-footer .btn {
        width: 100%;
    }
}
