/* Chat Widget - Minimalist Design */

/* Chat Button Pulse Animation */
@keyframes chatButtonPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.08);
    }
}

/* Chat Button Icon Rotation Animation - один оборот раз в 10 секунд */
@keyframes chatButtonIconRotate {
    0%, 95% {
        transform: translateY(-2px) rotate(0deg);
    }
    100% {
        transform: translateY(-2px) rotate(360deg);
    }
}

/* Chat Button */
.chat-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.45);
    backdrop-filter: blur(14px) brightness(1.35);
    -webkit-backdrop-filter: blur(14px) brightness(1.35);
    border: 1px solid #09237C;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(9, 35, 124, 0.18);
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: visible;
    max-width: calc(100vw - 30px);
    animation: chatButtonPulse 2s ease-in-out infinite;
}

.chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(9, 35, 124, 0.28);
    animation: none;
}

.chat-button:active {
    transform: scale(0.95);
}

.chat-button-icon {
    width: 44px;
    height: 44px;
    object-fit: contain;
    position: relative;
    z-index: 1;
    filter: brightness(0) saturate(100%) invert(14%) sepia(71%) saturate(1300%) hue-rotate(213deg) brightness(82%);
    display: block;
    margin: 0 auto;
    animation: chatButtonIconRotate 10s ease-in-out infinite;
}

/* Chat Notification Badge */
.chat-notification-badge {
    position: absolute;
    top: -5px;
    right: 0px;
    width: 16px;
    height: 16px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid #ffffff;
    z-index: 1002;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Chat Widget — Liquid Glass */
.chat-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 440px;
    height: 645px;
    max-height: calc(100vh - 60px);
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(32px) saturate(180%);
    -webkit-backdrop-filter: blur(32px) saturate(180%);
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    box-shadow:
        0 24px 64px rgba(0, 0, 0, 0.18),
        0 4px 16px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    z-index: 1001;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.88) translateY(24px);
    transform-origin: bottom right;
    transition: opacity 0.22s cubic-bezier(0.4, 0, 1, 1),
                transform 0.25s cubic-bezier(0.4, 0, 1, 1),
                visibility 0s linear 0.25s;
    box-sizing: border-box;
}

.chat-widget.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1) translateY(0);
    /* Открытие: spring с лёгким overshoot */
    transition: opacity 0.38s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.48s cubic-bezier(0.34, 1.06, 0.64, 1),
                visibility 0s linear 0s;
}

/* Chat Header */
.chat-header-minimal {
    position: relative;
    padding: 16px 20px 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.55);
    background: rgba(255, 255, 255, 0.28);
    flex-shrink: 0;
    gap: 16px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

/* Chat Status Mini */
.chat-status-mini {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.58);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 12px;
    font-size: 0.75rem;
    color: #64748b;
    z-index: 10;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.chat-status-indicator-mini {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
    animation: pulse 2s infinite;
}

.chat-status-text-mini {
    font-weight: 500;
    font-size: 0.75rem;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Chat Tabs - Browser-like */
.chat-tabs {
    display: flex;
    gap: 4px;
    flex: 1;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.chat-tabs::-webkit-scrollbar {
    display: none;
}

.chat-tab {
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #4a515b;
    background: transparent;
    border: none;
    border-radius: 10px 10px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    position: relative;
    flex-shrink: 0;
    letter-spacing: -0.01em;
}

.chat-tab:hover {
    background: rgba(0, 0, 0, 0.03);
    color: #334155;
}

.chat-tab.active {
    color: #17255F;
    background: rgba(23, 37, 95, 0.08);
}

.chat-tab.active::after {
    content: '';
    position: absolute;
    bottom: -13px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 3px;
    background: linear-gradient(90deg, #17255F 0%, #1e3a8a 100%);
    border-radius: 3px 3px 0 0;
    box-shadow: 0 -2px 8px rgba(23, 37, 95, 0.2);
}

/* Close Button - No background */
.chat-close-button {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-close-button:hover {
    color: #1e293b;
    transform: rotate(90deg);
}

.chat-close-button svg {
    width: 23px;
    height: 23px;
    stroke: currentColor;
    stroke-width: 2;
}

/* Chat Content with Tabs */
.chat-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.chat-tab-content {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.chat-tab-content.active {
    display: flex;
}

/* Messages Container */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: transparent;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    margin: 0;
    position: relative;
}

/* Hide scrollbar but keep functionality */
.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.15);
}

/* Message Bubbles - Keep original style */
.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 75%;
    animation: messageSlideIn 0.25s ease-out;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.operator {
    align-self: flex-start;
}

.chat-message.user {
    align-self: flex-end;
}

.chat-message-bubble {
    padding: 0.875rem 1.125rem;
    border-radius: 18px;
    font-size: 0.9375rem;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
    padding-bottom: 1.875rem;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

.chat-message.operator .chat-message-bubble {
    background: rgba(255, 255, 255, 0.58);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow:
        0 2px 12px rgba(0, 0, 0, 0.07),
        0 1px 3px rgba(0, 0, 0, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.95);
    color: #1e293b;
    border-bottom-left-radius: 4px;
    min-width: 90px;
}

.chat-message.user .chat-message-bubble {
    background: rgba(23, 37, 95, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: white;
    border-bottom-right-radius: 4px;
    padding-bottom: 0.875rem;
}

.chat-message-meta {
    font-size: 0.75rem;
    color: rgba(100, 116, 139, 0.7);
    position: absolute;
    bottom: 0.5rem;
    right: 1rem;
}

.chat-message.operator .chat-message-meta {
    color: rgba(100, 116, 139, 0.6);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
    padding: 8px 0;
    min-height: 24px;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #64748b;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

/* Reduce padding for operator bubble with typing indicator */
.chat-message.operator .chat-message-bubble:has(.typing-indicator) {
    padding: 0.75rem 1.125rem;
    padding-bottom: 0.75rem;
    min-height: auto;
}

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Options Container - для уточняющих вопросов с кнопками */
.chat-options-container {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-option-button {
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    border: 1.5px solid rgba(255, 255, 255, 0.65);
    border-radius: 12px;
    font-size: 0.9375rem;
    font-weight: 500;
    color: #334155;
    cursor: pointer;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    font-family: inherit;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.chat-option-button:hover {
    border-color: rgba(23, 37, 95, 0.35);
    background: rgba(255, 255, 255, 0.72);
    transform: translateX(4px);
    box-shadow: 0 4px 14px rgba(23, 37, 95, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.chat-option-button:active {
    transform: translateX(2px);
}

.chat-option-button.active {
    background: rgba(23, 37, 95, 0.78);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(23, 37, 95, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.chat-option-button.selected {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}

.chat-option-button.selected::after {
    content: '✓';
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-weight: bold;
    color: #10b981;
}

.chat-option-button.active::after {
    content: '✓';
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-weight: bold;
    color: #ffffff;
}

/* Expertise Card */
.chat-expertise-card {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.52);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.chat-expertise-card-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-expertise-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: #17255F;
    margin: 0;
}

.chat-expertise-card-description {
    font-size: 0.875rem;
    color: #475569;
    line-height: 1.5;
    margin: 0;
}

.chat-expertise-card-details {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.chat-expertise-card-detail {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #64748b;
}

.chat-expertise-card-detail svg {
    width: 16px;
    height: 16px;
    color: #17255F;
}

.chat-expertise-card-button {
    display: inline-block;
    padding: 0.625rem 1.25rem;
    background: #17255F;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    text-align: center;
    transition: background 0.2s ease;
    margin-top: 0.25rem;
}

.chat-expertise-card-button:hover {
    background: #1e3a8a;
}

/* AI Info Card - Liquid glass bubble */
.ai-info-card {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: calc(100% - 40px);
    max-width: 340px;
    padding: 22px 20px;
    background: rgba(255, 255, 255, 0.58);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow:
        0 2px 12px rgba(0, 0, 0, 0.07),
        0 1px 3px rgba(0, 0, 0, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.95);
    text-align: left;
    overflow: hidden;
    pointer-events: auto;
    opacity: 1;
}

.ai-info-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #17255F;
    margin: 0 0 20px 0;
    letter-spacing: -0.01em;
    text-align: center;
}

.ai-info-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    counter-reset: ai-list;
}

.ai-info-list li {
    font-size: 0.9rem;
    color: #334155;
    line-height: 1.5;
    padding-left: 26px;
    position: relative;
    counter-increment: ai-list;
}

.ai-info-list li::before {
    content: counter(ai-list) '.';
    position: absolute;
    left: 0;
    top: 0;
    font-size: 0.875rem;
    font-weight: 700;
    color: #17255F;
    line-height: 1.5;
}

.ai-info-link {
    background: none;
    border: none;
    color: #17255F;
    text-decoration: none;
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
    padding: 0;
    margin: 0;
    transition: all 0.2s ease;
    font-weight: 600;
    border-bottom: 2px solid transparent;
    display: inline;
}

.ai-info-link:hover {
    color: #1e3a8a;
    border-bottom-color: #1e3a8a;
}

/* Input Container */
/* Operator Offline Notice */
.operator-offline-notice {
    padding: 12px 20px;
    background: #fef3c7;
    border-bottom: 1px solid #fde68ab6;
    margin: 0;
    box-sizing: border-box;
}

.operator-offline-notice p {
    margin: 0;
    font-size: 0.875rem;
    color: #92400e;
    text-align: center;
    line-height: 1.5;
}

.response-time-notice {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 12px 20px;
    padding: 10px 16px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    font-size: 0.813rem;
    color: #1e40af;
    line-height: 1.4;
    animation: noticeSlideIn 0.3s ease;
}

.response-time-notice svg {
    flex-shrink: 0;
    stroke: #3b82f6;
}

@keyframes noticeSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.chat-input-container {
    padding: 16px 20px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0));
    background: rgba(255, 255, 255, 0.28);
    border-top: 1px solid rgba(255, 255, 255, 0.58);
    display: flex;
    gap: 12px;
    align-items: center;
    margin: 0;
    box-sizing: border-box;
}

.chat-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.chat-input {
    width: 100%;
    padding: 10px 16px 13px 16px;
    border: 1.5px solid rgb(238 237 237 / 72%);
    border-radius: 24px;
    font-size: 0.9375rem;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
    height: 44px;
    min-height: 44px;
    max-height: 120px;
    box-sizing: border-box;
    line-height: 1.5;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.52);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    box-shadow:
        inset 0 1px 3px rgba(0, 0, 0, 0.05),
        inset 0 -1px 0 rgba(255, 255, 255, 0.6),
        0 1px 0 rgba(255, 255, 255, 0.7);
    color: #1e293b;
    vertical-align: top;
}

.chat-input:focus {
    border-color: rgba(23, 37, 95, 0.35);
    background: rgba(255, 255, 255, 0.72);
    box-shadow:
        0 0 0 1px rgba(23, 37, 95, 0.08),
        inset 0 1px 3px rgba(0, 0, 0, 0.04),
        inset 0 -1px 0 rgba(255, 255, 255, 0.7);
}

.chat-input::placeholder {
    color: #94a3b8;
    line-height: 1.5;
}

.chat-send-button {
    width: 49px;
    height: 49px;
    min-width: 49px;
    min-height: 49px;
    border-radius: 50%;
    background: rgba(23, 37, 95, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow:
        0 4px 14px rgba(23, 37, 95, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.16);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.chat-send-button:hover {
    background: rgba(30, 58, 138, 0.88);
    transform: scale(1.06);
    box-shadow:
        0 6px 18px rgba(23, 37, 95, 0.42),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.chat-send-button:active {
    transform: scale(0.95);
}

.chat-send-button:disabled {
    background: rgba(203, 213, 225, 0.7);
    backdrop-filter: blur(8px);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.chat-send-button svg {
    width: 20px;
    height: 20px;
    stroke: white;
    stroke-width: 2;
    margin-bottom: 2px;
}

/* Mobile Styles */
/* Mobile Styles - FULL SCREEN FIX */
@media (max-width: 480px) {
    /* Prevent body scroll when chat is open */
    body.chat-open {
        overflow: hidden !important;
        position: fixed !important;
        width: 100% !important;
        height: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: 0 !important;
        bottom: 0 !important;
    }

    html.chat-open {
        overflow: hidden !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        height: 100% !important;
        position: relative !important;
    }

    .chat-button {
        bottom: 30px;
        right: 15px;
        width: 72px;
        height: 72px;
        z-index: 1000;
        max-width: calc(100vw - 30px);
    }

    .chat-button svg {
        width: 24px;
        height: 24px;
    }

    /* Chat widget - FIXED FULL SCREEN */
    .chat-widget {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        width: 100vw !important;
        width: 100dvw !important;
        height: 100% !important;
        height: 100vh !important;
        height: 100dvh !important;
        min-width: 100% !important;
        min-height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: translateY(100%) !important;
        transform-origin: center !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
        z-index: 1001 !important;
        /* Закрытие: быстрый slide down */
        transition: transform 0.32s cubic-bezier(0.4, 0, 1, 1) !important;
        background: rgba(245, 247, 255, 0.96) !important;
        backdrop-filter: blur(32px) saturate(180%) !important;
        -webkit-backdrop-filter: blur(32px) saturate(180%) !important;
    }

    .chat-widget.active {
        transform: translateY(0) !important;
        opacity: 1 !important;
        visibility: visible !important;
        transition: transform 0.46s cubic-bezier(0.34, 1.02, 0.64, 1) !important;
    }

    /* Ensure chat fills screen */
    .chat-widget:not(.active) {
        transform: translateY(100%) !important;
    }

    .chat-header-minimal {
        padding-top: calc(12px + env(safe-area-inset-top, 0)) !important;
        padding-left: calc(16px + env(safe-area-inset-left, 0)) !important;
        padding-right: calc(16px + env(safe-area-inset-right, 0)) !important;
        padding-bottom: 12px !important;
        border-bottom: 1px solid #cacfd5 !important;
    }

    .chat-tab {
        font-size: 0.9125rem !important;
        padding: 10px 12px !important;
    }

    .chat-tab.active::after {
        bottom: -13px !important;
    }

    .chat-close-button {
        z-index: 1002 !important;
    }

    .ai-info-card {
        padding: 16px !important;
        border-radius: 16px !important;
        width: calc(100% - 32px) !important;
    }

    .chat-messages {
        flex: 1 !important;
        padding: 16px 16px 24px 16px !important;
        margin: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem !important;
    }

    .chat-input-container {
        padding: 16px !important;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0)) !important;
        margin: 0 !important;
        margin-top: auto !important;
        width: 100% !important;
        border-top: 1px solid #cacfd5 !important;
        position: relative !important;
        box-sizing: border-box !important;
        flex-shrink: 0 !important;
    }

    .chat-input-wrapper {
        width: 100% !important;
    }

    .chat-input {
        width: 100% !important;
        font-size: 16px !important; /* Prevents zoom on iOS */
        box-sizing: border-box !important;
    }

    /* Make sure message bubbles fill width appropriately */
    .chat-message {
        max-width: 85% !important;
    }
}

/* Tablet Styles */
@media (min-width: 481px) and (max-width: 768px) {
    .chat-widget {
        width: 380px;
        height: 580px;
        max-height: calc(100vh - 60px);
    }
    
    .chat-widget.active {
        transform: scale(1) translateY(0) !important;
    }
}

/* Fix for iOS Safari 100vh issue */
@supports (-webkit-touch-callout: none) {
    .chat-widget {
        height: -webkit-fill-available;
    }
}

/* Ensure safe area handling */
.chat-messages {
    padding-top: calc(24px + env(safe-area-inset-top, 0));
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0));
}

.chat-input-container {
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0));
}

/* Fix for message container scroll */
.chat-messages {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* Operator Chat Modal */
.operator-chat-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.operator-chat-modal.active {
    display: flex;
}

.operator-chat-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.operator-chat-modal-content {
    position: relative;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(32px) saturate(180%);
    -webkit-backdrop-filter: blur(32px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 32px;
    padding: 32px;
    max-width: 450px;
    width: 100%;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.22),
        0 8px 24px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.95);
    animation: modalSlideIn 0.3s ease-out;
    z-index: 10001;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.operator-chat-modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 24px 0;
    text-align: center;
    line-height: 1.4;
}

.operator-chat-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.operator-chat-form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.operator-chat-form-group label {
    font-size: 0.9375rem;
    font-weight: 500;
    color: #334155;
}

.operator-chat-form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid #e2e8f0;
    border-radius: 16px;
    font-size: 0.9375rem;
    font-family: inherit;
    color: #1e293b;
    background: #ffffff;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.operator-chat-form-group input:focus {
    outline: none;
    border-color: #17255F;
    box-shadow: 0 0 0 3px rgba(23, 37, 95, 0.1);
}

.operator-chat-form-group input::placeholder {
    color: #94a3b8;
}

.operator-chat-submit-btn {
    width: 100%;
    padding: 14px 24px;
    background: #17255F;
    color: #ffffff;
    border: none;
    border-radius: 16px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 8px;
}

.operator-chat-submit-btn:hover {
    background: #1e3a8a;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(23, 37, 95, 0.25);
}

.operator-chat-submit-btn:active {
    transform: translateY(0);
}

.operator-chat-submit-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    transform: none;
}

.operator-chat-disclaimer {
    font-size: 0.75rem;
    color: #64748b;
    text-align: center;
    line-height: 1.5;
}

@media (max-width: 480px) {
    .operator-chat-modal-content {
        padding: 24px 20px;
        border-radius: 20px;
        max-width: 100%;
    }

    .operator-chat-modal-title {
        font-size: 1.25rem;
        margin-bottom: 20px;
    }

    .operator-chat-form {
        gap: 16px;
    }
}