﻿/* ==========================================================
   GLOBAL FORM MODAL (fm-*)
   Reusable glass-style modal for create/edit/import flows
   No Bootstrap required
   ========================================================== */

/* -------- OVERLAY -------- */

.fm-overlay {
    position: fixed;
    inset: 0;
    z-index: 1400; /* above sidebar, header, etc. */

    display: none; /* JS will typically set display:block/flex */
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.55), rgba(15, 23, 42, 0.85));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

    /* If your openFormModal adds a class, this is optional helper: */
    .fm-overlay.fm-open {
        display: flex;
    }

/* -------- DIALOG SHELL -------- */

.fm-dialog {
    width: 100%;
    max-width: 560px;
    margin: 24px;
    border-radius: 16px;
    background: linear-gradient( 135deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.97) );
    box-shadow: 0 22px 55px rgba(15, 23, 42, 0.35), 0 0 0 1px rgba(148, 163, 184, 0.24);
    color: #0f172a;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", sans-serif;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 48px);
    overflow: hidden;
}

/* Compact layout on very small devices */
@media (max-width: 640px) {
    .fm-dialog {
        margin: 0;
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
}

/* -------- HEADER -------- */

.fm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px 10px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.9);
}

    .fm-header h3 {
        margin: 0;
        font-size: 1rem;
        font-weight: 600;
        letter-spacing: 0.01em;
        color: #0f172a;
    }

/* Close button (×) */
.fm-close {
    border: none;
    background: transparent;
    padding: 4px 8px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    color: #6b7280;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease-out, color 0.15s ease-out, transform 0.08s ease-out;
}

    .fm-close:hover {
        background-color: rgba(226, 232, 240, 0.9);
        color: #111827;
        transform: translateY(-0.5px);
    }

/* -------- BODY -------- */

.fm-body {
    padding: 14px 20px 16px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

    /* Scrollbar styling (non-essential) */
    .fm-body::-webkit-scrollbar {
        width: 8px;
    }

    .fm-body::-webkit-scrollbar-track {
        background: transparent;
    }

    .fm-body::-webkit-scrollbar-thumb {
        background: rgba(148, 163, 184, 0.8);
        border-radius: 999px;
    }

/* -------- FOOTER -------- */

.fm-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    padding: 10px 20px 14px;
    border-top: 1px solid rgba(226, 232, 240, 0.9);
    background: linear-gradient( to top, rgba(248, 250, 252, 0.98), rgba(248, 250, 252, 0.92) );
}

/* -------- BUTTONS -------- */

.fm-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 88px;
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.16s ease-out, color 0.16s ease-out, box-shadow 0.16s ease-out, transform 0.08s ease-out;
}

/* Primary action */
.fm-btn-primary {
    background: radial-gradient(circle at top left, #2563eb, #1d4ed8);
    color: #f9fafb;
    border-color: rgba(37, 99, 235, 0.2);
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.35);
}

    .fm-btn-primary:hover {
        background: radial-gradient(circle at top left, #1d4ed8, #1e40af);
        box-shadow: 0 16px 35px rgba(37, 99, 235, 0.42);
        transform: translateY(-1px);
    }

    .fm-btn-primary:active {
        transform: translateY(0);
        box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
    }

/* Secondary / Cancel */
.fm-btn-secondary {
    background: rgba(248, 250, 252, 0.9);
    color: #374151;
    border-color: rgba(209, 213, 219, 0.9);
}

    .fm-btn-secondary:hover {
        background: #e5e7eb;
    }

/* Disabled state */
.fm-btn:disabled,
.fm-btn[disabled] {
    opacity: 0.6;
    cursor: default;
    box-shadow: none;
    transform: none;
}

/* -------- FORM FIELD GROUPS (used by JS) -------- */

.fm-field-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

    .fm-field-group label {
        font-size: 0.78rem;
        font-weight: 500;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        color: #6b7280;
    }

/* Read-only pill (Account name, etc.) */
.fm-field-readonly {
    padding: 8px 11px;
    border-radius: 11px;
    background: rgba(248, 250, 252, 0.95);
    border: 1px solid rgba(226, 232, 240, 0.9);
    font-size: 0.88rem;
    color: #111827;
}

/* Inputs inside modal */
.fm-field-group input[type="text"],
.fm-field-group input[type="number"],
.fm-field-group input[type="file"],
.fm-field-group input[type="date"],
.fm-field-group select,
.fm-field-group textarea {
    width: 100%;
    border-radius: 11px;
    border: 1px solid rgba(209, 213, 219, 0.95);
    padding: 8px 10px;
    font-size: 0.9rem;
    color: #111827;
    background-color: #ffffff;
    transition: border-color 0.16s ease-out, box-shadow 0.16s ease-out, background-color 0.16s ease-out;
}

.fm-field-group input[type="file"] {
    padding: 6px 8px;
}

.fm-field-group textarea {
    min-height: 80px;
    resize: vertical;
}

    .fm-field-group input:focus,
    .fm-field-group select:focus,
    .fm-field-group textarea:focus {
        outline: none;
        border-color: #2563eb;
        box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.35);
    }

/* Help text (used for CSV hints) */
.fm-help-text {
    margin: 2px 0 0;
    font-size: 0.78rem;
    color: #6b7280;
}

/* -------- SMALL TYPOGRAPHY HELPERS -------- */

.fm-body p {
    margin: 0 0 8px;
    font-size: 0.9rem;
    color: #4b5563;
}

.fm-body strong {
    color: #111827;
}

.fm-overlay.fm-open,
.fm-overlay.show {
    display: flex;
}
