/* ??????????????????????????????????????????????????
   Shared Dialog Design System
   Used by all modal dialogs in the app.
   ?????????????????????????????????????????????????? */

/* ?? Dialog Chrome ?? */
.mud-dialog {
    position: relative;
    border-radius: 20px !important;
    overflow: hidden;
    background: var(--mud-palette-surface) !important;
    border: 1px solid var(--mud-palette-lines-default) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12) !important;
}

.mud-dialog .mud-dialog-content {
    padding: 16px 24px 8px 24px !important;
}

.mud-dialog .mud-dialog-actions {
    padding: 8px 24px 16px 24px !important;
}

/* ?? Dialog overlay ?? near-invisible scrim ?? */
.mud-overlay.mud-overlay-dialog {
    overflow: hidden;
    background: rgba(0, 0, 0, 0.06) !important;
}

/* ?? Dialog closing animation (faster than open — feels responsive) ?? */
.mud-dialog-closing {
    animation: satlifyDialogExit 0.2s cubic-bezier(0.4, 0, 1, 1) both !important;
}

@keyframes satlifyDialogExit {
    from {
        opacity: 1;
        transform: scale(1, 1) translateY(0);
    }
    to {
        opacity: 0;
        transform: scale(0.98, 0.98) translateY(6px);
    }
}

/* ?? Focus visible state for dialog buttons ?? */
.dlg-actions .mud-button-root:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

/* ?? Overlay (loading + success checkmark) ?? */
.dlg-overlay {
    position: absolute;
    inset: 0;
    z-index: 9999;
    background: var(--mud-palette-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: dlg-fade-in 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 20px;
}

@keyframes dlg-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.dlg-check-svg {
    width: 72px;
    height: 72px;
}

.dlg-check-circle {
    stroke: #f7931a;
    stroke-width: 2.5;
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    animation: dlg-circle-draw 0.4s ease forwards;
}

.dlg-check-path {
    stroke: #f7931a;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: dlg-check-draw 0.3s ease 0.35s forwards;
}

@keyframes dlg-circle-draw {
    to { stroke-dashoffset: 0; }
}

@keyframes dlg-check-draw {
    to { stroke-dashoffset: 0; }
}

/* ?? Body layout ?? */
.dlg-body {
    display: flex;
    flex-direction: column;
    padding: 0 4px;
}

.dlg-body--scroll {
    overflow-y: auto;
    max-height: 480px;
}

/* ?? Sections ?? */
.dlg-section {
    padding: 14px 0;
    border-bottom: 1px solid var(--mud-palette-lines-default);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dlg-section--title {
    padding-top: 6px;
    padding-bottom: 12px;
}

.dlg-section--last {
    border-bottom: none;
}

/* ?? Section label ?? */
.dlg-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--mud-palette-text-secondary);
}

.dlg-optional {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    opacity: 0.7;
}

/* ?? Title row ?? */
.dlg-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dlg-title-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--mud-palette-text-primary);
}

.dlg-title-sub {
    font-size: 12px;
    color: var(--mud-palette-text-secondary);
    margin-top: 1px;
}

/* ?? Actions footer ?? */
.dlg-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 4px 0;
}

.dlg-submit-btn {
    min-width: 140px;
    font-weight: 700 !important;
}

/* ?? Generic helpers ?? */
.dlg-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.dlg-kv-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.dlg-kv {
    flex: 1 1 180px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.dlg-kv-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--mud-palette-text-secondary);
}

.dlg-kv-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--mud-palette-text-primary);
}

.dlg-kv-secondary {
    font-size: 0.75rem;
    color: var(--mud-palette-text-secondary);
    opacity: 0.7;
    margin-top: 1px;
}

.dlg-label-sub {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    opacity: 0.6;
    font-size: 10px;
}

.dlg-unit {
    font-size: 0.62em;
    opacity: 0.65;
    margin-left: 3px;
}

/* ?? Colors ?? */
.dlg-btc  { color: #f7931a !important; }
.dlg-positive { color: #16c784 !important; }
.dlg-negative { color: #ea3943 !important; }

/* ?? Badge ?? */
.dlg-badge {
    display: inline-flex;
    align-items: center;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    white-space: nowrap;
}

/* ?? Chip (account name display) ?? */
.dlg-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--mud-palette-background-grey);
    border-radius: 10px;
    border: 1px solid var(--mud-palette-lines-default);
}

.dlg-chip-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--mud-palette-text-primary);
}

/* ?? Hint bar ?? */
.dlg-hint-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    background: var(--mud-palette-background-grey);
    border-radius: 8px;
    font-size: 12px;
    color: var(--mud-palette-text-secondary);
}

/* ?? Route (from ? to) ?? */
.dlg-route {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.dlg-route-side {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 160px;
}

.dlg-route-icon { color: var(--mud-palette-primary); flex-shrink: 0; }

.dlg-route-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--mud-palette-text-primary);
}

.dlg-route-portfolio {
    font-size: 12px;
    color: var(--mud-palette-text-secondary);
}

/* ?? Move preview ?? */
.dlg-move-preview {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--mud-palette-background-grey);
    border-radius: 10px;
}

.dlg-move-side {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.dlg-move-side:last-child {
    text-align: right;
    align-items: flex-end;
}

.dlg-move-caption {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--mud-palette-text-secondary);
}

.dlg-move-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--mud-palette-text-primary);
}

.dlg-move-value--target {
    color: #f7931a;
}

/* ?? Empty state ?? */
.dlg-empty {
    font-size: 0.85rem;
    color: var(--mud-palette-text-secondary);
    font-style: italic;
}

/* ??????????????????????????????????????????????????
   Responsive Dialog Sizing
   ?????????????????????????????????????????????????? */

/* -- Size variants (desktop defaults) -- */
.dlg-responsive.dlg-responsive--sm {
    min-width: 440px;
    max-width: 460px;
}

.dlg-responsive.dlg-responsive--md-sm {
    min-width: 480px;
    max-width: 520px;
}

.dlg-responsive.dlg-responsive--md {
    min-width: 620px;
    max-width: 640px;
}

.dlg-responsive.dlg-responsive--lg {
    min-width: 720px;
    max-width: 900px;
}

/* -- Mobile: all dialogs go (near) full-width -- */
@media (max-width: 600px) {
    .mud-dialog {
        margin: 8px !important;
        max-width: calc(100vw - 16px) !important;
        width: calc(100vw - 16px) !important;
        border-radius: 16px !important;
    }

    .dlg-responsive.dlg-responsive--sm,
    .dlg-responsive.dlg-responsive--md-sm,
    .dlg-responsive.dlg-responsive--md,
    .dlg-responsive.dlg-responsive--lg {
        min-width: unset !important;
        max-width: unset !important;
        width: 100% !important;
    }

    .mud-dialog .mud-dialog-content {
        padding: 12px 16px 4px 16px !important;
    }

    .mud-dialog .mud-dialog-actions {
        padding: 6px 16px 12px 16px !important;
    }

    .dlg-body {
        padding: 0 !important;
    }

    .dlg-body--scroll {
        max-height: 65vh;
    }

    .dlg-section {
        padding: 10px 0;
        gap: 8px;
    }

    .dlg-title-text {
        font-size: 1rem;
    }

    .dlg-submit-btn {
        min-width: 110px;
    }

    .dlg-kv-row {
        gap: 8px;
    }

    .dlg-kv {
        flex: 1 1 140px;
    }

    .dlg-kv-value {
        font-size: 0.95rem;
    }

    .dlg-hint-bar {
        font-size: 11px;
        padding: 6px 8px;
    }

    .dlg-route {
        gap: 8px;
    }

    .dlg-route-side {
        flex: 1 1 120px;
    }

    .dlg-badge {
        font-size: 11px;
        padding: 3px 8px;
    }

    .dlg-move-preview {
        grid-template-columns: 1fr auto 1fr;
        gap: 6px;
        padding: 10px 12px;
    }
}

/* ?? P&L percent ?? */
.dlg-pnl-pct {
    font-size: 0.75em;
    font-weight: 400;
    margin-left: 3px;
    opacity: 0.85;
}
