/* ============================================================
   Telegram OIDC pairing modal
   Used by /assets/js/notifications/TelegramPairing.js
   ============================================================ */

.tg-pair-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 22, 41, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 999999990;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 50px 16px;
    overflow-y: auto;
    opacity: 0;
    transition: opacity 200ms ease;
}

.tg-pair-overlay.is-visible {
    opacity: 1;
}

.tg-pair-modal {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 560px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    transform: translateY(-12px);
    transition: transform 250ms cubic-bezier(0.2, 0.8, 0.2, 1);
    position: relative;
    overflow: hidden;
    font-family: Montserrat, sans-serif;
}

.tg-pair-overlay.is-visible .tg-pair-modal {
    transform: translateY(0);
}

.tg-pair-modal-close {
    position: absolute;
    top: 14px;
    right: 16px;
    width: 30px;
    height: 30px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8c93a8;
    transition: background 150ms;
}

.tg-pair-modal-close:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #2b3343;
}

.tg-pair-modal-close svg {
    width: 18px !important;
    height: 18px !important;
}

.tg-pair-modal-header {
    padding: 28px 32px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid #eef0f5;
    background: linear-gradient(135deg, rgba(36, 161, 222, 0.05) 0%, rgba(36, 161, 222, 0.0) 100%);
}

.tg-pair-modal-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #2aabee 0%, #229ed9 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 6px 18px rgba(36, 161, 222, 0.4);
    flex-shrink: 0;
}

.tg-pair-modal-icon svg {
    width: 24px !important;
    height: 24px !important;
    fill: #fff !important;
}

.tg-pair-modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #2b3343;
}

.tg-pair-modal-body {
    padding: 24px 32px 28px;
}


/* ---- Steps ---- */

.tg-pair-step {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    position: relative;
    z-index: 1;
    padding-bottom: 16px;
}

.tg-pair-step:last-child {
    padding-bottom: 0;
}

/* Kontinuální levá čára — per-step ::after, jde od spodního okraje markeru
   k spodnímu okraji stepu. Poslední step ji má taky, takže čára pokračuje
   až dolů i přes "Hotovo" tlačítko. */
.tg-pair-step::after {
    content: '';
    position: absolute;
    left: 16px;
    top: 34px;
    bottom: 0;
    width: 2px;
    background: #eef0f5;
    z-index: 0;
}

.tg-pair-step:last-child::after {
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

.tg-pair-step-marker {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #f1f3f8;
    color: #8c93a8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
    position: relative;
    transition: all 250ms;
    z-index: 2;
}

.tg-pair-step-marker .tg-pair-step-check {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 200ms, transform 200ms;
}

.tg-pair-step-marker .tg-pair-step-check svg {
    width: 18px !important;
    height: 18px !important;
    stroke: #fff !important;
}

.tg-pair-step[data-status="active"] .tg-pair-step-marker {
    background: #229ed9;
    color: #fff;
    box-shadow: 0 0 0 4px rgba(34, 158, 217, 0.18);
}

.tg-pair-step[data-status="done"] .tg-pair-step-marker {
    background: #3ad188;
    color: transparent;
}

.tg-pair-step[data-status="done"] .tg-pair-step-marker .tg-pair-step-check {
    opacity: 1;
    transform: scale(1);
}

.tg-pair-step[data-status="error"] .tg-pair-step-marker {
    background: #e85d5d;
    color: #fff;
}

.tg-pair-step-content {
    flex: 1;
    padding-bottom: 6px;
    min-width: 0;
}

.tg-pair-step-title {
    font-size: 16px;
    font-weight: 600;
    color: #2b3343;
}

.tg-pair-step[data-status="waiting"] .tg-pair-step-title {
    color: #8c93a8;
}

.tg-pair-step-desc {
    font-size: 13px;
    color: #6c7390;
    margin-top: 2px;
    font-weight: 300;
}

.tg-pair-step-body {
    margin-top: 10px;
}

.tg-pair-step[data-status="waiting"] .tg-pair-step-body {
    display: none;
}

/* popup_closed report (tipsters) */
.tg-pair-popup-closed-desc {
    margin-top: 4px;
    font-size: 12px;
    line-height: 1.45;
    opacity: 0.95;
}

.tg-pair-report-btn {
    margin-top: 10px;
    height: 34px;
}

.tg-pair-report-form {
    margin-top: 10px;
    padding: 12px;
    background: #f7f9fc;
    border-radius: 8px;
    border: 1px solid #e3e7f0;
}

.tg-pair-report-form-desc {
    font-size: 13px;
    color: #44485a;
    margin-bottom: 8px;
    line-height: 1.45;
}

.tg-pair-report-form textarea {
    width: 100%;
    min-height: 88px;
    padding: 8px 10px;
    border: 1px solid #c5c9d6;
    border-radius: 6px;
    font-family: Montserrat, sans-serif;
    font-size: 13px;
    resize: vertical;
    background: #fff;
    color: #2b3343;
}

.tg-pair-report-form textarea:focus {
    border-color: #229ed9;
    outline: none;
    box-shadow: 0 0 0 3px rgba(34, 158, 217, 0.15);
}

.tg-pair-report-submit {
    margin-top: 10px;
    height: 34px;
}

[data-tg-pair-report-result] {
    margin-top: 8px;
}

html.is-dark .tg-pair-report-form {
    background: #232a3e;
    border-color: #2a3148;
}

html.is-dark .tg-pair-report-form-desc {
    color: #9aa0b7;
}

html.is-dark .tg-pair-report-form textarea {
    background: #1b2030;
    border-color: #2a3148;
    color: #e7eaf3;
}

/* DEV-only debug bloček ze step 2 error */
.tg-pair-debug {
    margin-top: 10px;
    padding: 10px 12px;
    background: #f4f6fb;
    border: 1px dashed #c5c9d6;
    border-radius: 6px;
    font-family: 'JetBrains Mono', Consolas, Menlo, monospace;
    font-size: 11px;
    color: #44485a;
}

.tg-pair-debug-title {
    font-weight: 700;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #8c93a8;
    margin-bottom: 6px;
}

.tg-pair-debug-row {
    margin-bottom: 4px;
    word-break: break-all;
}

.tg-pair-debug-row span {
    color: #6c7390;
    font-weight: 600;
    margin-right: 6px;
}

.tg-pair-debug-row code {
    background: #fff;
    padding: 1px 5px;
    border-radius: 3px;
    border: 1px solid #e3e7f0;
    color: #2b3343;
}

.tg-pair-debug-row.tg-pair-debug-token code {
    display: inline-block;
    max-width: 100%;
    word-break: break-all;
}

.tg-pair-debug-row pre {
    margin: 4px 0 0 0;
    padding: 6px 8px;
    background: #fff;
    border: 1px solid #e3e7f0;
    border-radius: 3px;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
}


/* ---- Telegram login button container ---- */

[data-tg-pair-step1-body] {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

[data-tg-pair-step1-body] iframe {
    border-radius: 6px;
}

/* Fallback / default styling for .tg-auth-button — the Telegram OIDC widget
   (telegram-login.js?4) binds click handlers but doesn't always replace the
   button's look, so we ship a Telegram-blue style here. */
.tg-pair-tg-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 18px;
    background: #2aabee;
    color: #fff;
    border: 0;
    border-radius: 6px;
    font-family: Montserrat, sans-serif;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(36, 161, 222, 0.35);
    transition: background 150ms, transform 100ms;
}

.tg-pair-tg-button:hover {
    background: #229ed9;
}

.tg-pair-tg-button:active {
    transform: translateY(1px);
}

.tg-pair-tg-button::before {
    content: '';
    width: 18px;
    height: 18px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ffffff'><path d='M9.78 18.65l.28-4.23 7.68-6.92c.34-.31-.07-.46-.52-.19L7.74 13.3 3.64 12c-.88-.25-.89-.86.2-1.3l15.97-6.16c.73-.33 1.43.18 1.15 1.3l-2.72 12.81c-.19.91-.74 1.13-1.5.71L12.6 16.3l-1.99 1.93c-.23.23-.42.42-.83.42z'/></svg>");
    background-repeat: no-repeat;
    background-size: contain;
}


/* ---- User card (step 2 success) ---- */

.tg-pair-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: #f7f9fc;
    border-radius: 10px;
    margin-bottom: 8px;
}

.tg-pair-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.tg-pair-user-info {
    min-width: 0;
}

.tg-pair-user-name {
    font-weight: 600;
    color: #2b3343;
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tg-pair-user-username {
    font-size: 0.78rem;
    color: #8c93a8;
}


/* ---- Alerts ---- */

.tg-pair-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    line-height: 1.45;
}

.tg-pair-alert svg {
    width: 18px !important;
    height: 18px !important;
    flex-shrink: 0;
    margin-top: 1px;
}

.tg-pair-alert-danger {
    background: #fde7e7;
    border: 1px solid #f8c5c5;
    color: #a03434;
}

.tg-pair-alert-danger svg {
    stroke: #a03434 !important;
}

.tg-pair-error-meta {
    margin-top: 4px;
    font-size: 0.74rem;
    color: #804040;
    font-family: Roboto, monospace;
    word-break: break-all;
}


/* ---- Success texts ---- */

.tg-pair-success-text {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #228b54;
    font-size: 0.88rem;
    font-weight: 500;
}

.tg-pair-success-text svg {
    width: 18px !important;
    height: 18px !important;
    stroke: #3ad188 !important;
}


/* ---- Pending (loading) ---- */

.tg-pair-loading,
.tg-pair-pending {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
}

.tg-pair-pending-text {
    font-size: 0.85rem;
    color: #6c7390;
}

.tg-pair-spinner {
    width: 22px;
    height: 22px;
    border: 2.5px solid #e3e7f0;
    border-top-color: #229ed9;
    border-radius: 50%;
    animation: tg-pair-spin 700ms linear infinite;
    flex-shrink: 0;
}

@keyframes tg-pair-spin {
    to { transform: rotate(360deg); }
}


/* ---- Retry / finish buttons ---- */

.tg-pair-finish-btn,
.tg-pair-retry-btn {
    margin-top: 12px;
    height: 34px;
}


/* ---- Mobile ---- */

@media (max-width: 600px) {
    .tg-pair-overlay {
        padding: 16px 8px;
        align-items: stretch;
    }

    .tg-pair-modal {
        max-width: 100%;
    }

    .tg-pair-modal-header {
        padding: 20px 22px 14px;
    }

    .tg-pair-modal-body {
        padding: 18px 22px 22px;
    }
}


/* ---- Dark mode (project switches via .is-dark on html) ---- */

html.is-dark .tg-pair-modal {
    background: #1b2030;
}

html.is-dark .tg-pair-modal-title,
html.is-dark .tg-pair-step-title,
html.is-dark .tg-pair-user-name {
    color: #e7eaf3;
}

html.is-dark .tg-pair-step-desc,
html.is-dark .tg-pair-user-username,
html.is-dark .tg-pair-pending-text {
    color: #9aa0b7;
}

html.is-dark .tg-pair-modal-header {
    border-bottom-color: #2a3148;
    background: linear-gradient(135deg, rgba(36, 161, 222, 0.08) 0%, rgba(36, 161, 222, 0.0) 100%);
}

html.is-dark .tg-pair-step[data-status="waiting"] .tg-pair-step-marker {
    background: #2a3148;
    color: #6a708a;
}

html.is-dark .tg-pair-step::after {
    background: #2a3148;
}

html.is-dark .tg-pair-user {
    background: #232a3e;
}

html.is-dark .tg-pair-modal-close {
    color: #9aa0b7;
}

html.is-dark .tg-pair-modal-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #e7eaf3;
}
