/* =========================================================
   HSTOCK TELEGRAM SUPPORT CHAT
   File: public/assets/css/telegram-support.css
   ========================================================= */

/* Hide elements that contain the HTML hidden attribute */
.telegram-support-widget [hidden] {
    display: none !important;
}

/* Main widget wrapper */
.telegram-support-widget {
    position: fixed;
    left: 22px;
    bottom: 24px;
    z-index: 99999;
    font-family: Arial, Helvetica, sans-serif;
    box-sizing: border-box;
}

.telegram-support-widget *,
.telegram-support-widget *::before,
.telegram-support-widget *::after {
    box-sizing: border-box;
}

/* =========================================================
   FLOATING TELEGRAM BUTTON
   ========================================================= */

.telegram-support-button {
    position: relative;
    width: 58px;
    height: 58px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #2aabee 0%, #229ed9 100%);
    color: #ffffff;
    font-size: 29px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 10px 30px rgba(34, 158, 217, 0.35),
        0 4px 10px rgba(0, 0, 0, 0.18);
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease,
        background 0.2s ease;
    outline: none;
}

.telegram-support-button:hover {
    transform: translateY(-3px) scale(1.04);
    background: linear-gradient(135deg, #32b7f3 0%, #168dcc 100%);
    box-shadow:
        0 14px 34px rgba(34, 158, 217, 0.42),
        0 5px 12px rgba(0, 0, 0, 0.2);
}

.telegram-support-button:active {
    transform: scale(0.96);
}

.telegram-support-button:focus-visible {
    outline: 3px solid rgba(42, 171, 238, 0.3);
    outline-offset: 4px;
}

.telegram-support-button i {
    line-height: 1;
}

/* Unread counter */
.telegram-unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 21px;
    height: 21px;
    padding: 0 6px;
    border: 2px solid #ffffff;
    border-radius: 20px;
    background: #ef4444;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    line-height: 17px;
    text-align: center;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

/* =========================================================
   CHAT PANEL
   ========================================================= */

.telegram-support-panel {
    position: absolute;
    left: 0;
    bottom: 72px;
    width: 370px;
    height: min(600px, calc(100vh - 120px));
    overflow: hidden;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    background: #ffffff;
    box-shadow:
        0 24px 65px rgba(15, 23, 42, 0.22),
        0 8px 22px rgba(15, 23, 42, 0.12);
    animation: telegramPanelOpen 0.22s ease-out;
}

@keyframes telegramPanelOpen {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* =========================================================
   HEADER
   ========================================================= */

.telegram-support-header {
    min-height: 76px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #229ed9 0%, #168ac4 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.telegram-support-header-info {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 11px;
}

.telegram-support-logo {
    flex: 0 0 auto;
    width: 45px;
    height: 45px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 23px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.telegram-support-header h3 {
    margin: 0 0 4px;
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.25;
}

.telegram-support-header p {
    margin: 0;
    color: rgba(255, 255, 255, 0.9);
    font-size: 12px;
    line-height: 1.3;
    display: flex;
    align-items: center;
    gap: 6px;
}

.telegram-online-dot {
    width: 8px;
    height: 8px;
    border: 2px solid rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.17);
}

.telegram-support-close {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.13);
    color: #ffffff;
    font-size: 17px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
        background 0.2s ease,
        transform 0.2s ease;
}

.telegram-support-close:hover {
    background: rgba(255, 255, 255, 0.24);
    transform: rotate(4deg);
}

/* =========================================================
   VISITOR INFORMATION FORM
   ========================================================= */

.telegram-visitor-form-wrapper {
    height: calc(100% - 76px);
    padding: 22px 20px;
    overflow-y: auto;
    background:
        radial-gradient(circle at top right, rgba(42, 171, 238, 0.09), transparent 36%),
        #ffffff;
}

.telegram-welcome-message {
    margin-bottom: 20px;
    padding: 15px;
    border: 1px solid #dbeafe;
    border-radius: 14px;
    background: #eff8ff;
}

.telegram-welcome-message strong {
    display: block;
    margin-bottom: 5px;
    color: #0f172a;
    font-size: 16px;
    font-weight: 700;
}

.telegram-welcome-message p {
    margin: 0;
    color: #475569;
    font-size: 13px;
    line-height: 1.55;
}

.telegram-form-group {
    margin-bottom: 16px;
}

.telegram-form-group label {
    display: block;
    margin-bottom: 7px;
    color: #1e293b;
    font-size: 13px;
    font-weight: 700;
}

.telegram-form-group input {
    width: 100%;
    height: 46px;
    padding: 0 13px;
    border: 1px solid #d6dce5;
    border-radius: 11px;
    background: #ffffff;
    color: #0f172a;
    font-size: 14px;
    outline: none;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        background 0.2s ease;
}

.telegram-form-group input::placeholder {
    color: #94a3b8;
}

.telegram-form-group input:focus {
    border-color: #229ed9;
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(34, 158, 217, 0.12);
}

.telegram-form-group small {
    display: block;
    margin-top: 6px;
    color: #64748b;
    font-size: 11px;
}

/* Username field with @ symbol */
.telegram-username-input {
    width: 100%;
    height: 46px;
    overflow: hidden;
    border: 1px solid #d6dce5;
    border-radius: 11px;
    background: #ffffff;
    display: flex;
    align-items: center;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

.telegram-username-input:focus-within {
    border-color: #229ed9;
    box-shadow: 0 0 0 4px rgba(34, 158, 217, 0.12);
}

.telegram-username-input > span {
    height: 100%;
    padding: 0 0 0 13px;
    color: #64748b;
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
}

.telegram-username-input input {
    height: 100%;
    padding-left: 4px;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

.telegram-username-input input:focus {
    border: none;
    box-shadow: none;
}

/* Start conversation button */
.telegram-start-button {
    width: 100%;
    min-height: 48px;
    margin-top: 4px;
    padding: 11px 16px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #229ed9 0%, #168ac4 100%);
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 7px 18px rgba(34, 158, 217, 0.24);
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease,
        opacity 0.2s ease;
}

.telegram-start-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(34, 158, 217, 0.3);
}

.telegram-start-button:active {
    transform: translateY(0);
}

.telegram-start-button:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

/* =========================================================
   ACTIVE CONVERSATION
   ========================================================= */

.telegram-conversation {
    height: calc(100% - 76px);
    min-height: 0;
    background: #f5f7fa;
    display: flex;
    flex-direction: column;
}

.telegram-conversation-number {
    flex: 0 0 auto;
    padding: 8px 14px;
    border-bottom: 1px solid #e5e7eb;
    background: #ffffff;
    color: #64748b;
    font-size: 11px;
    text-align: center;
}

.telegram-conversation-number strong {
    color: #229ed9;
}

/* Messages container */
.telegram-messages {
    flex: 1 1 auto;
    min-height: 0;
    padding: 15px 13px;
    overflow-x: hidden;
    overflow-y: auto;
    scroll-behavior: smooth;
    background:
        linear-gradient(rgba(248, 250, 252, 0.93), rgba(248, 250, 252, 0.93)),
        radial-gradient(circle at 15% 20%, #dbeafe 0, transparent 24%),
        radial-gradient(circle at 85% 80%, #e0f2fe 0, transparent 24%);
}

.telegram-messages::-webkit-scrollbar,
.telegram-visitor-form-wrapper::-webkit-scrollbar {
    width: 5px;
}

.telegram-messages::-webkit-scrollbar-track,
.telegram-visitor-form-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.telegram-messages::-webkit-scrollbar-thumb,
.telegram-visitor-form-wrapper::-webkit-scrollbar-thumb {
    border-radius: 10px;
    background: #cbd5e1;
}

/* Initial system message */
.telegram-system-message {
    max-width: 88%;
    margin: 0 auto 14px;
    padding: 9px 12px;
    border: 1px solid #bae6fd;
    border-radius: 11px;
    background: #e0f2fe;
    color: #334155;
    font-size: 11px;
    line-height: 1.45;
    text-align: center;
}

.telegram-system-message p {
    margin: 0;
}

/* =========================================================
   MESSAGE BUBBLES
   These classes will be used by JavaScript
   ========================================================= */

.telegram-message {
    width: 100%;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
}

.telegram-message.visitor-message {
    align-items: flex-end;
}

.telegram-message.admin-message {
    align-items: flex-start;
}

.telegram-message-bubble {
    position: relative;
    max-width: 82%;
    padding: 9px 11px 7px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.45;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.visitor-message .telegram-message-bubble {
    border-bottom-right-radius: 4px;
    background: #229ed9;
    color: #ffffff;
    box-shadow: 0 3px 9px rgba(34, 158, 217, 0.17);
}

.admin-message .telegram-message-bubble {
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
    background: #ffffff;
    color: #1e293b;
    box-shadow: 0 3px 10px rgba(15, 23, 42, 0.06);
}

.telegram-message-text {
    margin: 0;
    white-space: pre-wrap;
}

.telegram-message-image {
    display: block;
    width: 100%;
    max-width: 230px;
    max-height: 260px;
    margin-bottom: 6px;
    border-radius: 10px;
    object-fit: cover;
    cursor: pointer;
}

.telegram-message-meta {
    margin-top: 4px;
    font-size: 9px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

.visitor-message .telegram-message-meta {
    color: rgba(255, 255, 255, 0.8);
}

.admin-message .telegram-message-meta {
    color: #94a3b8;
}

.telegram-message-status {
    font-size: 10px;
}

.telegram-message-status.seen {
    color: #7dd3fc;
}

/* =========================================================
   IMAGE PREVIEW
   ========================================================= */

.telegram-image-preview {
    position: relative;
    flex: 0 0 auto;
    padding: 9px 55px 9px 13px;
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
}

.telegram-image-preview img {
    display: block;
    width: 64px;
    height: 64px;
    border: 1px solid #dbe3ec;
    border-radius: 10px;
    object-fit: cover;
}

.telegram-image-preview button {
    position: absolute;
    top: 14px;
    right: 16px;
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #ef4444;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Sending and connection status */
.telegram-chat-status {
    flex: 0 0 auto;
    padding: 5px 14px;
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
    color: #64748b;
    font-size: 10px;
    text-align: center;
}

/* =========================================================
   MESSAGE COMPOSER
   ========================================================= */

.telegram-message-form {
    flex: 0 0 auto;
    min-height: 62px;
    padding: 9px 10px;
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
    display: flex;
    align-items: flex-end;
    gap: 7px;
}

.telegram-attachment-button,
.telegram-send-button {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    padding: 0;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
        transform 0.18s ease,
        background 0.18s ease,
        opacity 0.18s ease;
}

.telegram-attachment-button {
    background: #f1f5f9;
    color: #475569;
    font-size: 19px;
}

.telegram-attachment-button:hover {
    background: #e2e8f0;
    color: #229ed9;
}

.telegram-send-button {
    background: #229ed9;
    color: #ffffff;
    font-size: 17px;
    box-shadow: 0 4px 11px rgba(34, 158, 217, 0.22);
}

.telegram-send-button:hover {
    background: #168ac4;
    transform: translateY(-1px);
}

.telegram-send-button:disabled,
.telegram-attachment-button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.telegram-message-form textarea {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    min-height: 42px;
    max-height: 112px;
    padding: 10px 12px;
    overflow-y: auto;
    resize: none;
    border: 1px solid #d9e0e8;
    border-radius: 18px;
    background: #f8fafc;
    color: #0f172a;
    font-family: inherit;
    font-size: 13px;
    line-height: 20px;
    outline: none;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        background 0.2s ease;
}

.telegram-message-form textarea::placeholder {
    color: #94a3b8;
}

.telegram-message-form textarea:focus {
    border-color: #229ed9;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(34, 158, 217, 0.1);
}

/* Bottom branding */
.telegram-chat-footer {
    flex: 0 0 auto;
    padding: 5px 10px 7px;
    background: #ffffff;
    color: #94a3b8;
    font-size: 9px;
    text-align: center;
}

/* =========================================================
   LOADING STATE
   ========================================================= */

.telegram-is-loading {
    pointer-events: none;
    opacity: 0.7;
}

.telegram-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: telegramSpin 0.7s linear infinite;
}

@keyframes telegramSpin {
    to {
        transform: rotate(360deg);
    }
}

/* =========================================================
   MOBILE RESPONSIVE DESIGN
   ========================================================= */

@media (max-width: 575px) {
    .telegram-support-widget {
        left: 12px;
        bottom: 14px;
    }

    .telegram-support-button {
        width: 54px;
        height: 54px;
        font-size: 26px;
    }

    .telegram-support-panel {
        position: fixed;
        left: 8px;
        right: 8px;
        bottom: 78px;
        width: auto;
        height: min(610px, calc(100vh - 95px));
        border-radius: 18px;
    }

    .telegram-support-header {
        min-height: 70px;
        padding: 12px 14px;
    }

    .telegram-support-logo {
        width: 42px;
        height: 42px;
        font-size: 21px;
    }

    .telegram-conversation,
    .telegram-visitor-form-wrapper {
        height: calc(100% - 70px);
    }

    .telegram-visitor-form-wrapper {
        padding: 18px 15px;
    }

    .telegram-message-bubble {
        max-width: 88%;
    }
}

/* Very small mobile screens */
@media (max-width: 360px) {
    .telegram-support-panel {
        left: 5px;
        right: 5px;
        bottom: 73px;
    }

    .telegram-message-form {
        padding-right: 7px;
        padding-left: 7px;
        gap: 5px;
    }

    .telegram-attachment-button,
    .telegram-send-button {
        width: 39px;
        height: 39px;
    }
}

/* Reduce animation for accessibility */
@media (prefers-reduced-motion: reduce) {
    .telegram-support-panel,
    .telegram-support-button,
    .telegram-start-button,
    .telegram-send-button {
        animation: none;
        transition: none;
    }
}