/* ═══════════════════════════════════════════════════════════
   StyleFlow SaaS - Modal System (Light Theme)
   Two modal patterns:
   1. .modal-backdrop / .custom-modal / .active  → JS-created modals (ui.alert, ui.confirm)
   2. .modal / .modal-content / .show            → Inline HTML modals (forms)
   ═══════════════════════════════════════════════════════════ */

/* ── Pattern 1: Dynamic Modals (modal-backdrop) ── */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.custom-modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    width: 95%;
    max-width: 480px;
    padding: 32px;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95) translateY(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-main);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-backdrop.active .custom-modal {
    transform: scale(1) translateY(0);
}

/* ── Pattern 2: Inline HTML Modals (.modal / .show) ── */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    width: 95%;
    max-width: 480px;
    padding: 32px;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95) translateY(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-main);
    max-height: 90vh;
    overflow-y: auto;
}

.modal.show .modal-content {
    transform: scale(1) translateY(0);
}

/* ── Shared Modal Elements ── */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: -32px;
    background: var(--surface);
    z-index: 10;
    padding: 32px 32px 16px 32px;
    margin: -32px -32px 24px -32px;
}

.modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 800;
    font-family: 'Outfit', sans-serif;
    color: var(--text-main);
    letter-spacing: -0.5px;
    text-transform: none;
}

.modal-body {
    margin-bottom: 32px;
    color: var(--text-muted);
    line-height: 1.6;
    font-size: 15px;
}

.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.close-btn {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-muted);
    padding: 0;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}
.close-btn:hover {
    background: var(--danger-light);
    color: var(--danger);
    border-color: var(--danger);
}

/* ── Modal Buttons ── */
.modal-btn {
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}

.modal-btn-primary {
    background: var(--primary);
    color: var(--text-main);
}

.modal-btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.modal-btn-ghost {
    background: var(--surface-alt);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.modal-btn-ghost:hover {
    background: var(--border);
}

.modal-btn-danger {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid transparent;
}
.modal-btn-danger:hover {
    background: var(--danger);
    color: white;
}

/* ── Responsive Modals ── */
@media (max-width: 480px) {
    .custom-modal, .modal-content {
        padding: 24px 20px;
        width: 92%;
    }

    .modal-footer {
        flex-direction: column-reverse;
        gap: 10px;
        align-items: stretch;
    }

    .modal-btn {
        width: 100%;
        padding: 12px;
        font-size: 15px;
    }

    .modal-header h3 {
        font-size: 18px;
    }
}
