/* =========================================================
   AluminiumGlass
   modal.css
   Global Modal / Dialog System
   ========================================================= */

/* ---------------------------------------------------------
   1. Modal Overlay
   --------------------------------------------------------- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 10000;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 20px;

    background: rgba(15, 23, 42, 0.62);

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transition:
        opacity 0.2s ease,
        visibility 0.2s ease;
}

.modal.is-open,
.modal.open,
.modal.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}


/* ---------------------------------------------------------
   2. Prevent Background Scroll
   --------------------------------------------------------- */

body.modal-open {
    overflow: hidden;
}


/* ---------------------------------------------------------
   3. Modal Dialog
   --------------------------------------------------------- */

.modal-dialog {
    position: relative;

    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - 40px);

    display: flex;
    flex-direction: column;

    background: #ffffff;
    color: #1f2937;

    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 14px;

    box-shadow:
        0 20px 50px rgba(15, 23, 42, 0.20),
        0 8px 20px rgba(15, 23, 42, 0.10);

    overflow: hidden;

    transform: translateY(15px) scale(0.98);

    transition:
        transform 0.2s ease,
        opacity 0.2s ease;

    opacity: 0;
}

.modal.is-open .modal-dialog,
.modal.open .modal-dialog,
.modal.show .modal-dialog {
    transform: translateY(0) scale(1);
    opacity: 1;
}


/* ---------------------------------------------------------
   4. Modal Sizes
   --------------------------------------------------------- */

.modal-dialog.modal-sm {
    max-width: 400px;
}

.modal-dialog.modal-md {
    max-width: 560px;
}

.modal-dialog.modal-lg {
    max-width: 820px;
}

.modal-dialog.modal-xl {
    max-width: 1100px;
}

.modal-dialog.modal-xxl {
    max-width: 1400px;
}

.modal-dialog.modal-full {
    width: calc(100vw - 40px);
    max-width: none;
    height: calc(100vh - 40px);
    max-height: none;
}


/* ---------------------------------------------------------
   5. Modal Header
   --------------------------------------------------------- */

.modal-header {
    position: relative;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;

    padding: 18px 22px;

    border-bottom: 1px solid #e5e7eb;

    background: #ffffff;

    flex-shrink: 0;
}

.modal-title {
    margin: 0;

    font-size: 20px;
    line-height: 1.35;
    font-weight: 700;

    color: #111827;
}

.modal-subtitle {
    margin: 4px 0 0;

    font-size: 13px;
    line-height: 1.5;

    color: #6b7280;
}


/* ---------------------------------------------------------
   6. Close Button
   --------------------------------------------------------- */

.modal-close {
    width: 38px;
    height: 38px;

    flex: 0 0 38px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 0;

    border: 0;
    border-radius: 8px;

    background: transparent;
    color: #6b7280;

    font-size: 24px;
    line-height: 1;

    cursor: pointer;

    transition:
        background-color 0.15s ease,
        color 0.15s ease,
        transform 0.15s ease;
}

.modal-close:hover {
    background: #f3f4f6;
    color: #111827;
}

.modal-close:active {
    transform: scale(0.94);
}

.modal-close:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.25);
    outline-offset: 2px;
}


/* ---------------------------------------------------------
   7. Modal Body
   --------------------------------------------------------- */

.modal-body {
    padding: 22px;

    overflow-y: auto;
    overscroll-behavior: contain;

    flex: 1 1 auto;

    min-height: 0;
}

.modal-body.no-padding {
    padding: 0;
}


/* ---------------------------------------------------------
   8. Modal Footer
   --------------------------------------------------------- */

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;

    gap: 10px;

    padding: 16px 22px;

    border-top: 1px solid #e5e7eb;

    background: #ffffff;

    flex-shrink: 0;
}

.modal-footer.space-between {
    justify-content: space-between;
}

.modal-footer.center {
    justify-content: center;
}

.modal-footer.start {
    justify-content: flex-start;
}


/* ---------------------------------------------------------
   9. Modal Backdrop Variations
   --------------------------------------------------------- */

.modal.modal-light {
    background: rgba(255, 255, 255, 0.72);
}

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

.modal.modal-transparent {
    background: transparent;
}


/* ---------------------------------------------------------
   10. Confirmation Modal
   --------------------------------------------------------- */

.modal-confirm {
    text-align: center;
}

.modal-confirm .modal-body {
    padding: 30px 24px 20px;
}

.modal-confirm-icon {
    width: 56px;
    height: 56px;

    margin: 0 auto 16px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background: #eff6ff;
    color: #2563eb;

    font-size: 24px;
    font-weight: 700;
}

.modal-confirm-title {
    margin: 0 0 8px;

    font-size: 20px;
    font-weight: 700;

    color: #111827;
}

.modal-confirm-message {
    margin: 0;

    font-size: 14px;
    line-height: 1.6;

    color: #6b7280;
}


/* ---------------------------------------------------------
   11. Danger Confirmation
   --------------------------------------------------------- */

.modal-danger .modal-confirm-icon {
    background: #fef2f2;
    color: #dc2626;
}

.modal-danger .modal-confirm-title {
    color: #991b1b;
}


/* ---------------------------------------------------------
   12. Success Modal
   --------------------------------------------------------- */

.modal-success .modal-confirm-icon {
    background: #ecfdf5;
    color: #059669;
}


/* ---------------------------------------------------------
   13. Warning Modal
   --------------------------------------------------------- */

.modal-warning .modal-confirm-icon {
    background: #fffbeb;
    color: #d97706;
}


/* ---------------------------------------------------------
   14. Info Modal
   --------------------------------------------------------- */

.modal-info .modal-confirm-icon {
    background: #eff6ff;
    color: #2563eb;
}


/* ---------------------------------------------------------
   15. Form Modal
   --------------------------------------------------------- */

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.modal-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.modal-form label {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

.modal-form input,
.modal-form select,
.modal-form textarea {
    width: 100%;

    padding: 11px 13px;

    border: 1px solid #d1d5db;
    border-radius: 8px;

    background: #ffffff;
    color: #111827;

    font: inherit;

    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}

.modal-form input:focus,
.modal-form select:focus,
.modal-form textarea:focus {
    border-color: #2563eb;

    outline: none;

    box-shadow:
        0 0 0 3px rgba(37, 99, 235, 0.12);
}

.modal-form textarea {
    min-height: 120px;
    resize: vertical;
}


/* ---------------------------------------------------------
   16. Loading State
   --------------------------------------------------------- */

.modal-loading {
    display: flex;

    align-items: center;
    justify-content: center;

    min-height: 180px;

    padding: 30px;

    color: #6b7280;
}

.modal-spinner {
    width: 34px;
    height: 34px;

    border: 3px solid #e5e7eb;
    border-top-color: #2563eb;

    border-radius: 50%;

    animation: modal-spin 0.7s linear infinite;
}

@keyframes modal-spin {
    to {
        transform: rotate(360deg);
    }
}


/* ---------------------------------------------------------
   17. Image / Gallery Modal
   --------------------------------------------------------- */

.modal-image {
    max-width: 95vw;
    max-height: 90vh;

    background: transparent;

    border: 0;
    box-shadow: none;

    overflow: visible;
}

.modal-image .modal-body {
    padding: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    overflow: hidden;
}

.modal-image img {
    display: block;

    max-width: 100%;
    max-height: calc(100vh - 100px);

    object-fit: contain;

    border-radius: 8px;
}


/* ---------------------------------------------------------
   18. Fullscreen Modal
   --------------------------------------------------------- */

.modal-fullscreen {
    padding: 0;
}

.modal-fullscreen .modal-dialog {
    width: 100vw;
    height: 100vh;

    max-width: none;
    max-height: none;

    border-radius: 0;
}


/* ---------------------------------------------------------
   19. Side Drawer Modal
   --------------------------------------------------------- */

.modal-drawer {
    align-items: stretch;
    justify-content: flex-end;
}

.modal-drawer .modal-dialog {
    height: 100%;
    max-height: none;

    margin: 0;

    border-radius: 0;

    transform: translateX(100%);
}

.modal-drawer.is-open .modal-dialog,
.modal-drawer.open .modal-dialog,
.modal-drawer.show .modal-dialog {
    transform: translateX(0);
}

.modal-drawer-left {
    justify-content: flex-start;
}

.modal-drawer-left .modal-dialog {
    transform: translateX(-100%);
}

.modal-drawer-bottom {
    align-items: flex-end;
}

.modal-drawer-bottom .modal-dialog {
    width: 100%;
    max-width: none;
    max-height: 90vh;

    transform: translateY(100%);
}

.modal-drawer-bottom.is-open .modal-dialog,
.modal-drawer-bottom.open .modal-dialog,
.modal-drawer-bottom.show .modal-dialog {
    transform: translateY(0);
}


/* ---------------------------------------------------------
   20. Modal Table
   --------------------------------------------------------- */

.modal-table {
    width: 100%;

    border-collapse: collapse;

    font-size: 14px;
}

.modal-table th,
.modal-table td {
    padding: 12px;

    text-align: left;

    border-bottom: 1px solid #e5e7eb;
}

.modal-table th {
    font-weight: 600;
    color: #374151;
    background: #f9fafb;
}

.modal-table td {
    color: #4b5563;
}


/* ---------------------------------------------------------
   21. Modal Alert
   --------------------------------------------------------- */

.modal-alert {
    display: flex;
    align-items: flex-start;

    gap: 12px;

    padding: 13px 14px;

    margin-bottom: 18px;

    border: 1px solid transparent;
    border-radius: 8px;

    font-size: 14px;
    line-height: 1.5;
}

.modal-alert-info {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.modal-alert-success {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #047857;
}

.modal-alert-warning {
    background: #fffbeb;
    border-color: #fde68a;
    color: #b45309;
}

.modal-alert-danger {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}


/* ---------------------------------------------------------
   22. Modal Buttons
   --------------------------------------------------------- */

.modal-footer .btn {
    min-height: 40px;

    padding: 9px 16px;

    border-radius: 8px;

    font-size: 14px;
    font-weight: 600;

    cursor: pointer;
}


/* ---------------------------------------------------------
   23. Nested Modal Protection
   --------------------------------------------------------- */

.modal.modal-nested {
    z-index: 11000;
}

.modal.modal-top {
    z-index: 12000;
}


/* ---------------------------------------------------------
   24. Accessibility
   --------------------------------------------------------- */

.modal[aria-hidden="true"] {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

.modal[aria-hidden="false"] {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}


/* ---------------------------------------------------------
   25. Reduced Motion
   --------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {

    .modal,
    .modal-dialog,
    .modal-close {
        transition: none;
    }

    .modal-spinner {
        animation: none;
    }
}


/* ---------------------------------------------------------
   26. Mobile
   --------------------------------------------------------- */

@media (max-width: 767px) {

    .modal {
        padding: 12px;
    }

    .modal-dialog {
        max-height: calc(100vh - 24px);

        border-radius: 12px;
    }

    .modal-header {
        padding: 15px 16px;
    }

    .modal-title {
        font-size: 18px;
    }

    .modal-body {
        padding: 18px 16px;
    }

    .modal-footer {
        padding: 13px 16px;

        flex-wrap: wrap;
    }

    .modal-footer .btn {
        flex: 1 1 auto;
    }

    .modal-dialog.modal-lg,
    .modal-dialog.modal-xl,
    .modal-dialog.modal-xxl {
        max-width: 100%;
    }

    .modal-drawer .modal-dialog {
        width: 92%;
    }

    .modal-drawer-bottom .modal-dialog {
        width: 100%;
    }
}


/* ---------------------------------------------------------
   27. Very Small Screens
   --------------------------------------------------------- */

@media (max-width: 420px) {

    .modal {
        padding: 8px;
    }

    .modal-dialog {
        max-height: calc(100vh - 16px);
        border-radius: 10px;
    }

    .modal-header {
        gap: 10px;
    }

    .modal-close {
        width: 34px;
        height: 34px;
        flex-basis: 34px;
    }

    .modal-body {
        padding: 16px 14px;
    }

    .modal-footer {
        flex-direction: column;
        align-items: stretch;
    }

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


/* ---------------------------------------------------------
   28. Print
   --------------------------------------------------------- */

@media print {

    .modal {
        position: static;

        display: none !important;

        background: none;
    }
}