/* ============================================================
   WemX Unified Modal System
   BEM: .wemx-modal__*
   Supports dark (.dark) and light (:root:not(.dark)) themes
   ============================================================ */

/* ----------------------------------------------------------
   Body lock
   ---------------------------------------------------------- */
body.wemx-modal-open {
    overflow: hidden;
}

/* ----------------------------------------------------------
   Backdrop
   ---------------------------------------------------------- */
.wemx-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 150ms ease;
}

.wemx-modal-backdrop.hidden {
    display: none;
}

.wemx-modal-backdrop.active {
    opacity: 1;
}

/* Light theme backdrop */
:root:not(.dark) .wemx-modal-backdrop {
    background: rgba(0, 0, 0, 0.4);
}

/* ----------------------------------------------------------
   Modal container
   ---------------------------------------------------------- */
.wemx-modal {
    position: relative;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    border-radius: 1rem;
    transform: scale(0.95) translateY(8px);
    transition: transform 250ms ease, opacity 250ms ease;
    opacity: 0;
}

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

/* Dark theme modal */
.dark .wemx-modal {
    background: #111;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
}

/* Light theme modal */
:root:not(.dark) .wemx-modal {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.15);
}

/* ----------------------------------------------------------
   Size variants
   ---------------------------------------------------------- */
.wemx-modal--sm { max-width: 360px; }
.wemx-modal--md { max-width: 460px; }
.wemx-modal--lg { max-width: 600px; }
.wemx-modal--xl { max-width: 800px; }

/* ----------------------------------------------------------
   Header
   ---------------------------------------------------------- */
.wemx-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
}

.wemx-modal__header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.wemx-modal__header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ----------------------------------------------------------
   Icon
   ---------------------------------------------------------- */
.wemx-modal__icon {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Icon variants — dark */
.dark .wemx-modal__icon--default {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
}

.dark .wemx-modal__icon--danger {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.dark .wemx-modal__icon--warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.dark .wemx-modal__icon--info {
    background: rgba(20, 184, 166, 0.15);
    color: #2dd4bf;
}

/* Icon variants — light */
:root:not(.dark) .wemx-modal__icon--default {
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
}

:root:not(.dark) .wemx-modal__icon--danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

:root:not(.dark) .wemx-modal__icon--warning {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

:root:not(.dark) .wemx-modal__icon--info {
    background: rgba(20, 184, 166, 0.1);
    color: #0d9488;
}

/* ----------------------------------------------------------
   Title
   ---------------------------------------------------------- */
.wemx-modal__title {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
}

.dark .wemx-modal__title {
    color: #f5f5f5;
}

:root:not(.dark) .wemx-modal__title {
    color: #111;
}

/* ----------------------------------------------------------
   Close button
   ---------------------------------------------------------- */
.wemx-modal__close {
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
    border: none;
    background: transparent;
    transition: background 150ms ease;
}

.dark .wemx-modal__close {
    color: #a0a0a0;
}

.dark .wemx-modal__close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #f5f5f5;
}

:root:not(.dark) .wemx-modal__close {
    color: #6b7280;
}

:root:not(.dark) .wemx-modal__close:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #111;
}

/* ----------------------------------------------------------
   Divider
   ---------------------------------------------------------- */
.wemx-modal__divider {
    height: 1px;
    margin: 0 1.5rem;
    border: none;
}

.dark .wemx-modal__divider {
    background: rgba(255, 255, 255, 0.06);
}

:root:not(.dark) .wemx-modal__divider {
    background: rgba(0, 0, 0, 0.06);
}

/* ----------------------------------------------------------
   Body
   ---------------------------------------------------------- */
.wemx-modal__body {
    padding: 1.25rem 1.5rem;
    font-size: 0.875rem;
    line-height: 1.6;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}

.dark .wemx-modal__body {
    color: #a0a0a0;
}

:root:not(.dark) .wemx-modal__body {
    color: #555;
}

/* ----------------------------------------------------------
   Footer
   ---------------------------------------------------------- */
.wemx-modal__footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.625rem;
    padding: 1rem 1.5rem 1.25rem;
}

/* ----------------------------------------------------------
   Buttons
   ---------------------------------------------------------- */
.wemx-modal__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5625rem 1.25rem;
    border-radius: 0.625rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    border: none;
    transition: background 150ms ease, opacity 150ms ease;
    text-decoration: none;
}

.wemx-modal__btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Secondary */
.dark .wemx-modal__btn--secondary {
    background: rgba(255, 255, 255, 0.06);
    color: #d1d5db;
}

.dark .wemx-modal__btn--secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
}

:root:not(.dark) .wemx-modal__btn--secondary {
    background: #f3f4f6;
    color: #374151;
}

:root:not(.dark) .wemx-modal__btn--secondary:hover:not(:disabled) {
    background: #e5e7eb;
}

/* Primary */
.wemx-modal__btn--primary {
    background: #6366f1;
    color: #fff;
}

.wemx-modal__btn--primary:hover:not(:disabled) {
    background: #4f46e5;
}

/* Danger */
.wemx-modal__btn--danger {
    background: #ef4444;
    color: #fff;
}

.wemx-modal__btn--danger:hover:not(:disabled) {
    background: #dc2626;
}

/* Warning */
.wemx-modal__btn--warning {
    background: #f59e0b;
    color: #fff;
}

.wemx-modal__btn--warning:hover:not(:disabled) {
    background: #d97706;
}

/* Info */
.wemx-modal__btn--info {
    background: #14b8a6;
    color: #fff;
}

.wemx-modal__btn--info:hover:not(:disabled) {
    background: #0d9488;
}

/* ----------------------------------------------------------
   Badge
   ---------------------------------------------------------- */
.wemx-modal__badge {
    display: inline-flex;
    align-items: center;
    padding: 0.1875rem 0.625rem;
    border-radius: 0.375rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1;
}

/* Badge variants — dark */
.dark .wemx-modal__badge--danger {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.dark .wemx-modal__badge--warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

/* Badge variants — light */
:root:not(.dark) .wemx-modal__badge--danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

:root:not(.dark) .wemx-modal__badge--warning {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}
