/* ??????????????????????????????????????????????????
   Global UX Polish — Satlify
   ?????????????????????????????????????????????????? */

/* ?? Typography ?? */
*,
*::before,
*::after {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.mud-typography {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
}

/* ?? Global transitions ?? */
a, button, .mud-button-root, .mud-icon-button, .mud-nav-link,
.mud-chip, .mud-select, .mud-input, .mud-fab,
.metric-card, .summary-card, .chart-card, .filter-card {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ?? Smooth scrolling ?? */
html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ?? Content fade-in after load ?? */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page-enter {
    animation: fadeInUp 0.35s cubic-bezier(0.4, 0, 0.2, 1) both;
}

/* Staggered children animation */
.page-enter > * {
    animation: fadeInUp 0.3s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.page-enter > *:nth-child(1) { animation-delay: 0.03s; }
.page-enter > *:nth-child(2) { animation-delay: 0.06s; }
.page-enter > *:nth-child(3) { animation-delay: 0.09s; }
.page-enter > *:nth-child(4) { animation-delay: 0.12s; }
.page-enter > *:nth-child(5) { animation-delay: 0.15s; }

/* ?? AppBar glassmorphism ?? */
.mud-appbar {
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-bottom: 1px solid var(--mud-palette-lines-default);
    transition: box-shadow 0.3s ease;
}

/* ?? Drawer polish ?? */
#nav-drawer .mud-drawer-content {
    border-right: 1px solid var(--mud-palette-lines-default);
}

/* ?? NavMenu refinement ?? */
.mud-nav-link {
    border-radius: 10px !important;
    margin: 2px 8px !important;
    padding: 10px 16px !important;
    font-weight: 500 !important;
    font-size: 14px !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.mud-nav-link:hover {
    background: var(--mud-palette-action-hover) !important;
    transform: translateX(2px);
}

.mud-nav-link.active {
    background: color-mix(in srgb, var(--mud-palette-primary) 12%, transparent) !important;
    color: var(--mud-palette-primary) !important;
    font-weight: 600 !important;
}

.mud-nav-link.active .mud-icon-root {
    color: var(--mud-palette-primary) !important;
}

/* ?? Floating Action Button ?? */
.mud-fab {
    box-shadow: 0 4px 20px rgba(247, 147, 26, 0.35) !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.mud-fab:hover {
    transform: scale(1.08) !important;
    box-shadow: 0 6px 28px rgba(247, 147, 26, 0.45) !important;
}

.mud-fab:active {
    transform: scale(0.96) !important;
}

@keyframes fabEnter {
    from {
        opacity: 0;
        transform: scale(0.6) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.mud-fab-bottom-right {
    animation: fabEnter 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s both;
}

/* ?? Button hover/press refinement ?? */
.mud-button-filled:hover {
    filter: brightness(1.08);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}

.mud-button-filled:active {
    transform: scale(0.97);
    filter: brightness(0.95);
    transition: transform 0.08s ease, filter 0.08s ease;
}

.mud-button-outlined:hover {
    background: var(--mud-palette-action-hover);
}

.mud-button-outlined:active {
    transform: scale(0.98);
}

.mud-button-text:active {
    transform: scale(0.98);
    opacity: 0.8;
}

/* ?? Icon button press ?? */
.mud-icon-button:active {
    transform: scale(0.92);
    transition: transform 0.08s ease;
}

/* ?? Card hover elevation ?? */
.metric-card {
    transition: box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.metric-card:hover {
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.07);
    transform: translateY(-1px);
}

.summary-card {
    transition: box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.summary-card:hover {
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.06);
    transform: translateY(-1px);
}

/* ?? Input focus states ?? */
.mud-input-outlined .mud-input-outlined-border {
    transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
}

.mud-input.mud-input-outlined:focus-within .mud-input-outlined-border {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--mud-palette-primary) 15%, transparent);
}

/* ?? Table row hover ?? */
.mud-table-row:hover {
    transition: background 0.15s ease;
}

/* ?? Snackbar polish ?? */
.mud-snackbar {
    border-radius: 12px !important;
    font-weight: 500 !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12) !important;
    animation: snackEnter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes snackEnter {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ?? Dialog entrance (overrides MudBlazor's mud-open-dialog-center) ?? */
/* ROOT CAUSE FIX: MudBlazor sets animation: mud-open-dialog-center .1s on .mud-dialog.
   Our CSS now loads AFTER MudBlazor in index.html. We use !important to guarantee override. */
.mud-dialog {
    -webkit-animation: satlifyDialogEnter 0.3s cubic-bezier(0.22, 1, 0.36, 1) 70ms both !important;
    animation: satlifyDialogEnter 0.3s cubic-bezier(0.22, 1, 0.36, 1) 70ms both !important;
}

@keyframes satlifyDialogEnter {
    from {
        opacity: 0;
        transform: scale(0.96, 0.97) translateY(16px);
    }
    to {
        opacity: 1;
        transform: scale(1, 1) translateY(0);
    }
}

/* Overlay appears first (no delay, starts immediately) */
.mud-overlay {
    animation: satlifyOverlayFadeIn 0.2s cubic-bezier(0.4, 0, 0.2, 1) both !important;
}

@keyframes satlifyOverlayFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ?? Live value flash (price tick) ?? */
@keyframes flashUp {
    0%   { color: #16c784; }
    100% { color: inherit; }
}

@keyframes flashDown {
    0%   { color: #ea3943; }
    100% { color: inherit; }
}

.live-flash-up {
    animation: flashUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.live-flash-down {
    animation: flashDown 0.6s cubic-bezier(0.4, 0, 0.2, 1) both;
}

/* ?? Submit button disabled state (smooth) ?? */
.dlg-submit-btn {
    transition: opacity 0.2s ease, filter 0.2s ease, transform 0.15s ease !important;
}

.dlg-submit-btn.mud-disabled,
.dlg-submit-btn[disabled] {
    opacity: 0.5 !important;
    filter: grayscale(0.3);
}

/* ?? Inline validation message ?? */
.dlg-validation-msg {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    animation: fadeInUp 0.2s ease both;
}

.dlg-validation-msg--error {
    color: var(--mud-palette-error);
    background: color-mix(in srgb, var(--mud-palette-error) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--mud-palette-error) 20%, transparent);
}

.dlg-validation-msg--warn {
    color: var(--mud-palette-warning);
    background: color-mix(in srgb, var(--mud-palette-warning) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--mud-palette-warning) 20%, transparent);
}

.dlg-validation-msg--checking {
    color: var(--mud-palette-text-secondary);
    background: color-mix(in srgb, var(--mud-palette-text-secondary) 6%, transparent);
    border: 1px solid color-mix(in srgb, var(--mud-palette-text-secondary) 12%, transparent);
}

.dlg-validation-msg--balance {
    color: var(--mud-palette-text-secondary);
    background: color-mix(in srgb, var(--mud-palette-primary) 6%, transparent);
    border: 1px solid color-mix(in srgb, var(--mud-palette-primary) 15%, transparent);
}

/* ?? Button inline spinner ?? */
.dlg-btn-spinner {
    width: 16px !important;
    height: 16px !important;
    margin-right: 6px;
    color: inherit !important;
}

/* ?? Skeleton loader ?? */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--mud-palette-action-hover) 25%,
        color-mix(in srgb, var(--mud-palette-action-hover) 60%, transparent) 50%,
        var(--mud-palette-action-hover) 75%
    );
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s ease-in-out infinite;
    border-radius: 8px;
}

@keyframes skeletonShimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
}

.skeleton-text--sm {
    height: 10px;
    width: 60%;
}

.skeleton-text--lg {
    height: 24px;
    width: 50%;
}

.skeleton-card {
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 16px;
    padding: 20px 24px;
    height: 100%;
}

.skeleton-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
}

.skeleton-chart {
    height: 200px;
    border-radius: 12px;
}

/* ?? Selection / highlight ?? */
::selection {
    background: color-mix(in srgb, var(--mud-palette-primary) 25%, transparent);
    color: var(--mud-palette-text-primary);
}

/* ?? Scrollbar polish ?? */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--mud-palette-lines-default);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--mud-palette-text-disabled);
}

/* ?? Tooltip refinement ?? */
.mud-tooltip {
    border-radius: 8px !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    padding: 6px 12px !important;
}

/* ?? Chip polish ?? */
.mud-chip {
    border-radius: 8px !important;
    font-weight: 500 !important;
    transition: all 0.2s ease !important;
}

/* ?? Alert polish ?? */
.mud-alert {
    border-radius: 12px !important;
}

/* ?? Select / Popover polish ?? */
.mud-popover {
    border-radius: 12px !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12) !important;
    animation: popoverEnter 0.15s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes popoverEnter {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ?? AppBar BTC price ?? */
.appbar-price-display {
    display: flex;
    align-items: center;
}

@media (max-width: 600px) {
    .appbar-price-display {
        display: none !important;
    }
}

/* ?? Loading container (legacy fallback) ?? */
.loading-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

/* ?? Plan Lock — unified styles ?? */
.plan-locked-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: color-mix(in srgb, var(--mud-palette-surface) 65%, transparent);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-radius: 16px;
    padding: 24px;
    text-align: center;
}

.plan-locked-card {
    cursor: default;
}

.plan-locked-card .premium-card:hover,
.plan-locked-card .mud-card:hover {
    transform: none !important;
    box-shadow: none !important;
}

.plan-locked-row {
    cursor: default;
}

.plan-locked-row td {
    opacity: 0.25;
    filter: blur(3px);
    user-select: none;
    pointer-events: none;
}

.plan-locked-row td:last-child {
    opacity: 0.8;
    filter: none;
    pointer-events: auto;
}

.plan-locked-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--mud-palette-warning);
    background: color-mix(in srgb, var(--mud-palette-warning) 10%, transparent);
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid color-mix(in srgb, var(--mud-palette-warning) 25%, transparent);
}

.plan-limit-card {
    border: 1px dashed color-mix(in srgb, var(--mud-palette-warning) 40%, transparent);
    background: color-mix(in srgb, var(--mud-palette-warning) 4%, var(--mud-palette-surface));
}

/* ?? WASM initial loading spinner ?? */
.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid var(--mud-palette-lines-default, #e0e0e0);
    border-top: 6px solid #F7931A;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ?? Blazor error UI ?? */
.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred."
}

code {
    color: #c02d76;
}

/* ?? Menu-button CSS tooltip (email not confirmed) ?? */
.menu-btn-wrapper {
    position: relative;
    display: inline-flex;
}

.menu-btn-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    white-space: nowrap;
    padding: 5px 10px;
    background: rgba(97, 97, 97, 0.92);
    color: #fff;
    font-size: 0.625rem;
    line-height: 1.4;
    letter-spacing: 0.0071em;
    border-radius: 4px;
    pointer-events: none;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1;
}

.menu-btn-wrapper:hover .menu-btn-tooltip {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1) 0.5s,
                transform 0.4s cubic-bezier(0.4, 0, 0.2, 1) 0.5s;
}

/* ?? InfoTip — premium CSS-only tooltip ?? */
.infotip {
    position: relative;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    margin-left: 4px;
    cursor: help;
}

.infotip-icon {
    width: 14px;
    height: 14px;
    opacity: 0.3;
    color: var(--mud-palette-text-secondary);
    transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                color 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.infotip:hover .infotip-icon {
    opacity: 0.85;
    color: var(--mud-palette-primary);
    transform: scale(1.15);
}

.infotip-bubble {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) translateY(6px);
    min-width: 200px;
    max-width: 280px;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.55;
    letter-spacing: 0.01em;
    text-transform: none;
    color: #fff;
    background: linear-gradient(135deg, rgba(30, 30, 40, 0.96), rgba(40, 40, 55, 0.96));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22),
                0 2px 8px rgba(0, 0, 0, 0.12),
                inset 0 1px 0 rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    z-index: 9999;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0.3s;
    white-space: normal;
    word-wrap: break-word;
}

/* Arrow */
.infotip-bubble::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(35, 35, 48, 0.96);
}

/* Show on hover — with deliberate delay for smoothness */
.infotip:hover .infotip-bubble {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
    transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1) 0.15s,
                transform 0.35s cubic-bezier(0.4, 0, 0.2, 1) 0.15s,
                visibility 0s linear 0s;
}

/* Prevent clipping on small screens — flip to below */
@media (max-width: 600px) {
    .infotip-bubble {
        bottom: auto;
        top: calc(100% + 10px);
        transform: translateX(-50%) translateY(-6px);
    }

    .infotip-bubble::after {
        top: auto;
        bottom: 100%;
        border: 6px solid transparent;
        border-bottom-color: rgba(35, 35, 48, 0.96);
    }

    .infotip:hover .infotip-bubble {
        transform: translateX(-50%) translateY(0);
    }
}

/* Prevent tooltip from going off-screen left/right */
.infotip-bubble {
    transform-origin: center bottom;
}