
:root {
    --wa-teal: #008069;
    --wa-teal-dark: #075e54;
    --wa-teal-light: #128c7e;
    --wa-green: #25d366;
    --wa-bg-light: #efeae2;
    --wa-bg-dark: #0c1317;
    --wa-panel-dark: #111b21;
    --wa-panel-header: #202c33;
    --wa-outgoing-dark: #005c4b;
    --wa-incoming-dark: #202c33;
    --wa-text-primary: #e9edef;
    --wa-text-secondary: #8696a0;
    --wa-border: #222d34;
    --wa-blue-tick: #53bdeb;
    --wa-verified-blue: #1d9bf0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    background-color: #0c1317;
    color: #e9edef;
    height: 100%;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
    position: fixed;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
}

.chat-app-container {
    width: 100%;
    max-width: 520px;
    height: 100%;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: #0b141a;
    position: relative;
    box-shadow: 0 4px 25px rgba(0,0,0,0.6);
}

@media (min-width: 769px) {
    .chat-app-container {
        height: 94vh;
        border-radius: 14px;
        overflow: hidden;
        border: 1px solid #222d34;
    }
}

/* Header */
.chat-header {
    background-color: #202c33;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    min-height: 60px;
    flex-shrink: 0;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar-wrapper {
    position: relative;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
}

.avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    background: #2a3942;
    border: 1px solid rgba(255,255,255,0.1);
}

.status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #8696a0;
    border: 2px solid #202c33;
}

.status-dot.online {
    background: #25d366;
}

.header-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.agent-title {
    font-size: 15px;
    font-weight: 600;
    color: #e9edef;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.verified-badge {
    color: #1d9bf0;
    font-size: 13.5px;
}

.agent-status-text {
    font-size: 12px;
    color: #8696a0;
    transition: color 0.2s ease;
}

.agent-status-text.typing {
    color: #25d366;
    font-weight: 500;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #aebac1;
    font-size: 18px;
}

.btn-icon {
    background: none;
    border: none;
    color: #aebac1;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: 50%;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: rgba(255,255,255,0.1);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background-color: #0b141a;
    background-image: radial-gradient(rgba(255,255,255,0.03) 1px, transparent 0);
    background-size: 24px 24px;
    position: relative;
    -webkit-overflow-scrolling: touch;
}

.chat-messages::-webkit-scrollbar {
    width: 5px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 3px;
}

.date-divider {
    align-self: center;
    background: #182229;
    color: #8696a0;
    font-size: 11px;
    padding: 4px 12px;
    border-radius: 8px;
    margin: 4px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.security-badge {
    align-self: center;
    background: #182229;
    color: #ffd279;
    font-size: 11.5px;
    padding: 6px 14px;
    border-radius: 8px;
    margin: 2px 0 8px 0;
    text-align: center;
    max-width: 95%;
    line-height: 1.4;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* Message Bubbles */
.message-row {
    display: flex;
    width: 100%;
}

.message-row.outgoing {
    justify-content: flex-end;
}

.message-row.incoming {
    justify-content: flex-start;
}

.bubble {
    max-width: 86%;
    padding: 7px 10px 6px 11px;
    border-radius: 8px;
    font-size: 14.5px;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 1px 1px rgba(0,0,0,0.2);
}

.message-row.outgoing .bubble {
    background-color: #005c4b;
    color: #e9edef;
    border-top-right-radius: 2px;
}

.message-row.incoming .bubble {
    background-color: #202c33;
    color: #e9edef;
    border-top-left-radius: 2px;
}

.bubble-text {
    white-space: pre-wrap;
    word-break: break-word;
}

.bubble-meta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    float: right;
    margin-left: 8px;
    margin-top: 4px;
    font-size: 11px;
    color: #8696a0;
    user-select: none;
}

.tick-icon {
    font-size: 13px;
    line-height: 1;
}

.tick-icon.seen {
    color: #53bdeb;
}

/* Video Message Bubble */
.bubble-video-container {
    max-width: 280px;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    background: #000;
    margin-bottom: 4px;
}

.bubble-video {
    width: 100%;
    max-height: 280px;
    display: block;
    object-fit: contain;
    border-radius: 8px;
}

.video-upload-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #ffd279;
    font-size: 12px;
}

/* Image Message */
.bubble-image-container {
    max-width: 280px;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 4px;
    cursor: pointer;
    position: relative;
}

.bubble-image {
    width: 100%;
    max-height: 280px;
    object-fit: cover;
    display: block;
    transition: transform 0.2s;
}

.image-upload-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: #fff;
    font-size: 12px;
}

/* Voice Message */
.voice-bubble-content {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 200px;
    padding: 2px 0;
}

.voice-play-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #00a884;
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    cursor: pointer;
    flex-shrink: 0;
}

.voice-waveform-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.voice-slider {
    width: 100%;
    -webkit-appearance: none;
    background: rgba(255,255,255,0.2);
    height: 4px;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.voice-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #00a884;
    cursor: pointer;
}

.voice-time-text {
    font-size: 11px;
    color: #8696a0;
}

/* File Attachment */
.file-bubble-content {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0,0,0,0.15);
    padding: 8px 12px;
    border-radius: 6px;
    text-decoration: none;
    color: #e9edef;
}

.file-icon {
    font-size: 24px;
    color: #00a884;
}

.file-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.file-title {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

.file-size {
    font-size: 11px;
    color: #8696a0;
}

.upload-spinner-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #ffd279;
    padding: 4px 0;
}

.wa-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top-color: #25d366;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Input Bar */
.chat-input-bar {
    background-color: #202c33;
    padding: 8px 10px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    z-index: 10;
    flex-shrink: 0;
}

.input-box-wrapper {
    flex: 1;
    background-color: #2a3942;
    border-radius: 24px;
    display: flex;
    align-items: center;
    padding: 6px 14px;
    gap: 8px;
}

.chat-textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #d1d7db;
    font-size: 15px;
    resize: none;
    max-height: 90px;
    line-height: 1.4;
}

.chat-textarea::placeholder {
    color: #8696a0;
}

.action-btn-circle {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background-color: #00a884;
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    cursor: pointer;
    transition: transform 0.15s;
    flex-shrink: 0;
}

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

.action-btn-circle.recording {
    background-color: #ea4335;
    animation: pulseMic 1.2s infinite;
}

@keyframes pulseMic {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); box-shadow: 0 0 12px rgba(234,67,53,0.6); }
    100% { transform: scale(1); }
}

.recording-bar {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    background: #202c33;
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    z-index: 20;
}

.recording-bar.active {
    display: flex;
}

.recording-timer {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #ea4335;
    font-weight: 600;
    font-size: 14px;
}

.rec-pulse-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ea4335;
    animation: blinkDot 1s infinite;
}

@keyframes blinkDot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}

.rec-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-cancel-rec {
    background: none;
    border: none;
    color: #8696a0;
    cursor: pointer;
    font-size: 13.5px;
    padding: 6px 8px;
}

/* Lightbox */
.lightbox-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.92);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.lightbox-modal.active {
    display: flex;
}

.lightbox-modal img, .lightbox-modal video {
    max-width: 95%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 6px;
}

.lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
}
