﻿@import url('styles.css');

:root {
    --wa-teal: #008069;
    --wa-light-teal: #00a884;
    --bg-gray: #d1d7db;
    --white: #ffffff;
    --sidebar-header: #f0f2f5;
    --chat-bg: #efeae2;
    --message-out: #d9fdd3;
    --message-in: #ffffff;
    --border-light: #e9edef;
    --text-primary: #111b21;
    --text-secondary: #667781;
    --icon-gray: #54656f;
    --system-green: #25d366;
    --panel-header-height: 108px;
    --bg: #ffffff;
    --s1: #e6eef0; /* base shimmer colors */
    --s2: #f5f7f8;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-gray);
    background: linear-gradient(180deg, #00a884 127px, var(--bg-gray) 127px);
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.no-select {
    user-select: none;
    -webkit-user-select: none; /* Safari */
    -ms-user-select: none; /* Old Edge */
}
.allow-select {
    user-select: text;
    -webkit-user-select: text; /* Safari */
    -ms-user-select: text; /* Old Edge */
}

.app-container {
    width: 100%;
    height: 100%;
    max-width: 1600px;
    background-color: var(--white);
    display: flex;
    box-shadow: 0 17px 50px 0 rgba(11,20,26,.19), 0 12px 15px 0 rgba(11,20,26,.24);
    overflow: hidden;
    position: relative;
}

@media (min-width: 1441px) {
    .app-container {
        height: calc(100vh - 38px);
        width: calc(100vw - 38px);
    }
}

/* --- Left Sidebar & Panels --- */
.sidebar-container {
    width: 30%;
    min-width: 320px;
    max-width: 450px;
    height: 100%;
    position: relative;
    border-right: 1px solid var(--border-light);
    overflow: hidden;
}

.sidebar {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--white);
    transition: transform 0.3s ease-in-out;
}

/* New Chat Panel (Slides in) */
.side-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
}

    .side-panel.open {
        transform: translateX(0);
    }

.panel-header {
    height: var(--panel-header-height);
    background-color: var(--wa-teal);
    color: white;
    display: flex;
    align-items: flex-end;
    padding: 0 20px 20px 20px;
}

.panel-header-content {
    display: flex;
    align-items: center;
    gap: 25px;
    width: 100%;
}

.panel-title {
    font-size: 19px;
    font-weight: 500;
}

/* Header (Standard) */
.header {
    height: 60px;
    background-color: var(--sidebar-header);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    flex-shrink: 0;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #ddd;
    overflow: hidden;
    cursor: pointer;
}

    .user-avatar img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

.header-icons {
    display: flex;
    gap: 20px;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--icon-gray);
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

    .icon-btn:active {
        background-color: rgba(0,0,0,0.1);
    }

.panel-header .icon-btn {
    color: white;
}

/* Search Bar */
.search-container {
    background-color: var(--white);
    padding: 7px 12px;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

.search-bar {
    background-color: #f0f2f5;
    border-radius: 8px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    height: 35px;
}

    .search-bar input {
        border: none;
        background: none;
        outline: none;
        width: 100%;
        margin-left: 20px;
        font-size: 14px;
        color: var(--text-primary);
    }

/* Lists */
.list-container {
    flex: 1;
    overflow-y: auto;
    background-color: var(--white);
}

.list-section-title {
    padding: 30px 20px 15px 30px;
    color: var(--wa-teal);
    font-size: 16px;
    text-transform: uppercase;
}

.contact-item {
    display: flex;
    align-items: center;
    padding: 0 15px;
    height: 72px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    transition: background-color 0.2s;
}

    .contact-item:hover {
        background-color: #f5f6f6;
    }

    .contact-item.active {
        background-color: #f0f2f5;
    }

.contact-info {
    flex: 1;
    margin-left: 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-bottom: 1px solid transparent;
}

.unread-counter {
    position: absolute;
    right: 1rem;
    background-color: #21C063;
    color: black;
    padding: 0 8px 3px 8px;
    border-radius: 50%;
}

.contact-top {
    display: flex;
    justify-content: space-between;
    margin-bottom: 3px;
}

.contact-name {
    font-size: 17px;
    color: var(--text-primary);
}

.contact-time {
    font-size: 12px;
    color: var(--text-secondary);
}

.contact-preview {
    display: flex;
    align-content: center;
    justify-content: left;
    font-size: 16px;
    color: var(--text-secondary);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    max-width: 350px;
}

/* --- Right Chat Area --- */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #efeae2;
    position: relative;
}

.chat-header {
    z-index: 10;
}

.chat-header-info {
    display: flex;
    flex-direction: column;
    margin-left: 15px;
}

.chat-name {
    font-size: 16px;
    color: var(--text-primary);
    font-weight: 500;
}

.last-seen {
    font-size: 12px;
    color: var(--text-secondary);
}

.messages-container {
    flex: 1;
    padding: 50px 5%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    z-index: 1;
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
    background-blend-mode: overlay;
    padding-bottom: 70px;
}

.messages-container {
    & > *:first-child {
        margin-top: auto;
    }
}
.chat-area:has(.chat-footer .reply-footer.open) .messages-container {
    padding-bottom: 130px;
}
.chat-area:has(.chat-footer .reply-footer.close) .messages-container {
/*    transition: padding-bottom 300ms ease;*/
}

    .message-row {
        display: flex;
        justify-content: flex-start;
        margin-bottom: 4px;
        gap: 5px;
        align-items: center;

        &:has(.message-reactions:not([hidden])) {
            margin-bottom: 30px;
        }
    }

        .message-row.sent {
            flex-direction: row-reverse;
        }

        .message-row.received .message-reactions {
            left: 7px;
        }

        .message-row.sent .message-reactions {
            right: 7px;
        }

    .message-bubble {
        max-width: 65%;
        padding: 6px 7px 8px 9px;
        border-radius: 7.5px;
        font-size: 14.2px;
        line-height: 19px;
        box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        color: black;
        position: relative;
    }

    .message-reactions {
        bottom: -20px;
        position: absolute;
        background-color: darkslategray;
        border-radius: 20px;
        padding: 2px 6px;
        color: #d6d2d2;
    }
    /*emoji-container*/
    .emoji-host {
        position: relative;
        display: flex;
        width: 20px;
        height: 20px;
    }

    .show-emoji-container {
        display: none;
        align-content: center;

        & svg {
            stroke: darkslategray;
            stroke-width: .3px;
            transform: translateY(3px);

            & path {
                fill: darkslategray;
            }
        }

        &:hover {
            cursor: pointer;
        }
    }

    .emoji-container {
        position: absolute;
        background-color: darkslategrey;
        box-shadow: 0px 0px 6px rgba(0, 0, 0, 0.5);
        width: fit-content;
        height: 40px;
        gap: 9px;
        border-radius: 32px;
        justify-content: center;
        align-items: center;
        text-align: center;
        top: -44px;
        left: -75px;
        font-size: 18px;
        display: flex;
        transform-origin: center;
        transition: 0.3s;
        padding: 10px 10px;

        & .emoji-item {
            text-shadow: 0px 0px 6px rgba(0,0,0,0.5);
            display: inline-block;
            opacity: 0; /* Hidden by default until animation runs */
            transform: scale(0);
            transform-origin: center;
            margin-bottom: 3px;
        }

        &.emojis-visible {
            /* visible state start */
            max-width: 300px;
            max-height: 100px;
            /* visible state end */
            animation: popUp 0.3s ease-in-out forwards;

            & .emoji-item {
                /* simplified stagger logic */
                --delay: calc(var(--index) * 0.05s + 0.1s);
                /* Snappy pop-in for items */
                animation: itemPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
                animation-delay: var(--delay);

                &:hover, &.selected {
                    transition-duration: 300ms;
                    scale: 1.8;
                    cursor: pointer;
                }
            }
        }

        &.closed {
            animation: popUp 0.3s ease-in-out reverse;
            /* hidden state start */
            padding: 0;
            max-width: 0px;
            scale: 0.9;
            transform-origin: left;
        }
    }

    @keyframes popUp {
        0% {
            opacity: 0;
            transform: scale(1);
        }

        50% {
            opacity: 0.7;
        }

        100% {
            opacity: 1;
            transform: scale(1);
        }
    }

    @keyframes expandEmoji {
        0% {
            opacity: 0;
            max-width: 0;
            transform: scale(1);
        }

        50% {
            transform: scale(1.15);
        }

        100% {
            opacity: 1;
            max-width: 25px;
            transform: scale(1);
        }
    }

    @keyframes itemPop {
        0% {
            opacity: 0;
            transform: scale(0) translateY(10px);
        }

        100% {
            opacity: 1;
            transform: scale(1) translateY(0);
        }
    }


    .sent .message-bubble {
        background-color: var(--message-out);
        border-top-right-radius: 0;
    }

    .received .message-bubble {
        background-color: var(--message-in);
        border-top-left-radius: 0;
    }

    .message-image {
        width: 100%;
        max-width: 330px;
        border-radius: 6px;
        margin-bottom: 2px;
        display: block;
    }

    .message-meta {
        float: right;
        margin-left: 7px;
        margin-top: 4px;
        display: flex;
        align-items: center;
        gap: 3px;
        font-size: 11px;
        color: var(--text-secondary);
    }

.chat-footer {
    min-height: fit-content;
    background-color: var(--sidebar-header);
    padding: 7px 7px;
    flex-wrap: wrap;
    column-gap: 10px;
    z-index: 10;
    border-radius: 1.7rem;
    position: absolute;
    bottom: 10px;
    width: 96%;
    align-self: center;
    margin-right: 1%;

    & .reply-footer {
        width: 100%;
        margin-bottom: 10px;
        overflow: hidden;

        &.open {
            animation: slideUp 1000ms ease-out forwards;
        }

        &.close {
            animation: slideDown 500ms ease-out forwards;
            padding: 0;
            margin: 0;

            & .reply-close-btn {
                display: none;
            }
        }
    }

    &:has(.reply-footer.open) {
        border-radius: .5rem .5rem 1.7rem 1.7rem;
    }

    &:has(.reply-footer.close) {
        transition: border-radius 300ms ease;
        transition-delay: 200ms;
    }

    & .reply-close-btn {
        margin: 2px 0px;
        display: block;
        position: absolute;
        height: 40px;
        right: 8px;
    }


    & .reply-container {
        margin-bottom: 0 !important;
        padding-bottom: 0 !important;
    }

    & .reply-content {
        max-width: 90%;
    }
}

    @keyframes slideUp {
        from {
            max-height: 0px;
        }

        to {
            max-height: 200px;
        }
    }

    @keyframes slideDown {
        from {
            max-height: 200px;
            margin-bottom: 10px;
        }

        to {
            max-height: 0px;
            margin-bottom: 0px;
        }
    }

    .input-box {
        flex: 1;
        background-color: var(--white);
        border-radius: 8px;
        padding: 9px 12px;
        max-height: 100px;
        overflow-y: auto;
        font-size: 15px;
        outline: none;
        border: none;
    }

    .welcome-screen {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        height: 100%;
        background-color: #f8f9fa;
        border-bottom: 6px solid #25d366;
        text-align: center;
        position: absolute;
        width: 100%;
        z-index: 50;
    }

        .welcome-screen h1 {
            color: #41525d;
            font-weight: 300;
            margin-top: 28px;
        }
    /* SVG Icons */
    svg {
        stroke: currentColor;
        fill: none;
        stroke-width: 0.5px;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .filled-icon {
        fill: currentColor;
        stroke: none;
    }
    /* Action Items (New Group, New Community, New Contact) */
    .action-item {
        display: flex;
        align-items: center;
        padding: 0 15px;
        height: 60px;
        cursor: pointer;
        background-color: white;
    }

        .action-item:hover {
            background-color: #f5f6f6;
        }

    .action-icon {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        background-color: var(--wa-teal);
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;
        margin-right: 15px;
    }

    .action-text {
        font-size: 16px;
        color: var(--text-primary);
    }
    /* Contact Items */
    .contact-item {
        display: flex;
        align-items: center;
        padding: 0 15px;
        height: 72px;
        cursor: pointer;
        border-bottom: 1px solid var(--border-light);
    }
    /* Forms in New Contact */
    .panel-content {
        flex: 1;
        overflow-y: auto;
        background: white;
    }

    .form-group {
        padding: 20px 30px;
    }

    .input-wrapper {
        position: relative;
        margin-bottom: 30px;
    }

        .input-wrapper label {
            display: block;
            color: var(--wa-teal);
            font-size: 14px;
            margin-bottom: 8px;
        }

        .input-wrapper input {
            width: 100%;
            border: none;
            border-bottom: 1px solid var(--border-light);
            padding: 8px 0;
            font-size: 16px;
            outline: none;
            transition: border-color 0.2s;
        }

            .input-wrapper input:focus {
                border-bottom: 2px solid var(--wa-teal);
            }

    .done-btn-container {
        padding: 20px 0;
        display: flex;
        justify-content: center;
    }

    .done-btn {
        background-color: var(--wa-teal);
        color: white;
        border: none;
        padding: 15px 17px;
        border-radius: 50%;
        cursor: pointer;
    }

        .done-btn:hover {
            background-color: var(--wa-light-teal);
        }
    /* Alphabetical Divider Styling */
    .letter-header {
        padding: 30px 20px 15px 30px;
        color: var(--wa-teal);
        font-size: 14px;
        font-weight: 500;
        background: white;
        text-transform: uppercase;
    }
    /* base size + alignment */
    .tick {
        width: 18px;
        height: 18px;
        display: inline-block;
        vertical-align: middle;
        color: #9AA7B2;
        default gray tick (delivered) transition: color 160ms ease, filter 160ms ease;
    }
    /* tiny soft drop shadow so it pops on light backgrounds */
    .message-status svg {
        display: block;
        filter: drop-shadow(0 0 0.6px rgba(0,0,0,0.12));
    }

    :not(svg) {
        transform-origin: 0px 0px;
    }
    /* states */
    .sent {
        color: #9AA7B2;
        fill: currentColor;
    }

    .delivered {
        color: #9AA7B2;
    }

    .read {
        color: #34B7F1;
    }

    .default {
        color: #9AA7B2;
    }

    .error {
        color: #ef4444;
    }

    .message-status {
        display: inline-flex; /* centers the svg content and keeps it inline with text */
        align-items: center;
        justify-content: center;
        line-height: 0; /* avoid extra inline whitespace issues */
        flex: 0 0 auto;
        vertical-align: middle; /* extra safety for baseline alignment */
        transform: translateY(1px);
        padding-right: 2px;
    }

    .reply-container {
        display: flex;
        flex-direction: row;
        background-color: #d4d2d282;
        border-radius: 5px;
        margin-bottom: 4px;
        --directionColor: #006be0;

        &:hover {
            cursor: pointer;
        }

        &.received {
            --directionColor: #006be0;
        }

        &.sent {
            --directionColor: #029a02;
        }

        & .side-color {
            background-color: var(--directionColor);
            padding: 2px;
            border-radius: 5px 0 0 5px;
        }

        & .reply-body {
            padding: 5px;
            font-size: 12px;
            width: 100%;

            & .reply-from {
                color: var(--directionColor);
                font-weight: 500;
            }

            & .reply-content {
                color: darkslategray;
            }
        }
    }

    @keyframes flash {
        0% {
            background-color: rgba(255, 255, 0, 0.6);
        }

        100% {
            background-color: transparent;
        }
    }

    .flash {
        animation: flash 1.2s ease-out;
    }





.loading-skeleton {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0 12px;

    & * {
        background: linear-gradient( 90deg, #e5e7eb 25%, #f3f4f6 37%, #e5e7eb 63% );
        background-size: 400% 100%;
        animation: shimmer 1.4s ease infinite;
    }

    & .msg {
        height: 14px;
        border-radius: 10px;
        width: 50%;

        &.incoming {
            align-self: flex-start;
        }
        &.outgoing {
            align-self: flex-end;
        }

        &.medium {
            width: 35%;
        }

        &.short {
            width: 25%;
        }
    }

    & .contact {
        display: flex;
        gap: 12px;
        align-items: center;
        padding: 8px 6px;
        min-height: 64px;
        background: none;

        & .avatar {
            width: 48px;
            height: 48px;
            border-radius: 50%;
            flex: 0 0 48px;
        }

        & .meta {
            flex: 1 1 auto;
            display: flex;
            background: none;
            flex-direction: column;
            gap: 6px;

            & .row {
                display: flex;
                align-items: center;
                justify-content: space-between;
                gap: 8px;
                background:none ;

                & .name {
                    height: 14px;
                    width: 45%;
                    border-radius: 6px;
                    &.long {
                        width: 65%;
                    }
                }

                & .message {
                    height: 12px;
                    width: 60%;
                    border-radius: 6px;
                    &.short {
                        width: 40%;
                    }
                }

                & .time {
                    height: 10px;
                    width: 18%;
                    border-radius: 6px;
                    &.short {
                        width: 12%;
                    }
                }

                & .badge {
                    height: 18px;
                    min-width: 18px;
                    border-radius: 12px;
                    &.small {
                        height: 12px;
                        min-width: 12px;
                    }
                }

                /* variations */
                &.short .name {
                    width: 35%;
                }

                &.short .message {
                    width: 50%;
                }
            }
        }

    }

}


@keyframes shimmer {
    0% {
        background-position: 100% 0;
    }

    100% {
        background-position: 0 0;
    }
}









.wa-loader {
    display: flex;
    flex-direction: row-reverse;
    gap: 6px;
    padding: 10px;
    align-items: center;
}


    .wa-loader span {
        width: 8px;
        height: 8px;
        background: #25D366; /* WhatsApp green */
        border-radius: 50%;
        animation: wa-bounce 1.4s infinite ease-in-out both;
    }


        .wa-loader span:nth-child(1) {
            animation-delay: -0.32s;
        }

        .wa-loader span:nth-child(2) {
            animation-delay: -0.16s;
        }


@keyframes wa-bounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.3;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}



