/* Minimalistic Professional Chat Interface */

/* Reset and Base Styles */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* Prevent horizontal scrolling on mobile */
html {
    overflow-x: hidden;
}

/* Mobile viewport optimization */
@media (max-width: 1024px) {
    html, body {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* Full Width Chat Interface */
.livechat-page-wrapper {
    background: #f8fafc !important;
    width: 100vw !important;
    margin-left: calc(-50vw + 50%) !important;
    margin-right: calc(-50vw + 50%) !important;
    padding: 32px 60px !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif !important;
    display: flex !important;
    justify-content: center !important;
    align-items: flex-start !important;
    box-sizing: border-box !important;
    position: relative !important;
    overflow-x: hidden !important;
    min-height: auto !important;
}

/* Override any parent container constraints */
.livechat-page-wrapper * {
    box-sizing: border-box !important;
}

.wp-livechat-container-wrapper {
    width: 100%;
    max-width: 1920px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 5px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    height: auto;
    min-height: 700px;
    border: 1px solid #d1d5db;
}

/* Main Container */
.livechat-container {
    width: 100%;
    max-width: 1920px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 5px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    min-height: 700px;
    border: 1px solid #d1d5db;
    position: relative;
}

/* Two Column Layout */
.livechat-layout {
    display: flex !important;
    height: 100%;
    width: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

/* Ensure semantic HTML elements work properly */
.livechat-layout > * {
    box-sizing: border-box;
}

/* Large Screen Optimization */
@media (min-width: 1920px) {
    .livechat-page-wrapper,
    .wp-livechat-page-wrapper {
        padding: 40px 80px !important;
    }
    
    .livechat-container,
    .wp-livechat-container-wrapper {
        border-radius: 5px;
    }
    
    .livechat-info-panel {
        width: 500px;
    }
    
    .livechat-info-content {
        padding: 32px;
    }
    
    .livechat-chat-header {
        padding: 24px 32px;
    }
    
    .livechat-messages-wrapper {
        padding: 40px 48px;
    }
    
    .livechat-closed-notice {
        padding: 40px 32px;
        gap: 24px;
    }
    
    .livechat-closed-icon {
        width: 64px;
        height: 64px;
        font-size: 22px;
        border-radius: 5px;
    }
    
    .livechat-closed-message h3 {
        font-size: 20px;
    }
    
    .livechat-input-section {
        padding: 20px 32px;
        width: 100%;
    }
}

/* Left Panel - Information & Rules */
.livechat-info-panel,
aside.livechat-info-panel {
    width: 480px;
    background: #f8fafc;
    border-right: 1px solid #d1d5db;
    display: flex !important;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    box-sizing: border-box;
}

.livechat-info-content {
    padding: 20px;
    padding-bottom: 24px;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 12px;
}

.livechat-info-content::-webkit-scrollbar {
    width: 4px;
}

.livechat-info-content::-webkit-scrollbar-track {
    background: transparent;
}

.livechat-info-content::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

/* Info Panel Header */
.livechat-info-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    gap: 12px;
    margin-bottom: 0;
    padding-bottom: 16px;
    border-bottom: 1px solid #d1d5db;
}

.livechat-header-row {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    width: 100%;
}

.livechat-header-subtitle {
    width: 100%;
    margin-left: 0;
}

.livechat-info-icon {
    width: 56px;
    height: 56px;
    background: transparent;
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.livechat-info-title {
    padding-top: 10px;
    flex: 1;
    align-self: flex-start;
}

.livechat-info-title h1 {
    margin: 0 0 2px 0;
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.1;
    padding: 0;
}

.livechat-info-title p {
    margin: 0;
    font-size: 13px;
    color: #64748b;
    font-weight: 500;
    line-height: 1.2;
    padding: 0;
}

.livechat-header-subtitle p {
    margin: 0;
    font-size: 14px;
    color: #64748b;
    font-weight: 400;
    line-height: 1.3;
}

/* Info Sections */
.livechat-info-section {
    margin-bottom: 0;
    flex-shrink: 0;
}

.livechat-info-section:last-child {
    margin-bottom: 0;
}

.livechat-info-section h3 {
    margin: 0 0 6px 0;
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
}

.livechat-info-section p {
    margin: 0;
    font-size: 12px;
    line-height: 1.3;
    color: #475569;
}

.livechat-info-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.livechat-info-list li {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 12px;
    line-height: 1.2;
    color: #475569;
}

.livechat-info-list li i {
    color: #10b981;
    font-size: 10px;
    margin-top: 2px;
    flex-shrink: 0;
}

.livechat-info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3px;
    font-size: 12px;
}

.livechat-info-label {
    color: #64748b;
    font-weight: 400;
}

.livechat-info-value {
    color: #1e293b;
    font-weight: 500;
}

/* Status Indicators */
.livechat-status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
}

.livechat-status-indicator.status-waiting {
    color: #f59e0b;
}

.livechat-status-indicator.status-active {
    color: #10b981;
}

.livechat-status-indicator.status-closed {
    color: #ef4444;
}

.livechat-status-indicator i {
    font-size: 10px;
}

/* Privacy Notice */
.livechat-privacy-notice {
    background: #f1f5f9;
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #d1d5db;
    margin-top: 12px;
    flex-shrink: 0;
}

.livechat-privacy-notice h3 {
    margin: 0 0 5px 0;
    font-size: 13px;
    color: #1e293b;
}

.livechat-privacy-notice p {
    margin: 0;
    font-size: 11px;
    line-height: 1.4;
    color: #475569; /* was #64748b at 4.34:1 on #f1f5f9 */
}

.wp-livechat-error {
    padding: 40px;
    text-align: center;
    color: #6c757d;
    font-size: 16px;
}

/* Right Panel - Chat Interface */
.livechat-chat-panel,
main.livechat-chat-panel {
    flex: 1;
    display: flex !important;
    flex-direction: column;
    background: #ffffff;
    min-width: 0;
    box-sizing: border-box;
}

/* Chat Header */
.livechat-chat-header {
    padding: 20px 24px;
    border-bottom: 1px solid #d1d5db;
    background: #ffffff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.livechat-chat-title {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.livechat-chat-title h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.2;
}

.livechat-connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
}



.livechat-connection-text {
    font-size: 13px;
    color: #64748b;
    font-weight: 400;
}

.livechat-chat-actions {
    display: flex;
    align-items: center;
}

.livechat-close-btn {
    width: auto;
    min-width: 32px;
    height: 32px;
    padding: 0 12px;
    gap: 6px;
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #64748b;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    white-space: nowrap;
}

.livechat-close-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #1e293b;
}

.livechat-close-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Legacy header support */
.livechat-header {
    background: #ffffff;
    color: #1e293b;
    padding: 0;
    flex-shrink: 0;
    border-bottom: 1px solid #e2e8f0;
}

.livechat-header-wrapper {
    padding: 0;
}

.livechat-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 28px 32px 24px;
}

.livechat-brand-section {
    display: flex;
    align-items: center;
    gap: 20px;
}

.livechat-brand-icon {
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.livechat-brand-info {
    flex: 1;
}

.livechat-brand-title {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.5px;
}

.livechat-brand-subtitle {
    margin-top: 6px;
    font-size: 16px;
    opacity: 0.9;
    font-weight: 400;
    line-height: 1.4;
}

.livechat-status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.livechat-status-indicator i {
    font-size: 8px;
    animation: pulse-dot 2s infinite;
}

.livechat-status-connected i {
    color: #4ade80;
}

.livechat-separator {
    opacity: 0.6;
}

.livechat-header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.livechat-connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Professional Status Bar */
.livechat-status-bar {
    background: rgba(255, 255, 255, 0.08);
    padding: 16px 32px;
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.livechat-status-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.livechat-session-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.livechat-session-time {
    font-size: 14px;
    opacity: 0.8;
    font-weight: 400;
}

.livechat-session-time i {
    margin-right: 6px;
    font-size: 12px;
}

.livechat-support-status {
    display: flex;
    align-items: center;
}

.livechat-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
}

.livechat-status-waiting {
    color: #fbbf24;
}

.livechat-status-active {
    color: #4ade80;
}

/* Messages Container */
.livechat-messages-container {
    height: clamp(480px, 65vh, 900px) !important;
    max-height: none !important;
    overflow: hidden;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

/* Closed Room Notice */
.livechat-closed-notice {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    background: #f8fafc;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    margin: 16px;
    color: #475569;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.livechat-closed-notice::before {
    display: none;
}

.livechat-closed-icon {
    width: 56px;
    height: 56px;
    background: #64748b;
    color: white;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
}

.livechat-closed-icon::after {
    display: none;
}

.livechat-closed-message {
    flex: 1;
    max-width: 400px;
}

.livechat-closed-message h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.3;
}

.livechat-closed-message p {
    margin: 0;
    font-size: 14px;
    color: #64748b;
    line-height: 1.5;
    opacity: 0.9;
}

.livechat-messages-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 32px 40px;
    scroll-behavior: smooth;
    height: 100%;
    max-height: 600px;
}

/* Screen Reader Only */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.livechat-messages-wrapper::-webkit-scrollbar {
    width: 4px;
}

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

.livechat-messages-wrapper::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

.livechat-messages-wrapper::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.livechat-messages-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 100%;
}

/* Clean Message Styles */
.livechat-message {
    width: 100%;
}

.livechat-message-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    max-width: 70%;
}

.livechat-message-sent .livechat-message-wrapper {
    margin-left: auto;
    flex-direction: row-reverse;
}

.livechat-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
    border: 2px solid #ffffff;
}

.livechat-message-avatar-current {
    background: #000080;
    color: white;
}

/* Brand logo avatar (admin / AI replies). The logo is a self-contained
   circular badge, so it fills the avatar with no background tint or border. */
.livechat-message-avatar-logo {
    background: transparent;
    border: 0;
    padding: 0;
    overflow: hidden;
}
.livechat-message-avatar-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.livechat-message-content {
    flex: 1;
    min-width: 0;
}

.livechat-message-sender {
    font-size: 13px;
    font-weight: 600;
    color: #4b5563;
    margin-bottom: 6px;
    padding-left: 18px;
    letter-spacing: 0.3px;
}

.livechat-message-sent .livechat-message-sender {
    text-align: right;
    padding-left: 0;
    padding-right: 18px;
    color: #374151;
}

.livechat-message-bubble {
    background: #000080;
    border: 1px solid #000080;
    border-radius: 5px;
    padding: 12px 16px;
    box-shadow: none;
    position: relative;
    max-width: 100%;
    word-wrap: break-word;
}

.livechat-message-sent .livechat-message-bubble {
    background: #000080;
    color: white;
    border-color: #000080;
}

.livechat-message-bubble::before {
    content: '';
    position: absolute;
    bottom: 4px;
    left: -6px;
    width: 0;
    height: 0;
    border: 6px solid transparent;
    border-right-color: #000080;
    border-left: none;
}

.livechat-message-sent .livechat-message-bubble::before {
    left: auto;
    right: -6px;
    border-right: none;
    border-left-color: #000080;
}

.livechat-message-text {
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    font-weight: 400;
    color: white;
}

.livechat-message-sent .livechat-message-text {
    color: white;
}

.livechat-message-time {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
    text-align: right;
    font-weight: 400;
}

.livechat-message-received .livechat-message-time {
    text-align: left;
}

.livechat-message-sent .livechat-message-time {
    color: rgba(255, 255, 255, 0.7);
}

/* Professional System Messages */
.livechat-system-message {
    text-align: center;
    margin: 24px 0;
}

.livechat-system-content {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: #f8fafc;
    color: #64748b;
    padding: 12px 20px;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid #d1d5db;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.livechat-system-time {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 6px;
    font-weight: 400;
}

/* JavaScript-rendered system messages */
.livechat-message-system {
    text-align: center;
    margin: 16px 0;
    width: 100%;
}

.livechat-message-system .livechat-message-wrapper {
    justify-content: center;
    max-width: none;
    width: 100%;
    display: flex;
}

.livechat-message-system .livechat-message-content {
    background: #f9fafb;
    color: #000000;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    display: inline-block;
    text-align: center;
    max-width: 80%;
    margin: 0 auto;
}

.livechat-message-system .livechat-message-bubble {
    background: none;
    border: none;
    box-shadow: none;
    padding: 0;
    margin: 0;
}

.livechat-message-system .livechat-message-text {
    margin: 0;
    color: #000000;
    font-weight: 500;
    line-height: 1.4;
}

.livechat-message-system .livechat-message-time {
    font-size: 11px;
    color: #6b7280;
    margin-top: 4px;
    opacity: 0.8;
    text-align: center;
}

/* Ensure system messages are properly centered and aligned */
.livechat-message-system * {
    color: #000000 !important;
}

.livechat-message-system .livechat-message-content {
    position: relative;
    margin: 0 auto;
    width: fit-content;
}

/* Override any inherited styles that might affect system message alignment */
.livechat-message-system .livechat-message-wrapper {
    margin: 0 auto;
    align-items: center;
    flex-direction: column;
}

/* Improve spacing and visual hierarchy */
.livechat-message-system + .livechat-message-system {
    margin-top: 8px;
}

.livechat-message-system + .livechat-message:not(.livechat-message-system) {
    margin-top: 20px;
}

.livechat-message:not(.livechat-message-system) + .livechat-message-system {
    margin-top: 20px;
}

/* Typing Indicator */
.livechat-typing-indicator {
    display: none;
    padding: 8px 0;
}

.livechat-typing-indicator.show {
    display: block;
}

.livechat-typing-bubble {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 90%;
}

.livechat-typing-dots {
    background: #f9fafb;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    padding: 12px 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 4px;
}

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

.livechat-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.livechat-typing-dots span:nth-child(2) { animation-delay: -0.16s; }
.livechat-typing-dots span:nth-child(3) { animation-delay: 0s; }

.livechat-typing-text {
    font-size: 12px;
    color: #6b7280;
    font-style: italic;
}

/* Input Section */
.livechat-input-section {
    background: #ffffff;
    border-top: 1px solid #d1d5db;
    padding: 16px 24px;
    flex-shrink: 0;
    width: 100%;
}

.livechat-input-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.livechat-input-wrapper {
    display: flex;
    align-items: center;
    background: #f8fafc;
    border: 1px solid #8796a5; /* 1.4.11: field boundary needs 3:1 */
    border-radius: 5px;
    padding: 3px;
    transition: all 0.2s ease;
    width: 100%;
}

.livechat-input-wrapper:focus-within {
    background: #ffffff;
    border-color: #000080;
    box-shadow: 0 0 0 3px rgba(0, 0, 128, 0.1);
}

.livechat-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.4;
    outline: none;
    color: #1e293b;
    font-family: inherit;
    min-width: 0;
    width: 100%;
}

.livechat-input::placeholder {
    color: #5b6677; /* 4.5:1+ on #f8fafc (was #94a3b8 at 2.45:1) */
}

.livechat-input:disabled {
    background: #f1f5f9;
    color: #64748b;
    cursor: not-allowed;
}

.livechat-input-actions {
    display: flex;
    align-items: center;
    gap: 3px;
    padding-right: 3px;
    flex-shrink: 0;
}

.livechat-attach-btn {
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    border: none;
    background: transparent;
    color: #64748b;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 15px;
}

.livechat-attach-btn:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.livechat-send-btn {
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    border: none;
    background: #000080;
    color: white;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 15px;
}

.livechat-send-btn:hover {
    background: #000066;
}

.livechat-send-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
}

.livechat-char-counter {
    text-align: right;
    font-size: 10px;
    color: #5b6677; /* was #94a3b8 at 2.56:1 */
    margin-top: 2px;
    line-height: 1;
}

/* Disabled Input State */
.livechat-input-disabled {
    padding: 16px;
    text-align: center;
}

.livechat-disabled-message {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #64748b;
    font-size: 14px;
    font-weight: 500;
}

.livechat-disabled-message i {
    font-size: 16px;
}

.livechat-new-chat-section {
    margin-top: 16px;
    text-align: center;
}

.livechat-new-chat-btn {
    background: #000080;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
}

.livechat-new-chat-btn:hover {
    background: #000066;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 128, 0.3);
}

.livechat-new-chat-btn:active {
    transform: translateY(0);
}

/* Legacy styles */
.livechat-footer {
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.livechat-input-container {
    background: #ffffff;
    padding: 14px 24px;
    flex-shrink: 0;
    width: 100%;
}

.livechat-input-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    width: 100%;
}

.livechat-input-wrapper {
    flex: 1;
    position: relative;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 5px;
    display: flex;
    align-items: center;
    padding: 3px;
    transition: all 0.2s ease;
    width: 100%;
}

.livechat-input-wrapper:focus-within {
    background: #ffffff;
    border-color: #000080;
    box-shadow: 0 0 0 3px rgba(0, 0, 128, 0.1);
}

.livechat-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.4;
    outline: none;
    resize: none;
    font-family: inherit;
    min-width: 0;
    width: 100%;
}

.livechat-input::placeholder {
    color: #9ca3af;
}

.livechat-input:disabled {
    background: #f3f4f6;
    color: #6b7280;
    cursor: not-allowed;
}

.livechat-input:disabled::placeholder {
    color: #9ca3af;
}

.livechat-input-actions {
    display: flex;
    align-items: center;
    gap: 3px;
    padding-right: 3px;
    flex-shrink: 0;
}

/* Buttons */
.livechat-btn {
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 14px;
}

.livechat-btn:hover {
    transform: scale(1.05);
}

.livechat-btn:active {
    transform: scale(0.95);
}

.livechat-btn-icon {
    width: 36px;
    height: 36px;
    color: #6b7280;
    background: transparent;
}

.livechat-btn-icon:hover {
    background: rgba(0, 0, 128, 0.1);
    color: #000080;
}

.livechat-btn-icon:disabled {
    background: transparent;
    color: #d1d5db;
    cursor: not-allowed;
    transform: none;
}

.livechat-btn-send {
    width: 36px;
    height: 36px;
    background: #000080;
    color: white;
}

.livechat-btn-send:hover {
    background: #000066;
}

.livechat-btn-send:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    transform: none;
}

.livechat-btn-close {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.livechat-btn-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.livechat-btn-close:disabled {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.4);
    cursor: not-allowed;
    transform: none;
    border-color: rgba(255, 255, 255, 0.1);
}

.livechat-btn-text {
    font-size: 14px;
    font-weight: 500;
}

/* Legacy button support */
.livechat-btn-ghost {
    width: 32px;
    height: 32px;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.1);
}

.livechat-btn-ghost:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.livechat-btn-ghost:disabled {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
    cursor: not-allowed;
    transform: none;
}

/* Upload Progress */
.livechat-upload-progress {
    display: none;
    margin-top: 8px;
    padding: 8px 12px;
    background: #f9fafb;
    border-radius: 3px;
    border: 1px solid #e5e7eb;
}

.livechat-upload-progress.show {
    display: block;
}

.livechat-progress-bar {
    height: 3px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 6px;
}

.livechat-progress-fill {
    height: 100%;
    background: #1e40af;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.livechat-progress-text {
    font-size: 11px;
    color: #6b7280;
}

/* Character Counter */
.livechat-char-counter {
    text-align: right;
    margin-top: 4px;
    font-size: 10px;
    color: #5b6677; /* WCAG AA: 6.1:1 on white (was #9ca3af at 2.53:1) */
    line-height: 1;
}

/* Animations */
@keyframes pulse-dot {
    0%, 70%, 100% {
        opacity: 1;
    }
    35% {
        opacity: 0.3;
    }
}

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

/* Responsive Design */
@media (max-width: 1600px) {
    .livechat-page-wrapper,
    .wp-livechat-page-wrapper {
        padding: 24px 48px !important;
    }
    
    .livechat-info-panel {
        width: 420px;
    }
    
    .livechat-info-content {
        padding: 32px;
    }
    
    .livechat-chat-header {
        padding: 18px 24px;
    }
    
    .livechat-messages-wrapper {
        padding: 28px 36px;
    }
    
    .livechat-closed-notice {
        padding: 28px 24px;
        gap: 16px;
        margin: 12px;
    }
    
    .livechat-closed-icon {
        width: 48px;
        height: 48px;
        font-size: 18px;
        border-radius: 5px;
    }
    
    .livechat-closed-message h3 {
        font-size: 16px;
    }
    
    .livechat-input-section {
        padding: 16px 28px;
        width: 100%;
    }
}

@media (max-width: 1200px) {
    .livechat-page-wrapper,
    .wp-livechat-page-wrapper {
        padding: 20px 40px !important;
    }
    
    .livechat-container,
    .wp-livechat-container-wrapper {
        height: auto;
    }
    
    .livechat-info-panel {
        width: 380px;
    }
    
    .livechat-info-content {
        padding: 24px;
    }
    
    .livechat-chat-header {
        padding: 16px 20px;
    }
    
    .livechat-messages-wrapper {
        padding: 24px 32px;
    }
    
    .livechat-closed-notice {
        padding: 24px 20px;
        gap: 16px;
        flex-direction: column;
        text-align: center;
        margin: 12px;
    }
    
    .livechat-closed-icon {
        width: 48px;
        height: 48px;
        font-size: 18px;
        border-radius: 5px;
    }
    
    .livechat-closed-message {
        max-width: none;
    }
    
    .livechat-closed-message h3 {
        font-size: 16px;
    }
    
    .livechat-input-section {
        padding: 14px 24px;
        width: 100%;
    }
}

@media (max-width: 1024px) {
    .livechat-page-wrapper,
    .wp-livechat-page-wrapper {
        padding: 16px 32px !important;
        overflow-x: hidden !important;
    }
    
    .livechat-container,
    .wp-livechat-container-wrapper {
        height: auto;
        min-height: 600px;
        border-radius: 5px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    }
    
    .livechat-layout {
        flex-direction: column !important;
        overflow: hidden;
        position: relative;
        display: flex !important;
        height: 100%;
    }
    
    /* Full width info panel on mobile */
    .livechat-info-panel,
    aside.livechat-info-panel {
        width: 100% !important;
        height: auto !important;
        min-height: auto !important;
        max-height: none !important;
        border-right: none !important;
        border-bottom: 1px solid #d1d5db;
        overflow: visible !important;
        flex-shrink: 0;
        position: relative;
        background: #f8fafc;
        cursor: default;
        display: block !important;
    }
    
    .livechat-info-content {
        padding: 16px;
        padding-bottom: 24px;
        display: flex;
        flex-direction: column;
        gap: 16px;
        overflow: visible;
        height: auto;
        min-height: auto;
        align-items: stretch;
        justify-content: flex-start;
    }
    
    /* Remove scrollbars */
    .livechat-info-content::-webkit-scrollbar {
        display: none;
    }
    
    .livechat-info-section {
        flex-shrink: 0;
        margin-bottom: 12px;
        width: 100%;
        max-width: none;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .livechat-info-section:last-child {
        margin-bottom: 0;
    }
    
    .livechat-info-section h3 {
        font-size: 14px;
        margin-bottom: 8px;
        white-space: normal;
        word-wrap: break-word;
        line-height: 1.2;
    }
    
    .livechat-info-list {
        white-space: normal;
        margin: 0;
        padding: 0;
    }
    
    .livechat-info-list li {
        font-size: 13px;
        margin-bottom: 10px;
        white-space: normal;
        line-height: 1.3;
        word-break: break-word;
        display: flex;
        align-items: flex-start;
        gap: 8px;
    }
    
    .livechat-info-item {
        font-size: 13px;
        margin-bottom: 6px;
        white-space: normal;
        word-wrap: break-word;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
    }
    
    .livechat-info-label,
    .livechat-info-value {
        white-space: normal;
        word-break: break-word;
        line-height: 1.3;
    }
    
    .livechat-info-value {
        text-align: right;
        flex-shrink: 0;
        margin-left: 8px;
    }
    
    .livechat-info-header {
        flex-shrink: 0;
        margin-bottom: 0;
        padding-bottom: 12px;
        border-bottom: 1px solid #d1d5db;
        width: 100%;
        max-width: none;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
        gap: 8px;
        order: -1;
        flex-basis: 100%;
    }
    
    .livechat-header-row {
        display: flex;
        align-items: flex-start;
        gap: 12px;
        width: 100%;
    }
    
    .livechat-info-icon {
        width: 48px;
        height: 48px;
        font-size: 12px;
        border-radius: 6px;
        background: transparent;
    }
    
    .livechat-info-title h1 {
        font-size: 16px;
        margin: 0 0 1px 0;
        padding: 0;
        line-height: 1.1;
    }
    
    .livechat-info-title p {
        font-size: 12px;
        margin: 0;
        padding: 0;
        line-height: 1.2;
    }
    
    .livechat-header-subtitle p {
        font-size: 13px;
        margin: 0;
    }
    
    .livechat-info-title h1,
    .livechat-info-title p {
        white-space: normal;
        word-wrap: break-word;
        line-height: 1.2;
    }
    
    /* Privacy notice specific styling for column layout */
    .livechat-privacy-notice {
        width: 100%;
        max-width: none;
        padding: 10px;
        background: #f8fafc;
        border-radius: 5px;
        border: 1px solid #d1d5db;
    }
    
    .livechat-privacy-notice h3 {
        white-space: normal;
        word-wrap: break-word;
        font-size: 13px;
        margin-bottom: 6px;
    }
    
    .livechat-privacy-notice p {
        white-space: normal;
        word-wrap: break-word;
        line-height: 1.3;
        font-size: 12px;
        margin: 0;
    }
    
    .livechat-chat-panel,
    main.livechat-chat-panel {
        flex: 1;
        min-height: 0;
        overflow: hidden;
        display: flex !important;
        flex-direction: column;
        width: 100%;
    }
    
    /* Fixed height for chat messages area */
    .livechat-messages-container {
        height: clamp(420px, 70vh, 800px) !important;
        max-height: none !important;
        display: flex !important;
        flex-direction: column;
        flex-shrink: 0;
        overflow: hidden;
    }
    
    /* Better mobile message layout */
    .livechat-messages-wrapper {
        flex: 1;
        overflow-y: auto;
        padding: 16px;
    }
    
    /* Ensure proper input section positioning */
    .livechat-input-section {
        position: sticky;
        bottom: 0;
        background: #ffffff;
        border-top: 1px solid #d1d5db;
        z-index: 5;
        width: 100%;
    }
}

@media (max-width: 768px) {
    .livechat-page-wrapper,
    .wp-livechat-page-wrapper {
        padding: 12px 20px !important;
        overflow-x: hidden !important;
    }
    
    .livechat-container,
    .wp-livechat-container-wrapper {
        height: auto;
        min-height: 500px;
        border-radius: 5px;
        box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
    }
    
    /* Full content info panel on tablets */
    .livechat-info-panel,
    aside.livechat-info-panel {
        height: auto !important;
        min-height: auto !important;
        max-height: none !important;
        border-radius: 5px 5px 0 0;
        overflow: visible !important;
        width: 100% !important;
        display: block !important;
        border-right: none !important;
    }
    
    .livechat-layout {
        flex-direction: column !important;
        display: flex !important;
        height: 100%;
    }
    
    .livechat-chat-panel,
    main.livechat-chat-panel {
        flex: 1;
        display: flex !important;
        flex-direction: column;
        width: 100%;
    }
    
    .livechat-info-content {
        padding: 12px;
        padding-bottom: 20px;
        gap: 12px;
        overflow: visible;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        height: auto;
        min-height: auto;
    }
    
    .livechat-info-content::-webkit-scrollbar {
        display: none;
    }
    
    .livechat-info-section {
        width: 100%;
        max-width: none;
        word-wrap: break-word;
        overflow-wrap: break-word;
        margin-bottom: 10px;
        flex-shrink: 0;
    }
    
    .livechat-info-section:last-child {
        margin-bottom: 0;
    }
    
    .livechat-info-section h3 {
        font-size: 13px;
        margin-bottom: 6px;
        white-space: normal;
        word-wrap: break-word;
        line-height: 1.2;
    }
    
    .livechat-info-list {
        white-space: normal;
        margin: 0;
        padding: 0;
    }
    
    .livechat-info-list li {
        font-size: 12px;
        margin-bottom: 8px;
        white-space: normal;
        line-height: 1.3;
        word-break: break-word;
        display: flex;
        align-items: flex-start;
        gap: 6px;
    }
    
    .livechat-info-item {
        font-size: 12px;
        margin-bottom: 4px;
        white-space: normal;
        word-wrap: break-word;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
    }
    
    .livechat-info-label,
    .livechat-info-value {
        white-space: normal;
        word-break: break-word;
        line-height: 1.2;
        font-size: 11px;
    }
    
    .livechat-info-value {
        text-align: right;
        flex-shrink: 0;
        margin-left: 6px;
    }
    
    .livechat-info-header {
        width: 100%;
        max-width: none;
        margin-bottom: 0;
        padding-bottom: 10px;
        border-bottom: 1px solid #d1d5db;
        order: -1;
        flex-basis: 100%;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
        gap: 6px;
    }
    
    .livechat-header-row {
        display: flex;
        align-items: flex-start;
        gap: 10px;
        width: 100%;
    }
    
    .livechat-info-icon {
        width: 42px;
        height: 42px;
        font-size: 11px;
        border-radius: 6px;
        background: transparent;
    }
    
    .livechat-info-title h1 {
        font-size: 15px;
        margin: 0 0 1px 0;
        padding: 0;
        line-height: 1.1;
    }
    
    .livechat-info-title p {
        font-size: 11px;
        margin: 0;
        padding: 0;
        line-height: 1.2;
    }
    
    .livechat-header-subtitle p {
        font-size: 12px;
        margin: 0;
    }
    
    .livechat-info-title h1,
    .livechat-info-title p {
        white-space: normal;
        word-wrap: break-word;
        line-height: 1.2;
    }
    
    /* Privacy notice for 768px breakpoint */
    .livechat-privacy-notice {
        width: 100%;
        max-width: none;
        padding: 10px;
        background: #f8fafc;
        border-radius: 5px;
        border: 1px solid #d1d5db;
    }
    
    .livechat-privacy-notice h3 {
        white-space: normal;
        word-wrap: break-word;
        font-size: 12px;
        margin-bottom: 5px;
    }
    
    .livechat-privacy-notice p {
        white-space: normal;
        word-wrap: break-word;
        line-height: 1.3;
        font-size: 11px;
        margin: 0;
    }
    
    .livechat-chat-header {
        padding: 12px 16px;
        border-bottom: 1px solid #f1f5f9;
    }
    
    .livechat-chat-title h2 {
        font-size: 14px;
    }
    
    .livechat-connection-text {
        font-size: 12px;
    }
    
    .livechat-close-btn {
        width: auto;
        min-width: 28px;
        height: 28px;
        padding: 0 10px;
        font-size: 12px;
        border-radius: 5px;
    }
    
    .livechat-messages-wrapper {
        padding: 16px;
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    .livechat-message-wrapper {
        max-width: 88%;
        gap: 8px;
    }
    
    .livechat-message-avatar {
        width: 26px;
        height: 26px;
        font-size: 10px;
    }
    
    .livechat-message-bubble {
        padding: 8px 12px;
        border-radius: 5px;
    }
    
    .livechat-message-text {
        font-size: 13px;
        line-height: 1.4;
    }
    
    .livechat-message-time {
        font-size: 10px;
    }
    
    .livechat-input-section {
        padding: 10px 14px;
        border-top: 1px solid #f1f5f9;
        width: 100%;
    }
    
    .livechat-closed-notice {
        padding: 20px 16px;
        gap: 12px;
        margin: 10px;
    }
    
    .livechat-closed-icon {
        width: 40px;
        height: 40px;
        font-size: 16px;
        border-radius: 5px;
    }
    
    .livechat-closed-message h3 {
        font-size: 15px;
    }
    
    .livechat-closed-message p {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .livechat-page-wrapper,
    .wp-livechat-page-wrapper {
        padding: 8px 12px !important;
        overflow-x: hidden !important;
    }
    
    .livechat-container,
    .wp-livechat-container-wrapper {
        height: auto;
        min-height: 450px;
        border-radius: 5px;
        box-shadow: 0 1px 12px rgba(0, 0, 0, 0.06);
    }
    
    /* Full content info panel on small mobile phones */
    .livechat-info-panel,
    aside.livechat-info-panel {
        height: auto !important;
        min-height: auto !important;
        max-height: none !important;
        border-radius: 5px 5px 0 0;
        overflow: visible !important;
        width: 100% !important;
        display: block !important;
        border-right: none !important;
    }
    
    .livechat-layout {
        flex-direction: column !important;
        display: flex !important;
        height: 100%;
    }
    
    .livechat-chat-panel,
    main.livechat-chat-panel {
        flex: 1;
        display: flex !important;
        flex-direction: column;
        width: 100%;
        min-height: 0;
    }
    
    .livechat-info-content {
        padding: 8px;
        padding-bottom: 16px;
        gap: 8px;
        overflow: visible;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        height: auto;
        min-height: auto;
    }
    
    .livechat-info-content::-webkit-scrollbar {
        display: none;
    }
    
    .livechat-info-section {
        width: 100%;
        max-width: none;
        word-wrap: break-word;
        overflow-wrap: break-word;
        margin-bottom: 8px;
        flex-shrink: 0;
    }
    
    .livechat-info-section:last-child {
        margin-bottom: 0;
    }
    
    .livechat-info-section h3 {
        font-size: 12px;
        margin-bottom: 4px;
        white-space: normal;
        word-wrap: break-word;
        line-height: 1.2;
    }
    
    .livechat-info-list {
        white-space: normal;
        margin: 0;
        padding: 0;
    }
    
    .livechat-info-list li {
        font-size: 11px;
        margin-bottom: 6px;
        line-height: 1.3;
        white-space: normal;
        word-break: break-word;
        display: flex;
        align-items: flex-start;
        gap: 5px;
    }
    
    .livechat-info-item {
        font-size: 11px;
        margin-bottom: 3px;
        white-space: normal;
        word-wrap: break-word;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
    }
    
    .livechat-info-label,
    .livechat-info-value {
        white-space: normal;
        word-break: break-word;
        line-height: 1.2;
        font-size: 10px;
    }
    
    .livechat-info-value {
        text-align: right;
        flex-shrink: 0;
        margin-left: 5px;
    }
    
    .livechat-info-header {
        width: 100%;
        max-width: none;
        margin-bottom: 0;
        padding-bottom: 8px;
        border-bottom: 1px solid #d1d5db;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
        gap: 5px;
    }
    
    .livechat-header-row {
        display: flex;
        align-items: flex-start;
        gap: 8px;
        width: 100%;
    }
    
    .livechat-info-icon {
        width: 36px;
        height: 36px;
        font-size: 10px;
        border-radius: 5px;
        background: transparent;
    }
    
    .livechat-info-title h1 {
        font-size: 13px;
        line-height: 1.1;
        margin: 0 0 1px 0;
        padding: 0;
    }
    
    .livechat-info-title p {
        font-size: 10px;
        line-height: 1.2;
        margin: 0;
        padding: 0;
    }
    
    .livechat-header-subtitle p {
        font-size: 11px;
        line-height: 1.2;
        margin: 0;
    }
    
    .livechat-info-title h1,
    .livechat-info-title p {
        white-space: normal;
        word-wrap: break-word;
        line-height: 1.2;
    }
    
    /* Privacy notice for 480px breakpoint */
    .livechat-privacy-notice {
        width: 100%;
        max-width: none;
        padding: 8px;
        background: #f8fafc;
        border-radius: 5px;
        border: 1px solid #d1d5db;
    }
    
    .livechat-privacy-notice h3 {
        white-space: normal;
        word-wrap: break-word;
        font-size: 11px;
        margin-bottom: 4px;
    }
    
    .livechat-privacy-notice p {
        white-space: normal;
        word-wrap: break-word;
        line-height: 1.3;
        font-size: 10px;
        margin: 0;
    }
    
    .livechat-chat-header {
        padding: 10px 12px;
        border-bottom: 1px solid #f8fafc;
    }
    
    .livechat-chat-title {
        gap: 2px;
    }
    
    .livechat-chat-title h2 {
        font-size: 13px;
    }
    
    .livechat-connection-text {
        font-size: 11px;
    }
    
    .livechat-connection-dot {
        width: 6px;
        height: 6px;
    }
    
    .livechat-close-btn {
        width: auto;
        min-width: 26px;
        height: 26px;
        padding: 0 8px;
        font-size: 11px;
        border-radius: 5px;
    }
    
    .livechat-messages-wrapper {
        padding: 12px;
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    .livechat-message-wrapper {
        max-width: 92%;
        gap: 6px;
    }
    
    .livechat-message-avatar {
        width: 24px;
        height: 24px;
        font-size: 9px;
    }
    
    .livechat-message-bubble {
        padding: 8px 10px;
        border-radius: 5px;
    }
    
    .livechat-message-text {
        font-size: 12px;
        line-height: 1.3;
    }
    
    .livechat-message-time {
        font-size: 9px;
    }
    
    .livechat-message-sender {
        font-size: 10px;
        margin-bottom: 2px;
    }
    
    .livechat-input-section {
        padding: 8px 10px;
        border-top: 1px solid #f8fafc;
        width: 100%;
    }
    
    .livechat-input {
        font-size: 12px;
        padding: 8px 12px;
        border-radius: 3px;
    }
    
    .livechat-attach-btn,
    .livechat-send-btn {
        width: 28px;
        height: 28px;
        font-size: 11px;
        border-radius: 3px;
    }
    
    .livechat-closed-notice {
        padding: 16px 12px;
        gap: 10px;
        margin: 8px;
    }
    
    .livechat-closed-icon {
        width: 36px;
        height: 36px;
        font-size: 14px;
        border-radius: 5px;
    }
    
    .livechat-closed-message h3 {
        font-size: 14px;
    }
    
    .livechat-closed-message p {
        font-size: 12px;
    }
    
    /* Ultra-compact typography */
    .livechat-typing-text {
        font-size: 11px;
    }
    
    .livechat-system-message {
        font-size: 11px;
    }
    
    /* Mobile-specific enhancements */
    .livechat-input-form {
        display: flex;
        gap: 4px;
        align-items: flex-end;
        width: 100%;
    }
    
    .livechat-input-wrapper {
        flex: 1;
        position: relative;
        width: 100%;
    }
    
    /* Smooth transitions for mobile */
    .livechat-message-bubble,
    .livechat-close-btn,
    .livechat-attach-btn,
    .livechat-send-btn {
        transition: all 0.2s ease;
    }
    
    /* Touch-friendly buttons */
    .livechat-close-btn:active,
    .livechat-attach-btn:active,
    .livechat-send-btn:active {
        transform: scale(0.95);
    }
}

/* Add modern mobile optimizations */
@media (max-width: 1024px) {
    /* Smooth scrolling for mobile */
    .livechat-messages-wrapper,
    .livechat-info-content {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
    
    /* Prevent zoom on input focus */
    .livechat-input,
    input[type="text"],
    textarea {
        font-size: 16px !important;
        transform-origin: left top;
        transition: none;
    }
    
    /* Mobile-first animations */
    .livechat-message {
        animation: slideInMessage 0.3s ease-out;
    }
    
    @keyframes slideInMessage {
        from {
            opacity: 0;
            transform: translateY(10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    /* Compact status indicators */
    .livechat-connection-status {
        gap: 4px;
    }
    
    /* Optimized info panel scrolling */
    .livechat-info-content {
        scroll-snap-type: x mandatory;
    }
    
    .livechat-info-section,
    .livechat-info-header {
        scroll-snap-align: start;
    }
}

/* =============================================
   WCAG 2.2 Compliance
   ============================================= */

/* Focus-visible for all interactive elements */
.livechat-container button:focus-visible,
.livechat-container input:focus-visible,
.livechat-container textarea:focus-visible,
.livechat-container a:focus-visible,
.livechat-container select:focus-visible {
    outline: 3px solid #2563eb;
    outline-offset: 2px;
    box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.2);
}

/* Remove outline for mouse users */
.livechat-container button:focus:not(:focus-visible),
.livechat-container input:focus:not(:focus-visible),
.livechat-container textarea:focus:not(:focus-visible),
.livechat-container a:focus:not(:focus-visible) {
    outline: none;
    box-shadow: none;
}

/* Minimum touch target 44px */
.livechat-container button,
.livechat-container [role="button"] {
    min-width: 44px;
    min-height: 44px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .livechat-container,
    .livechat-container * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* High contrast mode */
@media (forced-colors: active) {
    .livechat-container input,
    .livechat-container textarea,
    .livechat-container button {
        border: 2px solid ButtonText;
    }
    .livechat-message-bubble {
        border: 1px solid CanvasText;
    }
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* =============================================
   SAVED REPLIES DROPDOWN
   ============================================= */
.livechat-saved-replies-container { position: relative; display: inline-block; }

.livechat-saved-replies-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 320px;
    max-height: 350px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 100;
    display: flex;
    flex-direction: column;
    margin-bottom: 8px;
}

.livechat-reply-search {
    padding: 10px 12px;
    border: none;
    border-bottom: 1px solid #e5e7eb;
    font-size: 13px;
    outline: none;
    border-radius: 8px 8px 0 0;
}
.livechat-reply-search:focus { box-shadow: inset 0 -2px 0 #2563eb; }

.livechat-reply-list { overflow-y: auto; max-height: 280px; padding: 4px; }

.livechat-reply-category {
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b7280;
    background: #f9fafb;
}

.livechat-reply-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    border-radius: 4px;
    transition: background 0.1s;
}
.livechat-reply-item:hover { background: #eff6ff; }
.livechat-reply-item:focus-visible { outline: 2px solid #2563eb; outline-offset: -2px; }
.livechat-reply-item strong { display: block; color: #1f2937; }
.livechat-reply-shortcut { font-size: 11px; color: #1e40af; margin-left: 6px; }
.livechat-reply-preview { font-size: 12px; color: #6b7280; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.livechat-reply-empty { padding: 20px; text-align: center; color: #6b7280; font-size: 13px; }

/* =============================================
   COLLISION DETECTION BAR
   ============================================= */
.livechat-collision-bar {
    padding: 8px 14px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    font-size: 13px;
    color: #1e40af;
    margin: 0 16px 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: fadeIn 0.2s ease;
}
.livechat-collision-bar.warning {
    background: #fef3c7;
    border-color: #fde68a;
    color: #92400e;
}
.collision-icon { font-size: 16px; flex-shrink: 0; }

/* =============================================
   VISITOR HISTORY (in dashboard modal)
   ============================================= */
.livechat-visitor-history { margin-top: 15px; }
.livechat-visitor-history h4 { margin: 0 0 10px; font-size: 14px; color: #374151; }

.livechat-page-visit {
    display: flex;
    gap: 10px;
    padding: 6px 0;
    border-left: 2px solid #e5e7eb;
    padding-left: 12px;
    margin-left: 6px;
    font-size: 13px;
}
.livechat-page-visit:first-child { border-left-color: #10b981; }
.livechat-page-visit .visit-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d1d5db;
    margin-top: 5px;
    flex-shrink: 0;
    margin-left: -17px;
}
.livechat-page-visit:first-child .visit-dot { background: #10b981; }
.livechat-page-visit .visit-title { font-weight: 500; color: #1f2937; }
.livechat-page-visit .visit-url { color: #6b7280; font-size: 12px; word-break: break-all; }
.livechat-page-visit .visit-time { color: #9ca3af; font-size: 11px; white-space: nowrap; }

/* Active agents indicators */
.livechat-active-agents { display: flex; gap: -4px; }
.livechat-agent-badge {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    background: #2563eb;
    border: 2px solid #fff;
    margin-left: -4px;
}
.livechat-agent-badge:first-child { margin-left: 0; }
.livechat-agent-badge.typing { background: #f59e0b; }

/* Links inside message bubbles (file shares): default link blue on the navy
   bubble was 1.70:1 — white underlined is 16:1 */
.livechat-message-text a,
.livechat-message-text a:visited {
    color: #ffffff;
    text-decoration: underline;
}
.livechat-message-text a:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

/* Inline post-close actions (replaced the timed confirm() dialogs) */
.livechat-closed-actions {
    display: flex;
    justify-content: center;
    padding: 16px;
}
.livechat-return-link {
    display: inline-block;
    /* #1e40af on white = 8.7:1 — clears WCAG AAA (7:1) for this 14px text.
       !important guards against the site theme's aggressive link/button styles
       (it ships a generic button/anchor :hover that would otherwise force white
       text onto a light/themed background). */
    background: #1e40af !important;
    color: #ffffff !important;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    padding: 10px 20px;
    border-radius: 8px;
    min-height: 44px;
    line-height: 24px;
    box-sizing: border-box;
}
.livechat-return-link:hover,
.livechat-return-link:focus { background: #1e3a8a !important; color: #ffffff !important; }
.livechat-return-link:focus-visible { outline: 3px solid #1e40af; outline-offset: 2px; }

/* --- Inline SVG icons (replaced the Font Awesome CDN) --- */
.lc-icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
    flex-shrink: 0;
}
.lc-icon-spinner { animation: lc-spin 0.8s linear infinite; }
@keyframes lc-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .lc-icon-spinner { animation: none; } }

/* Minimal utility classes the templates use (previously from Bootstrap) */
.d-none { display: none !important; }
.alert { padding: 12px 16px; border-radius: 6px; margin: 10px 0; }
.alert-danger { background: #fcf0f1; color: #8a1f24; border: 1px solid #f0c4c7; }

/* ============================================================
   AGENT / ADMIN VIEW
   Clean, minimal, distraction-free chat for the agent. The visitor-facing
   rules/marketing panel is replaced by a compact customer card; the chat
   takes visual priority and the layout collapses to full-width on small
   screens (the customer name stays visible in the header).
   ============================================================ */
.livechat-agent-view .livechat-page-wrapper,
.livechat-agent-view.livechat-page-wrapper {
    background: #f1f5f9;
}

/* Centered, calmer container — not stretched edge-to-edge on large monitors */
.livechat-agent-view .livechat-container {
    max-width: 1200px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Compact customer sidebar */
.livechat-agent-view .livechat-info-panel,
.livechat-agent-view aside.livechat-info-panel {
    width: 300px;
    background: #ffffff;
    border-right: 1px solid #e5e7eb;
}
.livechat-agent-view .livechat-info-content {
    padding: 24px 20px;
}
.livechat-agent-view .livechat-info-header {
    margin-bottom: 4px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f1f5f9;
}
.livechat-agent-view .livechat-info-title h1 {
    font-size: 18px;
    line-height: 1.2;
}
.livechat-agent-view .livechat-info-title p {
    font-size: 13px;
    color: #64748b;
    font-weight: 400;
    margin-top: 2px;
}
.livechat-agent-view .livechat-info-section {
    border: 0;
    padding: 0;
    margin-top: 16px;
}
.livechat-agent-view .livechat-info-item {
    padding: 10px 0;
    border-bottom: 1px solid #f1f5f9;
}
.livechat-agent-view .livechat-info-item:last-child {
    border-bottom: 0;
}
.livechat-agent-view .livechat-info-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b; /* WCAG AA: 4.9:1 on white */
    margin-bottom: 2px;
}
.livechat-agent-view .livechat-info-value {
    font-size: 14px;
    color: #1e293b;
    word-break: break-word;
}
.livechat-agent-view .livechat-info-value a {
    color: #1e40af;
}

/* Cleaner, quieter chat header */
.livechat-agent-view .livechat-chat-header {
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
}

/* Agent view: the customer's incoming messages get a light bubble so they read
   as distinct from the agent's own (navy) replies — easy to scan at a glance.
   Scoped to agent view only; the visitor experience is unchanged. */
.livechat-agent-view .livechat-message-received .livechat-message-bubble {
    background: #f1f5f9;
    border-color: #e2e8f0;
}
.livechat-agent-view .livechat-message-received .livechat-message-bubble::before {
    border-right-color: #f1f5f9;
}
.livechat-agent-view .livechat-message-received .livechat-message-text {
    color: #1e293b; /* 13:1 on #f1f5f9 */
}
.livechat-agent-view .livechat-message-received .livechat-message-time {
    color: #5b6677; /* AA on #f1f5f9 */
}

/* On tablet/mobile the customer card is hidden so the agent gets the full
   width for the conversation; the customer name remains in the header. */
@media (max-width: 1024px) {
    .livechat-agent-view .livechat-info-panel,
    .livechat-agent-view aside.livechat-info-panel {
        display: none !important;
    }
    .livechat-agent-view .livechat-container {
        min-height: 100vh;
        border-radius: 0;
        border: 0;
    }
}


/* ============================================================
   INTRO CARD
   Text placed between [live_chat_interface] and [/live_chat_interface]
   (e.g. live chat hours) sits above the chat, centered at the same width
   as the chat container and in the same font.
   ============================================================ */
.livechat-page-wrapper.livechat-has-intro {
    flex-direction: column !important;
}
.livechat-intro-card {
    width: 100%;
    max-width: 1920px; /* matches .livechat-container */
    margin: 0 auto 20px;
    padding: 16px 24px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 5px;
    color: #1e3a8a; /* 9.5:1 on #eff6ff (AAA) */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    text-align: center;
    box-sizing: border-box;
}
.livechat-intro-card p {
    margin: 0 0 6px;
    color: inherit;
    font-size: inherit;
    line-height: inherit;
}
.livechat-intro-card p:last-child {
    margin-bottom: 0;
}
.livechat-intro-card a {
    color: #1e40af; /* 8.0:1 on #eff6ff (AAA) */
    text-decoration: underline;
}
.livechat-agent-view .livechat-intro-card {
    max-width: 1200px; /* matches the agent view container */
}
