/* Modal / Dialog Component */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-index-modal);
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
}

.modal.is-open {
    display: flex;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: var(--z-index-modal-overlay);
    animation: fadeIn var(--transition-medium);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-container {
    position: relative;
    z-index: var(--z-index-modal);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    background-color: var(--color-white);
    border-radius: var(--radius-large);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    animation: slideUp var(--transition-medium);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5);
    border-bottom: 1px solid var(--color-gray-20);
}

.modal-header h3 {
    margin: 0;
    font-size: var(--font-size-h4);
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    padding: 0;
    background: none;
    border: none;
    color: var(--color-gray-60);
    cursor: pointer;
    border-radius: var(--radius-small);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background-color: var(--color-gray-10);
    color: var(--color-gray-100);
}

.modal-close:focus-visible {
    outline: var(--focus-outline-width) solid var(--color-primary-100);
    outline-offset: 2px;
}

.modal-close svg {
    width: 24px;
    height: 24px;
}

.modal-body {
    padding: var(--space-5);
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-5);
    border-top: 1px solid var(--color-gray-20);
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden;
}

/* Mobile Responsive */
@media (max-width: 767px) {
    .modal {
        padding: 0;
    }

    .modal-container {
        max-height: 100vh;
        border-radius: 0;
        height: 100%;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: var(--space-4);
    }

    .modal-footer {
        flex-direction: column-reverse;
        gap: var(--space-2);
    }

    .modal-footer .btn {
        width: 100%;
    }
}

/* -------------------------------------------------------------------------
   Session Recovery Modal
   Injected dynamically by questionnaire.js; all visual styles live here so
   that 'unsafe-inline' is not required in the Content-Security-Policy.
   ------------------------------------------------------------------------- */

.session-recovery-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.55);
}

.session-recovery-modal.is-open {
    display: flex;
}

.session-recovery-dialog {
    background: #fff;
    border-radius: 0.75rem;
    padding: 2rem;
    max-width: 28rem;
    width: 100%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

.session-recovery-title {
    margin: 0 0 0.75rem;
    font-size: 1.125rem;
    font-weight: 700;
    color: #1a1a2e;
}

.session-recovery-desc {
    margin: 0 0 1.5rem;
    color: #4a4a68;
    line-height: 1.5;
}

.session-recovery-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.session-recovery-btn-fresh {
    padding: 0.625rem 1.25rem;
    border: 2px solid #6b7280;
    border-radius: 0.375rem;
    background: #fff;
    color: #374151;
    font-weight: 600;
    cursor: pointer;
}

.session-recovery-btn-fresh:hover {
    background: #f9fafb;
}

.session-recovery-btn-resume {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 0.375rem;
    background: #4f46e5;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

.session-recovery-btn-resume:hover {
    background: #4338ca;
}
