/* Modals
   Modals and confirmation dialogs */

/* ======= MODAL STYLES ======= */

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1050;
    backdrop-filter: blur(2px);
}

/* Global backdrop for Blazor modals (processing, dialogs, etc.) – dims page behind, does not hide it */
.modal-backdrop-formal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 26, 26, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(3px);
    animation: backdropFadeIn 0.25s ease-out;
}

@keyframes backdropFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Application card-style modals (Blazor components) */
.app-modal {
    background-color: var(--card-bg-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 600px;
    width: 100%;
    margin: 1.75rem;
    animation: modalFadeIn 0.3s ease-out;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 3.5rem);
}

/* Keep Bootstrap confirmation modal layout centered and full-screen */
.app-confirm-modal {
    background-color: transparent;
    border-radius: 0;
    box-shadow: none;
    max-width: none;
    width: 100%;
    margin: 0;
    display: block;
    z-index: 10000 !important;
    position: relative !important;
}

/* Force confirmation modal to appear above all other elements */
.app-confirm-modal.show {
    z-index: 10000 !important;
    position: fixed !important;
}

.app-confirm-modal[style*="z-index"] {
    z-index: 10000 !important;
}

/* Ensure confirmation modal backdrop appears above other modals */
.app-confirm-modal.show {
    z-index: 10000 !important;
}

/* Ensure confirmation modal backdrop has higher z-index */
.modal-backdrop.show + .app-confirm-modal,
.modal-backdrop.show ~ .app-confirm-modal {
    z-index: 10000 !important;
}

/* When confirmation modal is shown, ensure its backdrop is on top */
body.modal-open .app-confirm-modal {
    z-index: 10000 !important;
}

/* Ensure Bootstrap modal backdrop for confirmation appears above all other modals */
body.modal-open .modal-backdrop:last-of-type {
    z-index: 9999 !important;
}

/* Ensure confirmation modal appears above modal-backdrop-formal */
.modal-backdrop-formal ~ .app-confirm-modal,
.modal-backdrop-formal + .app-confirm-modal {
    z-index: 10000 !important;
}

/* Style confirmation modal content to look like app modals */
.app-confirm-modal .modal-content {
    border-radius: 22px;
    border: none;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.25);
    overflow: hidden;
    padding: 24px 24px 20px;
}

.app-confirm-modal .app-confirm-header {
    background: transparent;
    border-bottom: none;
    padding-top: 0;
    padding-bottom: 0.75rem;
}

.app-confirm-modal .app-confirm-header::before {
    display: none;
}

.app-confirm-modal .app-confirm-icon {
    width: 56px;
    height: 56px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.75rem auto;
    box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.9), 0 8px 18px rgba(0, 0, 0, 0.12);
    font-size: 1.4rem;
}

.app-confirm-modal .app-confirm-card--danger .app-confirm-icon {
    background: #fde2e4;
    color: #d6333c;
}

.app-confirm-modal .app-confirm-card--neutral .app-confirm-icon {
    background: #e0f2fe;
    color: #0ea5e9;
}

.app-confirm-modal .app-confirm-card--warning .app-confirm-icon {
    background: #fef3c7;
    color: #f59e0b;
}

.app-confirm-modal .modal-title {
    font-weight: 600;
    color: #111827;
    font-size: 1.15rem;
    margin: 0;
}

.app-confirm-modal .app-confirm-body {
    text-align: center;
    padding-top: 0;
    padding-bottom: 0.5rem;
}

.app-confirm-modal .app-confirm-message {
    margin: 0;
    color: #6b7280;
    font-size: 0.95rem;
}

.app-prompt-modal .app-prompt-input {
    margin-top: 0.75rem;
    text-align: inherit;
}

.app-confirm-modal .modal-footer {
    justify-content: center !important;
    gap: 1rem;
    border-top: none;
    padding-top: 0.75rem;
    width: 100%;
}

/* Remove green gradient line from shared modal footer styles */
.app-confirm-modal .modal-footer::before {
    display: none !important;
}

/* Custom confirm buttons */
.app-confirm-modal .btn-confirm-danger {
    background-color: #dc3545;
    border-color: #dc3545;
    color: #fff;
    min-width: 120px;
    font-weight: 600;
}

.app-confirm-modal .btn-confirm-danger:hover {
    background-color: #bb2d3b;
    border-color: #b02a37;
}

.app-confirm-modal .btn-confirm-primary {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
    min-width: 120px;
    font-weight: 600;
}

.app-confirm-modal .btn-confirm-primary:hover {
    background-color: #0b5ed7;
    border-color: #0a58ca;
}

.app-confirm-modal .btn-confirm-warning {
    background-color: #f59e0b;
    border-color: #f59e0b;
    color: #fff;
    min-width: 120px;
    font-weight: 600;
}

.app-confirm-modal .btn-confirm-warning:hover {
    background-color: #d97706;
    border-color: #b45309;
}

.app-confirm-modal .modal-footer .btn {
    min-width: 120px;
    border-radius: 999px;
}

.modal-sm {
    max-width: 400px;
}

.modal-lg {
    max-width: 800px;
}

.modal-xl {
    max-width: 1140px;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.modal-title {
    margin: 0;
    font-weight: 600;
    color: var(--primary-color);
    font-size: var(--font-size-lg);
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    margin: 0;
    color: var(--text-light);
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all var(--transition-fast);
}

    .modal-close:hover {
        background-color: rgba(0, 0, 0, 0.05);
        color: var(--text-color);
    }

.modal-body {
    padding: var(--spacing-lg);
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 1rem var(--spacing-lg);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
    background-color: rgba(0, 0, 0, 0.01);
}

html[dir="rtl"] .modal-footer {
    justify-content: flex-start;
}

.modal-backdrop.fade {
    opacity: 0;
    transition: opacity 0.15s linear;
}

.modal-backdrop.show {
    opacity: 1;
}

/* Fullscreen modal */
.modal-fullscreen {
    width: 100vw;
    max-width: none;
    height: 100vh;
    margin: 0;
    border-radius: 0;
}
