﻿:root {
    /* Aligned with pos.css for visual consistency */
    --feature-accent: #1d4ed8; /* brand blue (was 
#2f6aa3) */
    --feature-accent-dk: #1e40af;
    --feature-accent-lt: #eff6ff;
    --feature-border: #e2e8f0; /* hairline (was 
#787878) */
    --feature-border-2: #cbd5e1; /* mid */
    --feature-ink: #0f172a;
    --feature-muted: #64748b;
    --feature-faint: #94a3b8;
    /* Legacy aliases preserved for any code that referenced them */
    --card: #ffffff;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --primary: #16a34a; /* green for success actions */
    --primary-ink: #14532d;
    --secondary: #1d4ed8;
    --danger: #dc2626;
    --warning: #d97706;
    --success: #16a34a;
    --modal-radius: 12px;
    --modal-radius-sm: 8px;
    --modal-transition: 180ms cubic-bezier(.4, 0, .2, 1);
}
/* ─────────────────────────────────────────────────────────────
   OVERLAY — semi-transparent backdrop with blur
   ───────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: auto;
    padding: 4vh 2vw;
    background: rgba(15, 23, 42, .45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1050;
    animation: modalFadeIn .15s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}
/* ─────────────────────────────────────────────────────────────
   MODAL CARDS — multiple shells (modal-box, modal-content)
   ───────────────────────────────────────────────────────────── */
/* Small fixed-size modal */
.modal-box {
    background: #fff;
    padding: 20px;
    width: 420px;
    max-width: calc(100vw - 32px);
    border: 1px solid var(--feature-border);
    border-radius: var(--modal-radius);
    box-shadow: 0 20px 50px rgba(15, 23, 42, .18), 0 4px 12px rgba(15, 23, 42, .08);
    animation: modalSlideIn .18s ease-out;
}
/* Generic body */
.modal-body {
    padding: 18px;
    max-height: 70vh;
    overflow-y: auto;
    background: #fff;
}
/* Big card shell — used by most form-style modals */
.modal-content {
    display: flex;
    flex-direction: column;
    width: min(80vw, 1900px);
    max-height: 92vh;
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--feature-border);
    border-radius: var(--modal-radius);
    box-shadow: 0 20px 50px rgba(15, 23, 42, .18), 0 4px 12px rgba(15, 23, 42, .08);
    animation: modalSlideIn .18s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(.99);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
/* Route-modal helper container */
.route-modal-body {
    display: flex;
    flex-direction: column;
    position: relative;
    padding: 20px;
    margin: 10px auto;
    width: 90%;
    max-width: 1500px;
    min-height: 200px;
    background: #fff;
    border: 1px solid var(--feature-border);
    border-radius: var(--modal-radius);
    box-shadow: 0 4px 12px rgba(15, 23, 42, .08);
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 13px;
    color: var(--feature-ink);
}

    .route-modal-body h2 {
        font-size: 18px;
        font-weight: 600;
        margin-bottom: 10px;
        color: var(--feature-ink);
    }

    .route-modal-body p {
        line-height: 1.6;
        margin-bottom: 12px;
        color: var(--feature-muted);
    }

    .route-modal-body.scrollable {
        max-height: 400px;
        overflow-y: auto;
    }
/* ─────────────────────────────────────────────────────────────
   HEADER
   ───────────────────────────────────────────────────────────── */
.modal-header {
    position: sticky;
    top: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    background: #fff;
    border-bottom: 1px solid var(--feature-border);
    color: var(--feature-ink);
}

.modal-title {
    margin: 0;
    font-weight: 600;
    font-size: 15px;
    color: var(--feature-ink);
    display: flex;
    align-items: center;
    gap: 8px;
}

    .modal-title i {
        color: var(--feature-accent);
        font-size: 14px;
    }

.modal-close {
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--feature-border);
    background: #fff;
    color: var(--feature-muted);
    border-radius: 7px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all var(--modal-transition);
}

    .modal-close:hover {
        background: #f8fafc;
        color: var(--feature-ink);
        border-color: var(--feature-border-2);
    }
/* ─────────────────────────────────────────────────────────────
   ASSIGNMENT / META BANNER INSIDE HEADER OR BODY
   ───────────────────────────────────────────────────────────── */
.assignment-details {
    display: flex;
    gap: 20px;
    align-items: center;
    white-space: nowrap;
    font-size: 12.5px;
    color: var(--feature-muted);
    background: #f8fafc;
    border: 1px solid var(--feature-border);
    border-radius: var(--modal-radius-sm);
    padding: 10px 14px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

    .assignment-details p {
        margin: 0;
        font-size: 12.5px;
    }

        .assignment-details p strong {
            color: var(--feature-ink);
            font-weight: 600;
            margin-right: 4px;
        }
/* ─────────────────────────────────────────────────────────────
   BODY / FORM
   ───────────────────────────────────────────────────────────── */
.modal-form {
    flex: 1 1 auto;
    overflow: auto;
    padding: 18px 18px 80px 18px; /* bottom padding so content doesn't hide under sticky footer */
    background: #fff;
}

.form-grid.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 16px;
}

.form-grid.one-col {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}
/* Native textareas inside modal-form */
.modal-form textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--feature-border-2);
    border-radius: var(--modal-radius-sm);
    font-size: 13px;
    color: var(--feature-ink);
    background: #fff;
    resize: vertical;
    font-family: inherit;
    transition: border-color var(--modal-transition), box-shadow var(--modal-transition);
}

    .modal-form textarea:focus {
        outline: none;
        border-color: var(--feature-accent);
        box-shadow: 0 0 0 3px rgba(29, 78, 216, .12);
    }
/* Scrollbars inside body */
.modal-form::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.route-modal-body.scrollable::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.modal-form::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
.route-modal-body.scrollable::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 8px;
    border: 2px solid #fff;
}

    .modal-form::-webkit-scrollbar-thumb:hover,
    .modal-body::-webkit-scrollbar-thumb:hover {
        background: #94a3b8;
    }

.modal-form::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track {
    background: #fff;
}
/* ─────────────────────────────────────────────────────────────
   FOOTER ACTIONS
   ───────────────────────────────────────────────────────────── */
.modal-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 12px 18px;
    background: #fafbfc;
    border-top: 1px solid var(--feature-border);
    min-height: 60px;
}

    .modal-actions .left-actions,
    .modal-actions .right-actions {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
    }

    .modal-actions .right-actions {
        margin-left: auto;
    }
/* Base button — neutral outlined */
/*.modal-actions .btn {
        height: 38px;
        padding: 0 14px;
        background: #fff;
        color: 
#334155;
        border: 1px solid var(--feature-border);
        border-radius: var(--modal-radius-sm);
        font-size: 12.5px;
        font-weight: 500;
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        font-family: inherit;
        transition: all var(--modal-transition);
    }
        .modal-actions .btn i {
            color: inherit;
            opacity: .9;
            font-size: 12px;
        }
        .modal-actions .btn:hover {
            background: 
#f8fafc;
            border-color: var(--feature-border-2);
        }
        .modal-actions .btn:focus-visible {
            outline: none;
            box-shadow: 0 0 0 3px rgba(29, 106, 163, .18);
        }
        .modal-actions .btn:disabled {
            opacity: .55;
            cursor: not-allowed;
        }*/
/* Primary — solid brand blue */
/*.modal-actions .btn.primary {
            background: var(--feature-accent);
            color: #fff;
            border-color: var(--feature-accent);
        }
            .modal-actions .btn.primary:hover {
                background: var(--feature-accent-dk);
                border-color: var(--feature-accent-dk);
            }*/
/* Success — solid green */
/*.modal-actions .btn.success {
            background: var(--success);
            color: #fff;
            border-color: var(--success);
        }
            .modal-actions .btn.success:hover {
                background: 
#15803d;
                border-color: 
#15803d;
            }*/
/* Danger — text only, soft red border so it doesn't shout */
/*.modal-actions .btn.danger {
            background: #fff;
            color: var(--danger);
            border-color: 
#fecaca;
        }
            .modal-actions .btn.danger:hover {
                background: 
#fef2f2;
                border-color: 
#fca5a5;
            }*/
/* Warning — amber */
/*.modal-actions .btn.warning {
            background: #fff;
            color: var(--warning);
            border-color: 
#fcd34d;
        }
            .modal-actions .btn.warning:hover {
                background: 
#fffbeb;
            }*/
/* Left-side status text (e.g. "Last saved …") */
.add-to-left {
    margin: 0;
    flex: 1;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px;
    color: var(--feature-muted);
}
/* ─────────────────────────────────────────────────────────────
   SIZE VARIANTS
   ───────────────────────────────────────────────────────────── */
.modal-content.modal-small-popup {
    width: min(480px, 92vw);
    max-height: 88vh;
}

.modal-content.modal-medium-popup {
    width: min(720px, 92vw);
    max-height: 92vh;
}

.modal-content.modal-large-popup {
    width: min(1100px, 92vw);
    max-height: 92vh;
}

.modal-content.modal-fullscreen {
    width: min(96vw, 1400px);
    max-height: 96vh;
}
/* ─────────────────────────────────────────────────────────────
   DRAG & RESIZE SUPPORT
   ───────────────────────────────────────────────────────────── */
/* Grab cursor on draggable headers */
.modal-header-row,
.modal-header-custom,
.modal-header {
    cursor: grab;
}

    .modal-header-row:active,
    .modal-header-custom:active,
    .modal-header:active {
        cursor: grabbing;
    }
/* Resize corner hint icon */
.afri-resize-hint {
    position: absolute;
    bottom: 5px;
    right: 5px;
    width: 18px;
    height: 18px;
    color: #cbd5e1;
    font-size: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 20;
    transform: rotate(90deg);
    opacity: 0.7;
    transition: opacity 0.15s, color 0.15s;
}

.modal-content:hover .afri-resize-hint,
.modal-content-custom:hover .afri-resize-hint,
.modal-box:hover .afri-resize-hint {
    opacity: 1;
    color: #94a3b8;
}
/* Ensure .modal-content stays as a flex column after JS override */
.modal-content {
    position: relative; /* needed for absolute .afri-resize-hint */
}
/* ─────────────────────────────────────────────────────────────
   RESPONSIVE
   ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .modal-content {
        width: 94vw;
        max-height: 94vh;
    }

    .form-grid.two-col {
        grid-template-columns: 1fr;
    }

    .modal-actions {
        flex-direction: column;
        align-items: stretch;
    }

        .modal-actions .right-actions {
            margin-left: 0;
        }

    .assignment-details {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        white-space: normal;
    }
}
