/* Shared modal styles for all components */
/* Overlay */
.modal-overlay {
    position: fixed;
    inset: 0;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 900; /* below toast (1000) but above app */
}

/* Overlay respects theme */
:root[data-theme="dark"] .modal-overlay {
    background: rgba(0, 0, 0, 0.45);
}

:root[data-theme="light"] .modal-overlay {
    background: rgba(12, 10, 20, 0.35);
}

/* Dialog - structural */
.modal-dialog {
    width: min(720px, 92vw);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-lg);
    /* Ensure visible panel even if other frameworks style .modal-dialog */
    background: rgba(22, 18, 41, 0.88);
    background-color: rgba(22, 18, 41, 0.88) !important; /* win vs bootstrap */
    color: var(--text-on-dark, #fff);
    border: 1px solid rgba(255,255,255,0.10);
    box-shadow: 0 20px 40px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.08);
}

/* Dialog visuals per theme */
:root[data-theme="dark"] .modal-dialog {
    color: var(--text-on-dark);
    background: linear-gradient(180deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.02) 100%), rgba(22, 18, 41, 0.85);
    background-color: rgba(22, 18, 41, 0.85) !important;
    border: 1px solid var(--border-dark);
    box-shadow: 0 20px 40px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.08);
}

:root[data-theme="light"] .modal-dialog {
    color: var(--text-on-light);
    background: radial-gradient(120% 120% at 50% 0%, var(--surface-0, #fff) 0%, var(--surface-1, #f6f6f8) 100%);
    background-color: var(--surface-0, #fff) !important;
    border: 1px solid var(--border-light, rgba(0,0,0,0.1));
    box-shadow: var(--elev-2, 0 10px 25px rgba(0,0,0,0.15));
}

/* Modern modal look refinement */
/* Modern modal look: apply to all .modal-dialog by default */
.modal-dialog {
    border: none;
    overflow: hidden;
    backdrop-filter: saturate(140%) blur(8px);
    -webkit-backdrop-filter: saturate(140%) blur(8px);
    background: linear-gradient(180deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.02) 100%), var(--surface-1);
}

:root[data-theme="light"] .modal-dialog {
    background: linear-gradient(180deg, rgba(255,255,255,0.75) 0%, rgba(255,255,255,0.55) 100%);
}

.modal-header {
    padding: 18px 20px;
}

.modal-body {
    padding: 18px 20px;
}

.modal-footer {
    padding: 16px 20px 20px 20px;
}

/* Dropdown/select theming for dark and light */
.modal-dialog .option select {
    min-width: 180px;
    border-radius: 10px;
    padding: 8px 10px;
}

/* Subtle divider accents */
.modal-header,
.modal-footer {
    border-color: rgba(255,255,255,.08);
}

:root[data-theme="light"] .modal-header,
:root[data-theme="light"] .modal-footer {
    border-color: rgba(0,0,0,.08);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-light, rgba(255,255,255,0.1));
}

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

.modal-close {
    appearance: none;
    border: 1px solid var(--border-light, rgba(255,255,255,0.2));
    background: var(--surface-1, rgba(255,255,255,0.06));
    color: var(--muted-light, #cbd5e1);
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 140ms ease, color 140ms ease, transform 140ms ease, border-color 140ms ease;
}

:root[data-theme="light"] .modal-close:hover {
    background: var(--surface-0, #fff);
    color: var(--text-on-light, #111827);
    transform: translateY(-1px);
}

:root[data-theme="dark"] .modal-close {
    border: 1px solid var(--border-dark, rgba(255,255,255,0.15));
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted-dark, #b3b3b3);
}

:root[data-theme="dark"] .modal-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-on-dark, #fff);
    transform: translateY(-1px);
}

.modal-close svg {
    width: 16px;
    height: 16px;
}

.modal-body {
    padding: 16px 18px;
    overflow: auto;
}

.option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light, rgba(255,255,255,0.08));
}

.option:last-child {
    border-bottom: none;
}

.option label {
    display: flex;
    align-items: center;
    gap: 10px;
    color: inherit;
}

/* Select visuals per theme */
.option select {
    border-radius: 10px;
    padding: 8px 10px;
}

:root[data-theme="dark"] .modal-dialog .option select {
    background: rgba(255,255,255,0.06);
    color: var(--text-on-dark, #fff);
    border: 1px solid var(--border-dark, rgba(255,255,255,0.15));
}

:root[data-theme="light"] .modal-dialog .option select {
    background: radial-gradient(120% 120% at 50% 0%, var(--surface-0, #fff) 0%, var(--surface-1, #f6f6f8) 100%);
    color: var(--text-on-light, #111827);
    border: 1px solid var(--border-light, rgba(0,0,0,0.1));
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04) inset, 0 1px 0 rgba(255,255,255,0.8);
}

.option.muted {
    color: var(--muted-light, #94a3b8);
    opacity: 0.9;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 18px 16px 18px;
    border-top: 1px solid var(--border-light, rgba(255,255,255,0.08));
}

.btn-primary,
.btn-secondary {
    /* Inherit from global .btn tokens */
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.08);
    transform: translateY(-1px);
}

/* Primary button tint stays consistent across themes (brand color) */
.btn-primary {
    background: rgba(113, 204, 152, 0.12);
    border-color: rgba(113, 204, 152, 0.35);
    color: var(--brand-mint, #71cc98);
}

.btn-primary:hover {
    background: rgba(113,204,152,0.18);
    transform: translateY(-1px);
}

@media (prefers-reduced-motion: reduce) {
    .modal-overlay, .modal-dialog, .btn-primary, .btn-secondary, .modal-close {
        transition: none;
    }
}
