/* =============================================
   CHAT SCREEN STYLES
   ============================================= */

.wa-chat-container {
    max-width: 100%;
    height: 100vh;
    min-height: 100vh;
    background: url('../images/chat-bg.png') repeat, var(--wa-chat-bg);
    background-size: 412.5px 749.25px;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
}

/* Chat Header */
.wa-chat-header {
    background-color: var(--wa-teal);
    color: var(--wa-white);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.wa-back-btn {
    background: transparent;
    border: none;
    color: var(--wa-white);
    padding: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wa-chat-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.wa-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-round);
    object-fit: cover;
    background-color: var(--wa-gray-medium);
}

.wa-chat-profile-info {
    flex: 1;
    min-width: 0;
}

.wa-chat-name {
    font-size: 16px;
    font-weight: 500;
    margin: 0;
    color: var(--wa-white);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wa-chat-status {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
    margin: 0;
}

.wa-chat-actions {
    display: flex;
    gap: 16px;
    align-items: center;
}

/* Chat Messages Area */
.wa-chat-messages {
    flex: 1;
    padding: 12px 8px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wa-chat-date {
    text-align: center;
    margin: 8px 0;
}

.wa-chat-date span {
    background-color: rgba(255, 255, 255, 0.9);
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-size: 12px;
    color: #54656f;
    box-shadow: var(--shadow-sm);
}

#wa-messages-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Message Bubble */
.wa-message {
    max-width: 75%;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
    animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wa-message-received {
    background-color: var(--wa-white);
    align-self: flex-start;
    border-radius: 0 var(--radius-md) var(--radius-md) var(--radius-md);
}

.wa-message-sent {
    background-color: var(--wa-green-light);
    align-self: flex-end;
    border-radius: var(--radius-md) 0 var(--radius-md) var(--radius-md);
}

.wa-message-text {
    font-size: 14px;
    line-height: 1.4;
    color: var(--wa-black);
    margin: 0;
}

.wa-message-time {
    font-size: 11px;
    color: var(--wa-gray-dark);
    margin-top: 4px;
    text-align: right;
    display: block;
}

/* Typing Indicator */
.wa-typing-indicator {
    max-width: 75%;
    align-self: flex-start;
}

.wa-typing-bubble {
    background-color: var(--wa-white);
    padding: 12px 16px;
    border-radius: 0 var(--radius-md) var(--radius-md) var(--radius-md);
    display: flex;
    gap: 4px;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
}

.wa-typing-bubble span {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-round);
    background-color: var(--wa-gray-dark);
    animation: typingDot 1.4s infinite;
}

.wa-typing-bubble span:nth-child(2) {
    animation-delay: 0.2s;
}

.wa-typing-bubble span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {

    0%,
    60%,
    100% {
        opacity: 0.3;
        transform: translateY(0);
    }

    30% {
        opacity: 1;
        transform: translateY(-4px);
    }
}

/* Chat Input */
.wa-chat-input-container {
    background-color: var(--wa-gray-light);
    padding: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    position: sticky;
    bottom: 0;
}

.wa-input-wrapper {
    flex: 1;
    background-color: var(--wa-white);
    border-radius: 21px;
    padding: 0 16px;
}

.wa-chat-input {
    width: 100%;
    border: none;
    outline: none;
    padding: 10px 0;
    font-size: 15px;
    background: transparent;
}

.wa-chat-input:disabled {
    color: var(--wa-gray-dark);
    cursor: not-allowed;
}

/* Ad Containers */
.wa-chat-ad-container,
.wa-bottom-ad-container {
    margin: 12px 8px;
}

/* Hide if empty */
.wa-chat-ad-container:empty,
.wa-bottom-ad-container:empty {
    display: none;
    margin: 0;
    padding: 0;
}

/* Hide if contains only text nodes (whitespace) - requires JS or specific structure, 
   but :empty works for truly empty. For simulated empty (comments only), we rely on PHP logic or structure.
*/

/* Ensure bottom ad doesn't break layout */
.wa-bottom-ad-container {
    /* If ad is present */
    flex-shrink: 0;
}

/* Incoming Call Popup */
.wa-call-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, var(--wa-teal), #054740);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: callPopupFade 0.3s ease-out;
}

@keyframes callPopupFade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.wa-call-popup-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 60px 20px 40px;
    color: var(--wa-white);
}

.wa-call-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    text-align: center;
}

.wa-call-avatar {
    width: 120px;
    height: 120px;
    border-radius: var(--radius-round);
    object-fit: cover;
    box-shadow: var(--shadow-lg);
    animation: callAvatarPulse 1.5s infinite;
}

@keyframes callAvatarPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

.wa-call-profile-name {
    font-size: 32px;
    font-weight: 400;
    margin: 0;
}

.wa-call-status {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
}

.wa-call-actions {
    display: flex;
    justify-content: center;
    gap: 80px;
    width: 100%;
}

.wa-call-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    background: transparent;
    border: none;
    color: var(--wa-white);
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.wa-call-btn:active {
    transform: scale(0.9);
}

.wa-call-btn svg {
    width: 64px;
    height: 64px;
    padding: 18px;
    border-radius: var(--radius-round);
}

.wa-call-reject svg {
    background-color: #E53935;
}

.wa-call-accept svg {
    background-color: var(--wa-green);
}

.wa-call-btn span {
    font-size: 16px;
}

/* Active Call Screen */
.wa-call-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, var(--wa-teal), #054740);
    z-index: 1000;
    animation: callPopupFade 0.3s ease-out;
}

.wa-call-screen-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 60px 20px 40px;
    color: var(--wa-white);
}

.wa-call-screen-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    text-align: center;
}

.wa-call-screen-avatar {
    width: 120px;
    height: 120px;
    border-radius: var(--radius-round);
    object-fit: cover;
    box-shadow: var(--shadow-lg);
}

.wa-call-screen-name {
    font-size: 32px;
    font-weight: 400;
    margin: 0;
}

.wa-call-screen-duration {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
    font-variant-numeric: tabular-nums;
}

.wa-call-ad-top {
    width: 100%;
    max-width: 400px;
    margin: 20px 0;
}

.wa-call-ad-container {
    width: 100%;
    margin: 12px 0;
    display: flex;
    justify-content: center;
}

.wa-call-screen-actions {
    display: flex;
    justify-content: center;
    gap: 32px;
    flex-wrap: wrap;
    width: 100%;
}

.wa-call-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    color: var(--wa-white);
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.wa-call-action-btn:active {
    transform: scale(0.9);
}

.wa-call-action-btn svg {
    width: 56px;
    height: 56px;
    padding: 16px;
    border-radius: var(--radius-round);
    background-color: rgba(255, 255, 255, 0.2);
}

.wa-call-end-btn svg {
    background-color: #E53935;
    width: 64px;
    height: 64px;
}

.wa-call-action-btn span {
    font-size: 14px;
}

/* Responsive Design */
@media (min-width: 768px) {
    .wa-chat-container {
        max-width: 600px;
        margin: 0 auto;
        box-shadow: var(--shadow-md);
    }

    .wa-message {
        max-width: 65%;
    }
}

@media (min-width: 1024px) {
    .wa-chat-container {
        max-width: 800px;
    }
}