/* Lex Platform - Host Web Styles */

/* Spinner utility — used by ti-loader-2 and similar icon-font icons */
@keyframes lex-spin {
    to { transform: rotate(360deg); }
}

.ti-spin {
    animation: lex-spin 0.8s linear infinite;
    display: inline-block;
}

h1:focus {
    outline: none;
}

/* Validation states */
.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--lex-success);
}

.invalid {
    outline: 1px solid var(--lex-danger);
}

.validation-message {
    color: var(--lex-danger);
    font-size: var(--lex-font-size-sm);
}

/* Error boundary */
.blazor-error-boundary {
    background: var(--lex-danger-bg);
    border: 1px solid var(--lex-danger);
    padding: var(--lex-space-4);
    border-radius: var(--lex-radius-md);
    color: var(--lex-danger);
}

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

/* Error UI overlay */
#blazor-error-ui {
    display: none;
    position: fixed;
    right: 24px;
    bottom: 24px;
    left: auto;
    z-index: 10000;
    width: min(440px, calc(100vw - 32px));
    pointer-events: none;
    animation: errorSlideIn .4s cubic-bezier(.22,1,.36,1);
}

.lex-error-toast {
    position: relative;
    pointer-events: auto;
}

.lex-error-toast__glow {
    position: absolute;
    inset: auto 16px -18px 16px;
    height: 72px;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(255, 92, 92, .18), transparent 72%);
    filter: blur(18px);
    pointer-events: none;
}

.lex-error-bar {
    align-items: flex-start;
    backdrop-filter: blur(22px);
    background:
        linear-gradient(180deg, rgba(31, 15, 20, .96), rgba(17, 11, 16, .98)),
        radial-gradient(circle at top left, rgba(255, 119, 119, .18), transparent 46%);
    border: 1px solid rgba(255, 110, 110, .24);
    border-radius: 22px;
    box-shadow:
        0 28px 70px rgba(0,0,0,.52),
        0 0 0 1px rgba(255, 110, 110, .08),
        inset 0 1px 0 rgba(255,255,255,.05);
    color: #f7f7f8;
    display: flex;
    font-family: 'DM Sans', sans-serif;
    gap: 14px;
    overflow: hidden;
    padding: 16px;
    position: relative;
}

.lex-error-bar::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: linear-gradient(180deg, #ff8d72 0%, #ff496c 100%);
}

.lex-error-bar__icon {
    align-items: center;
    background: linear-gradient(180deg, rgba(255, 114, 114, .18), rgba(255, 85, 105, .12));
    border: 1px solid rgba(255, 118, 118, .22);
    border-radius: 16px;
    color: #ff8b78;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
    display: flex;
    flex-shrink: 0;
    height: 46px;
    justify-content: center;
    margin-left: 4px;
    width: 46px;
}

.lex-error-bar__content {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.lex-error-bar__eyebrow {
    color: rgba(255, 173, 173, .72);
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .18em;
    text-transform: uppercase;
}

.lex-error-bar__title {
    color: #fff5f5;
    font-family: 'Syne', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
}

.lex-error-bar__text {
    color: rgba(255, 236, 236, .72);
    font-size: .85rem;
    line-height: 1.5;
}

.lex-error-bar__actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.lex-error-bar__action {
    align-items: center;
    background: linear-gradient(135deg, rgba(255, 122, 99, .18), rgba(255, 76, 108, .22));
    border: 1px solid rgba(255, 126, 126, .28);
    border-radius: 999px;
    color: #fff2f2;
    display: inline-flex;
    font-family: inherit;
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .02em;
    min-height: 40px;
    padding: 0 16px;
    text-decoration: none;
    transition: transform .15s, background .15s, border-color .15s, box-shadow .15s;
}

.lex-error-bar__action:hover {
    background: linear-gradient(135deg, rgba(255, 138, 116, .28), rgba(255, 83, 118, .3));
    border-color: rgba(255, 159, 159, .4);
    box-shadow: 0 12px 24px rgba(255, 86, 116, .18);
    transform: translateY(-1px);
}

.lex-error-bar__dismiss {
    align-items: center;
    background: rgba(255,255,255,.04);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 999px;
    color: rgba(255, 226, 226, .72);
    cursor: pointer;
    display: flex;
    font-family: inherit;
    font-size: .78rem;
    font-weight: 600;
    height: 40px;
    justify-content: center;
    line-height: 1;
    padding: 0 14px;
    transition: color .15s, background .15s, border-color .15s;
}

.lex-error-bar__dismiss:hover {
    background: rgba(255,255,255,.08);
    border-color: rgba(255,255,255,.14);
    color: rgba(255,255,255,.9);
}

@keyframes errorSlideIn {
    from { opacity: 0; transform: translateY(18px) scale(.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 720px) {
    #blazor-error-ui {
        left: 16px;
        right: 16px;
        bottom: 16px;
        width: auto;
    }

    .lex-error-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .lex-error-bar__actions {
        margin-left: 0;
        width: 100%;
    }

    .lex-error-bar__action,
    .lex-error-bar__dismiss {
        flex: 1;
        justify-content: center;
    }
}

/* ── Reconnect modal ── */
#components-reconnect-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10001;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .65);
    backdrop-filter: blur(6px);
    animation: reconnectFadeIn .3s ease;
}

#components-reconnect-modal.components-reconnect-show {
    display: flex;
}

#components-reconnect-modal.components-reconnect-show .lex-reconnect-modal { display: flex; }
#components-reconnect-modal.components-reconnect-show .lex-reconnect-modal--failed,
#components-reconnect-modal.components-reconnect-show .lex-reconnect-modal--rejected { display: none; }

#components-reconnect-modal.components-reconnect-failed {
    display: flex;
}

#components-reconnect-modal.components-reconnect-failed .lex-reconnect-modal { display: none; }
#components-reconnect-modal.components-reconnect-failed .lex-reconnect-modal--failed { display: flex !important; }
#components-reconnect-modal.components-reconnect-failed .lex-reconnect-modal--rejected { display: none; }

#components-reconnect-modal.components-reconnect-rejected {
    display: flex;
}

#components-reconnect-modal.components-reconnect-rejected .lex-reconnect-modal { display: none; }
#components-reconnect-modal.components-reconnect-rejected .lex-reconnect-modal--failed { display: none; }
#components-reconnect-modal.components-reconnect-rejected .lex-reconnect-modal--rejected { display: flex !important; }

.lex-reconnect-modal {
    align-items: center;
    backdrop-filter: blur(24px);
    background: rgba(14, 14, 18, .92);
    border: 1px solid rgba(16, 185, 129, .2);
    border-radius: 16px;
    box-shadow:
        0 24px 80px rgba(0, 0, 0, .5),
        0 0 0 1px rgba(16, 185, 129, .08),
        inset 0 1px 0 rgba(255, 255, 255, .04);
    color: #f1f1f1;
    display: flex;
    flex-direction: column;
    font-family: 'DM Sans', sans-serif;
    gap: 16px;
    max-width: 340px;
    padding: 32px 28px;
    position: relative;
    text-align: center;
    width: 90vw;
}

.lex-reconnect-pulse {
    animation: reconnectPulse 2s ease-in-out infinite;
    background: radial-gradient(circle, rgba(16, 185, 129, .15) 0%, transparent 70%);
    border-radius: 50%;
    height: 200px;
    left: 50%;
    pointer-events: none;
    position: absolute;
    top: 0;
    transform: translate(-50%, -40%);
    width: 200px;
}

.lex-reconnect-icon {
    align-items: center;
    background: rgba(16, 185, 129, .12);
    border: 1px solid rgba(16, 185, 129, .25);
    border-radius: 14px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, .05),
        0 10px 24px rgba(16, 185, 129, .12);
    color: #10b981;
    display: flex;
    height: 56px;
    justify-content: center;
    width: 56px;
}

.lex-reconnect-icon svg {
    animation: reconnectSpin 1.8s linear infinite;
    filter: drop-shadow(0 0 10px rgba(16, 185, 129, .18));
    transform-origin: center;
}

.lex-reconnect-icon--warn {
    background: rgba(245, 158, 11, .12);
    border-color: rgba(245, 158, 11, .25);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, .05),
        0 10px 24px rgba(245, 158, 11, .12);
    color: #f59e0b;
}

.lex-reconnect-icon--danger {
    background: rgba(239, 68, 68, .12);
    border-color: rgba(239, 68, 68, .25);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, .05),
        0 10px 24px rgba(239, 68, 68, .12);
    color: #ef4444;
}

.lex-reconnect-icon--warn svg,
.lex-reconnect-icon--danger svg {
    animation: none;
    filter: none;
}

.lex-reconnect-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.lex-reconnect-title {
    color: rgba(255, 255, 255, .95);
    font-family: 'Syne', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: .01em;
    margin: 0;
}

.lex-reconnect-text {
    color: rgba(255, 255, 255, .5);
    font-size: .82rem;
    line-height: 1.5;
    margin: 0;
}

.lex-reconnect-bar {
    background: rgba(255, 255, 255, .06);
    border-radius: 4px;
    height: 3px;
    overflow: hidden;
    width: 100%;
}

.lex-reconnect-bar-fill {
    animation: reconnectProgress 2.5s ease-in-out infinite;
    background: linear-gradient(90deg, transparent, #10b981, transparent);
    border-radius: 4px;
    height: 100%;
    width: 40%;
}

.lex-reconnect-btn {
    background: rgba(16, 185, 129, .12);
    border: 1px solid rgba(16, 185, 129, .3);
    border-radius: 8px;
    color: #10b981;
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    font-size: .85rem;
    font-weight: 600;
    letter-spacing: .02em;
    padding: 10px 28px;
    transition: background .15s, border-color .15s, transform .1s;
}

.lex-reconnect-btn:hover {
    background: rgba(16, 185, 129, .22);
    border-color: rgba(16, 185, 129, .5);
}

.lex-reconnect-btn:active {
    transform: scale(.97);
}

.lex-reconnect-modal--failed .lex-reconnect-modal {
    border-color: rgba(245, 158, 11, .2);
}

.lex-reconnect-modal--failed .lex-reconnect-btn {
    background: rgba(245, 158, 11, .12);
    border-color: rgba(245, 158, 11, .3);
    color: #f59e0b;
}

.lex-reconnect-modal--failed .lex-reconnect-btn:hover {
    background: rgba(245, 158, 11, .22);
    border-color: rgba(245, 158, 11, .5);
}

.lex-reconnect-modal--rejected {
    border-color: rgba(239, 68, 68, .2) !important;
}

.lex-reconnect-modal--rejected .lex-reconnect-btn {
    background: rgba(239, 68, 68, .12);
    border-color: rgba(239, 68, 68, .3);
    color: #ef4444;
}

.lex-reconnect-modal--rejected .lex-reconnect-btn:hover {
    background: rgba(239, 68, 68, .22);
    border-color: rgba(239, 68, 68, .5);
}

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

@keyframes reconnectSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes reconnectPulse {
    0%, 100% { opacity: .4; transform: translate(-50%, -40%) scale(.9); }
    50% { opacity: 1; transform: translate(-50%, -40%) scale(1.1); }
}

@keyframes reconnectProgress {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

/* Dashboard card (used on home page) */
.lex-card {
    background-color: var(--lex-bg-tertiary);
    border: 1px solid var(--lex-border);
    border-radius: var(--lex-radius-lg);
    padding: var(--lex-space-6);
    transition: box-shadow var(--lex-transition-base);
}

.lex-card:hover {
    box-shadow: var(--lex-shadow-glow);
}

.lex-card__title {
    color: var(--lex-primary-500);
    font-size: var(--lex-font-size-lg);
    font-weight: 600;
    margin: 0 0 var(--lex-space-2) 0;
}

.lex-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--lex-space-4);
}
