/* =========================================================================
   MODALS - Modal Dialog Styles
   ========================================================================= */

/**
 * Modal styles for dialogs, confirmations, and overlay content.
 * Built on Bootstrap modals with BusOva theming.
 */

/* ---------------------------------------------------------------------
   Modal Backdrop
   --------------------------------------------------------------------- */

.modal-backdrop {
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-backdrop.show {
    opacity: 1;
}

/* ---------------------------------------------------------------------
   Modal Dialog
   --------------------------------------------------------------------- */

.modal-dialog {
    margin: 1.75rem auto;
}

.modal-dialog-centered {
    min-height: calc(100% - 3.5rem);
}

.modal-dialog-scrollable {
    height: calc(100% - 3.5rem);
}

.modal-dialog-scrollable .modal-content {
    max-height: 100%;
    overflow: hidden;
}

.modal-dialog-scrollable .modal-body {
    overflow-y: auto;
}

/* ---------------------------------------------------------------------
   Modal Content
   --------------------------------------------------------------------- */

.modal-content {
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 0.75rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

/* ---------------------------------------------------------------------
   Modal Header
   --------------------------------------------------------------------- */

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    border-top-left-radius: calc(0.75rem - 1px);
    border-top-right-radius: calc(0.75rem - 1px);
}

.modal-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
    margin: 0;
    line-height: 1.5;
}

.modal-title i,
.modal-title svg {
    color: var(--accent);
    margin-right: 0.5rem;
}

/* Close button */
.modal-header .btn-close {
    padding: 0.5rem;
    margin: -0.5rem -0.5rem -0.5rem auto;
    opacity: 0.5;
    transition: opacity 0.15s ease;
}

.modal-header .btn-close:hover {
    opacity: 0.85;
}

.modal-header .btn-close:focus {
    outline: none;
    box-shadow: 0 0 0 0.2rem var(--accent-soft);
}

/* ---------------------------------------------------------------------
   Modal Body
   --------------------------------------------------------------------- */

.modal-body {
    position: relative;
    flex: 1 1 auto;
    padding: 1rem;
    font-size: 0.9rem;
    color: var(--text-main);
}

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

/* ---------------------------------------------------------------------
   Modal Footer
   --------------------------------------------------------------------- */

.modal-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    background-color: var(--bg-card-soft);
    border-top: 1px solid var(--border-subtle);
    border-bottom-left-radius: calc(0.75rem - 1px);
    border-bottom-right-radius: calc(0.75rem - 1px);
}

/* Full-width footer buttons */
.modal-footer-stack {
    flex-direction: column;
}

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

/* ---------------------------------------------------------------------
   Modal Sizes
   --------------------------------------------------------------------- */

.modal-sm {
    max-width: 300px;
}

.modal-lg {
    max-width: 800px;
}

.modal-xl {
    max-width: 1140px;
}

/* ---------------------------------------------------------------------
   Fullscreen Modals
   --------------------------------------------------------------------- */

.modal-fullscreen {
    width: 100vw;
    max-width: none;
    height: 100%;
    margin: 0;
}

.modal-fullscreen .modal-content {
    height: 100%;
    border: 0;
    border-radius: 0;
}

.modal-fullscreen .modal-header {
    border-radius: 0;
}

.modal-fullscreen .modal-footer {
    border-radius: 0;
}

/* Responsive fullscreen */
@media (max-width: 575.98px) {
    .modal-fullscreen-sm-down {
        width: 100vw;
        max-width: none;
        height: 100%;
        margin: 0;
    }

    .modal-fullscreen-sm-down .modal-content {
        height: 100%;
        border: 0;
        border-radius: 0;
    }
}

/* ---------------------------------------------------------------------
   Modal Variants
   --------------------------------------------------------------------- */

/* Confirmation modal (danger) */
.modal-danger .modal-header {
    background-color: rgba(220, 53, 69, 0.1);
    border-bottom-color: rgba(220, 53, 69, 0.2);
}

.modal-danger .modal-title {
    color: #dc3545;
}

/* Success modal */
.modal-success .modal-header {
    background-color: rgba(25, 135, 84, 0.1);
    border-bottom-color: rgba(25, 135, 84, 0.2);
}

.modal-success .modal-title {
    color: #198754;
}

/* Warning modal */
.modal-warning .modal-header {
    background-color: rgba(255, 193, 7, 0.1);
    border-bottom-color: rgba(255, 193, 7, 0.2);
}

.modal-warning .modal-title {
    color: #856404;
}

/* ---------------------------------------------------------------------
   Modal Animations
   --------------------------------------------------------------------- */

.modal.fade .modal-dialog {
    transform: translateY(-20px);
    transition: transform 0.2s ease-out;
}

.modal.show .modal-dialog {
    transform: translateY(0);
}

/* Slide-up animation */
.modal.modal-slide-up .modal-dialog {
    transform: translateY(50px);
}

.modal.modal-slide-up.show .modal-dialog {
    transform: translateY(0);
}

/* Scale animation */
.modal.modal-scale .modal-dialog {
    transform: scale(0.95);
    opacity: 0;
}

.modal.modal-scale.show .modal-dialog {
    transform: scale(1);
    opacity: 1;
}

/* ---------------------------------------------------------------------
   Dark Theme Adjustments
   --------------------------------------------------------------------- */

body.theme-dark .modal-backdrop {
    background-color: rgba(0, 0, 0, 0.7);
}

body.theme-dark .modal-content {
    background-color: var(--bg-card);
    border-color: var(--border-subtle);
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

body.theme-dark .modal-header {
    border-bottom-color: var(--border-subtle);
}

body.theme-dark .modal-header,
body.theme-dark .modal-title {
    color: #fff;
}

body.theme-dark .modal-body {
    color: var(--text-main);
}

/* Muted text inside modals */
body.theme-dark .modal-body .text-muted,
body.theme-dark .modal-body small {
    color: #cfd5e6 !important;
}

body.theme-dark .modal-footer {
    background-color: var(--bg-card-soft);
    border-top-color: var(--border-subtle);
}

/* Dark theme close button */
body.theme-dark .modal-header .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Dark theme modal variants */
body.theme-dark .modal-danger .modal-header {
    background-color: rgba(220, 53, 69, 0.15);
}

body.theme-dark .modal-danger .modal-title {
    color: #f5a3ab;
}

body.theme-dark .modal-success .modal-header {
    background-color: rgba(25, 135, 84, 0.15);
}

body.theme-dark .modal-success .modal-title {
    color: #75d9a3;
}

body.theme-dark .modal-warning .modal-header {
    background-color: rgba(255, 193, 7, 0.15);
}

body.theme-dark .modal-warning .modal-title {
    color: #ffe066;
}

/* ---------------------------------------------------------------------
   Responsive Adjustments
   --------------------------------------------------------------------- */

@media (max-width: 576px) {
    .modal-dialog {
        margin: 0.5rem;
    }

    .modal-dialog-centered {
        min-height: calc(100% - 1rem);
    }

    .modal-content {
        border-radius: 0.5rem;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 0.75rem;
    }

    .modal-title {
        font-size: 0.95rem;
    }
}

@media (min-width: 576px) {
    .modal-dialog {
        max-width: 500px;
        margin: 1.75rem auto;
    }
}
