﻿/* wwwroot/css/sg-ui.css */

/* базові токени */
:root{
    --sg-bg: #07090d;
    --sg-surface: rgba(255,255,255,0.04);
    --sg-surface-2: rgba(255,255,255,0.06);
    --sg-border: rgba(255,255,255,0.10);
    --sg-border-2: rgba(255,255,255,0.14);
    --sg-text: rgba(255,255,255,0.92);
    --sg-muted: rgba(255,255,255,0.62);
    --sg-accent: #2f7bff;
    --sg-danger: #ff4d5e;
    --sg-radius: 16px;
}

/* універсальна "картка/скло" */
.sg-card{
    background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.03));
    border: 1px solid var(--sg-border);
    border-radius: var(--sg-radius);
    box-shadow: 0 18px 60px rgba(0,0,0,0.55);
    backdrop-filter: blur(12px);
    margin: 4px;
}

.sg-card-pad{ padding: 16px 16px; }
.sg-card-pad-lg{ padding: 22px 22px; }

.sg-title{
    font-size: 28px;
    letter-spacing: .2px;
    margin: 0 0 12px 0;
}
.sg-subtle{ color: var(--sg-muted); }

/* кнопки */
.sg-btn{
    appearance: none;
    border: 1px solid var(--sg-border);
    background: rgba(255,255,255,0.04);
    color: var(--sg-text);
    border-radius: 12px;
    padding: 8px 12px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: transform .08s ease, border-color .15s ease, background .15s ease, opacity .15s ease;
}
.sg-btn:hover{
    border-color: rgba(255,255,255,0.20);
    background: rgba(255,255,255,0.06);
}
.sg-btn:active{ transform: translateY(1px); }
.sg-btn:disabled{ opacity: .55; cursor: not-allowed; }

.sg-btn-primary{
    border-color: rgba(47,123,255,0.45);
    background: rgba(47,123,255,0.14);
}
.sg-btn-primary:hover{
    border-color: rgba(47,123,255,0.65);
    background: rgba(47,123,255,0.18);
}

.sg-btn-danger{
    border-color: rgba(255,77,94,0.45);
    background: rgba(255,77,94,0.12);
}
.sg-btn-danger:hover{
    border-color: rgba(255,77,94,0.65);
    background: rgba(255,77,94,0.16);
}

/* інпути */
.sg-input{
    width: 100%;
    border: 1px solid var(--sg-border);
    background: rgba(0,0,0,0.25);
    color: var(--sg-text);
    border-radius: 12px;
    padding: 10px 12px;
    outline: none;
}
.sg-input:focus{
    border-color: rgba(47,123,255,0.55);
    box-shadow: 0 0 0 3px rgba(47,123,255,0.18);
}

/* таблиці: прибираємо “угловатість” */
.sg-table-wrap{
    overflow-x: auto;               /* горизонтальний скрол на мобілці */
    -webkit-overflow-scrolling: touch;
    border-radius: var(--sg-radius);
    border: 1px solid var(--sg-border);
    background: rgba(255,255,255,0.03);
}

table.sg-table{
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    color: var(--sg-text);
    font-size: 14px;
}

table.sg-table thead th{
    text-align: left;
    font-weight: 600;
    color: rgba(255,255,255,0.80);
    background: rgba(255,255,255,0.04);
    border-bottom: 1px solid var(--sg-border);
    padding: 12px 12px;
}

table.sg-table tbody td{
    padding: 12px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.86);
}

table.sg-table tbody tr:hover td{
    background: rgba(255,255,255,0.03);
}

table.sg-table tbody tr:last-child td{
    border-bottom: none;
}

/* бейджі/статуси (True/False) */
.sg-badge{
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--sg-border);
    background: rgba(255,255,255,0.04);
    color: rgba(255,255,255,0.85);
    font-size: 12px;
}
.sg-badge-ok{ border-color: rgba(60,200,120,0.35); background: rgba(60,200,120,0.10); }
.sg-badge-no{ border-color: rgba(255,180,60,0.35); background: rgba(255,180,60,0.10); }

/* трохи “прибрати” bootstrap-контейнери на темному фоні */
.sg-page{
    min-height: 100vh;
    padding: 28px 34px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .sg-page {
        padding: 16px 12px;
    }

    .sg-card-pad-lg {
        padding: 14px 14px;
    }

    /* API key — truncate на мобілці, залишаємо кнопки доступними */
    .sg-table .key-cell {
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Actions — вертикально на малих екранах */
    .sg-table .actions-cell {
        display: flex;
        flex-direction: column;
        gap: 4px;
        min-width: 80px;
    }
}

::deep .sg-main-inner .container,
::deep .sg-main-inner .container-sm,
::deep .sg-main-inner .container-md,
::deep .sg-main-inner .container-lg,
::deep .sg-main-inner .container-xl,
::deep .sg-main-inner .container-xxl{
    max-width: 100% !important;
    width: 100% !important;
}

/* якщо сторінка складається з card-ів — хай card теж не стискається */
::deep .sg-main-inner .card{
    width: 100%;
}

/* modal dialog */
.sg-modal-overlay{
    position: fixed; inset: 0;
    background: rgba(0,0,0,.75);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
}
.sg-modal-box{
    background: #0d1117;
    border: 1px solid #1e2538;
    border-radius: 12px;
    padding: 32px 36px;
    min-width: 320px;
    max-width: 480px;
    width: 100%;
    text-align: center;
    box-shadow: 0 8px 40px rgba(0,0,0,.8);
}
.sg-modal-question{
    margin: 0 0 22px;
    font-size: 1rem;
    font-weight: 500;
    color: #e0e4f0;
}
.sg-modal-input{
    width: 100%;
    margin-bottom: 20px;
    box-sizing: border-box;
}
.sg-modal-actions{
    display: flex; gap: 12px; justify-content: center; flex-wrap: wrap;
}

/* ─────────────────────────────────────────────────────────────────────
 * Reconnect modal — full-screen overlay with three states.
 *
 * Classes toggled by the reconnectionHandler in App.razor:
 *   .components-reconnect-show       → active "Reconnecting…" state
 *   .components-reconnect-failed     → retries exhausted, prominent Reload
 *   .components-reconnect-rejected   → circuit disposed, prominent Reload
 *
 * The markup in App.razor provides three .reconnect-state sections; CSS
 * selectors below show exactly one at a time based on the parent class.
 * ───────────────────────────────────────────────────────────────────── */
#components-reconnect-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    align-items: center;
    justify-content: center;
    padding: 20px;
    -webkit-tap-highlight-color: transparent;
}
#components-reconnect-modal.components-reconnect-show {
    display: flex;
    animation: reconnect-fade-in 180ms ease-out;
}
@keyframes reconnect-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

#components-reconnect-modal .reconnect-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(5, 7, 11, 0.78);
    backdrop-filter: blur(6px) saturate(140%);
    -webkit-backdrop-filter: blur(6px) saturate(140%);
}

#components-reconnect-modal .reconnect-card {
    position: relative;
    z-index: 1;
    min-width: 320px;
    max-width: 420px;
    width: 100%;
    padding: 36px 32px 32px;
    text-align: center;
    background: linear-gradient(180deg, #0b0f18 0%, #070a10 100%);
    border: 1px solid rgba(42, 167, 255, 0.45);
    border-radius: 18px;
    box-shadow:
        0 0 0 1px rgba(42, 167, 255, 0.15),
        0 24px 80px rgba(0, 0, 0, 0.6),
        0 0 60px rgba(42, 167, 255, 0.10);
    color: #e7eefc;
    font-family: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif;
    animation: reconnect-card-in 220ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes reconnect-card-in {
    from { transform: translateY(8px) scale(0.96); opacity: 0; }
    to   { transform: translateY(0)   scale(1);    opacity: 1; }
}

#components-reconnect-modal .reconnect-spinner {
    width: 44px;
    height: 44px;
    margin: 0 auto 20px;
    border: 3px solid rgba(42, 167, 255, 0.18);
    border-top-color: #2aa7ff;
    border-radius: 50%;
    animation: reconnect-spin 0.8s linear infinite;
}
@keyframes reconnect-spin {
    to { transform: rotate(360deg); }
}

#components-reconnect-modal .reconnect-title {
    margin: 0 0 8px;
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: #e7eefc;
}
#components-reconnect-modal .reconnect-subtitle {
    margin: 0 0 14px;
    font-size: 0.9rem;
    line-height: 1.4;
    color: rgba(231, 238, 252, 0.62);
}
#components-reconnect-modal .reconnect-attempt {
    margin: 0 0 18px;
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
    color: rgba(231, 238, 252, 0.45);
    min-height: 1.1em; /* reserve space so layout doesn't shift */
}

#components-reconnect-modal .reconnect-btn {
    display: inline-block;
    min-width: 140px;
    padding: 10px 22px;
    font-size: 0.92rem;
    font-weight: 600;
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 80ms ease, background 120ms ease, border-color 120ms ease;
    user-select: none;
}
#components-reconnect-modal .reconnect-btn:active { transform: translateY(1px); }
#components-reconnect-modal .reconnect-btn-primary {
    background: linear-gradient(180deg, #2aa7ff 0%, #1f8fe0 100%);
    color: #03070d;
    box-shadow: 0 6px 18px rgba(42, 167, 255, 0.35);
}
#components-reconnect-modal .reconnect-btn-primary:hover {
    background: linear-gradient(180deg, #43b3ff 0%, #2aa7ff 100%);
}
#components-reconnect-modal .reconnect-btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    color: #c8cce0;
    border-color: rgba(255, 255, 255, 0.10);
}
#components-reconnect-modal .reconnect-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(42, 167, 255, 0.45);
    color: #e7eefc;
}

/* State visibility — only one .reconnect-state shown at a time. */
#components-reconnect-modal .reconnect-state { display: none; }
#components-reconnect-modal.components-reconnect-show
    .reconnect-state-active { display: block; }

#components-reconnect-modal.components-reconnect-failed
    .reconnect-state-active { display: none; }
#components-reconnect-modal.components-reconnect-failed
    .reconnect-state-failed { display: block; }
#components-reconnect-modal.components-reconnect-failed
    .reconnect-spinner { display: none; }

#components-reconnect-modal.components-reconnect-rejected
    .reconnect-state-active,
#components-reconnect-modal.components-reconnect-rejected
    .reconnect-state-failed { display: none; }
#components-reconnect-modal.components-reconnect-rejected
    .reconnect-state-rejected { display: block; }
#components-reconnect-modal.components-reconnect-rejected
    .reconnect-spinner { display: none; }

/* Mobile — narrower card, full-width button */
@media (max-width: 480px) {
    #components-reconnect-modal .reconnect-card {
        min-width: 0;
        padding: 28px 22px 24px;
        border-radius: 16px;
    }
    #components-reconnect-modal .reconnect-title { font-size: 1.05rem; }
    #components-reconnect-modal .reconnect-subtitle { font-size: 0.85rem; }
    #components-reconnect-modal .reconnect-btn { width: 100%; }
}

/* Honour user motion preference */
@media (prefers-reduced-motion: reduce) {
    #components-reconnect-modal,
    #components-reconnect-modal .reconnect-card,
    #components-reconnect-modal .reconnect-spinner {
        animation: none !important;
    }
}
