﻿/* ===== Modern modal polish (non-breaking upgrade) ===== */

/* Backdrop: darker tint + glass blur + fade-in */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(10, 15, 25, 0.45);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    animation: mb-fade-in 180ms ease-out both;
    z-index: 999;
}

@keyframes mb-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Modal panel: glass surface, better elevation, smooth pop */
.modal.modern {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-48%) scale(.98);
    width: min(720px, 94vw);
    background: linear-gradient(180deg, rgba(255,255,255,.85), rgba(255,255,255,.90));
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(0,0,0,.06);
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0,0,0,.25), 0 2px 8px rgba(0,0,0,.08);
    padding: 0; /* we’ll pad inner sections */
    overflow: hidden; /* rounded corners apply to children */
    animation: modal-pop 220ms cubic-bezier(.2,.7,.2,1) both;
    z-index: 1000;
}

@keyframes modal-pop {
    from {
        opacity: 0;
        transform: translate(-50%,-44%) scale(.96);
    }

    to {
        opacity: 1;
        transform: translate(-50%,-50%) scale(1);
    }
}

/* Header: clean bar with divider and better spacing */
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(255,255,255,.88));
    border-bottom: 1px solid rgba(0,0,0,.06);
}

    .modal-header h3 {
        font-size: 1.05rem;
        line-height: 1.25rem;
        font-weight: 700;
        letter-spacing: .2px;
        margin: 0;
    }

/* Body: comfortable spacing and scroll containment */
.modal .form-grid,
.modal .modal-body {
    padding: 1rem 1.25rem 0 1.25rem;
}

.modal .modal-body {
    max-height: min(60vh, 520px);
    overflow: auto;
}

/* Footer: sticky actions with subtle top divider */
.modal-actions {
    position: sticky;
    bottom: 0;
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    padding: .85rem 1.25rem;
    background: linear-gradient(180deg, rgba(255,255,255,.9), rgba(255,255,255,.96));
    border-top: 1px solid rgba(0,0,0,.06);
}

/* Icon button: bigger hit area + hover/active states */
.icon-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: .35rem .5rem;
    border-radius: 10px;
    color: #111;
    transition: transform .1s ease, background-color .12s ease, color .12s ease;
}

    .icon-btn:hover {
        background: rgba(0,0,0,.06);
    }

    .icon-btn:active {
        transform: translateY(1px) scale(.98);
    }

    .icon-btn.close {
        color: #444;
    }

        .icon-btn.close:hover {
            background: rgba(0,0,0,.07);
            color: #111;
        }

/* Inputs: tighten vertical rhythm slightly inside modals */
.modal .form-grid > div label {
    display: grid;
    gap: .35rem;
    font-size: .92rem;
}

.modal input[type="text"],
.modal input[type="date"],
.modal input[type="number"],
.modal textarea,
.modal select {
    border: 1px solid rgba(0,0,0,.12);
    border-radius: 10px;
    padding: .55rem .65rem;
    outline: none;
    transition: border-color .12s ease, box-shadow .12s ease;
    background: white;
}

.modal textarea {
    min-height: 90px;
}

    .modal input:focus,
    .modal select:focus,
    .modal textarea:focus {
        border-color: #2962ff;
        box-shadow: 0 0 0 3px rgba(41,98,255,.12);
    }

/* Buttons: ensure elevated style in modal context */
.modal .btn-primary {
    box-shadow: 0 6px 16px rgba(41,98,255,.28);
}

    .modal .btn-primary:active {
        transform: translateY(1px);
        box-shadow: 0 4px 12px rgba(41,98,255,.22);
    }

/* Tables in modals: subtle separators + compact padding */
.modal .grid {
    width: 100%;
    border-collapse: collapse;
    margin: .75rem 1.25rem 1rem;
}

    .modal .grid th, .modal .grid td {
        border-bottom: 1px solid rgba(0,0,0,.06);
        padding: .5rem .25rem;
        text-align: left;
    }

/* Responsive: smaller screens get edge-to-edge comfort */
@media (max-width: 560px) {
    .modal.modern {
        width: 96vw;
    }

    .modal .form-grid {
        grid-template-columns: 1fr !important;
    }

    .modal .modal-actions {
        justify-content: stretch;
    }

        .modal .modal-actions .btn {
            flex: 1;
        }
}

/* Backdrop */
.modal-backdrop.modern {
    position: fixed;
    inset: 0;
    background: rgba(30, 30, 30, 0.55);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    z-index: 999;
    animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Panel */
.modal.modern {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(720px, 95vw);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
    overflow: hidden;
    z-index: 1000;
    animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
    from {
        transform: translate(-50%, calc(-50% + 40px));
        opacity: 0;
    }

    to {
        transform: translate(-50%, -50%);
        opacity: 1;
    }
}

/* Header / footer / buttons */
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: #f9f9f9;
    border-bottom: 1px solid #e5e5e5;
}

    .modal-header h3 {
        margin: 0;
        font-size: 1.1rem;
        font-weight: 600;
    }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    padding: .85rem 1.25rem;
    background: #f9f9f9;
    border-top: 1px solid #e5e5e5;
}

.icon-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: .35rem .5rem;
    border-radius: 8px;
    transition: background-color .15s, transform .1s;
}

    .icon-btn:hover {
        background: rgba(0,0,0,.06);
    }

    .icon-btn:active {
        transform: scale(.96);
    }

