/* 
   WhatsApp Web Clone CSS - Dark Mode
   Matches WhatsApp Web colors, typography, and layout as of 2026
*/

:root {
    /* Color Palette */
    --app-background: #0c1317;
    --background-default: #111b21;
    --background-default-hover: #202c33;
    --background-default-active: #2a3942;
    --background-input: #202c33;
    --background-header: #202c33;
    --border-list: rgba(134, 150, 160, 0.15);
    --border-strong: rgba(134, 150, 160, 0.15);
    --primary: #00a884;
    --primary-deep: #008069;
    --secondary: #8696a0;
    --secondary-lighter: #aebac1;
    --inverse: #e9edef;
    --system-message-text: #8696a0;
    --system-message-background: #182229;
    --outgoing-background: #005c4b;
    --incoming-background: #202c33;
    --modal-background: #3b4a54;
    --dropdown-background: #233138;
    --panel-header-icon: #aebac1;
    --icon: #aebac1;
    --icon-ack: #53bdeb;
    /* Blue ticks */
    --danger: #ef5350;

    /* Spacing & Typography */
    --header-height: 59px;
    --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--app-background);
    color: var(--inverse);
    font-family: var(--font-stack);
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    /* Prevent body scroll */
    height: 100vh;
    font-size: 14.5px;
}

/* Main Container */
.app-wrapper {
    display: flex;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* Background strip (desktop only effect) */
.app-wrapper::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 127px;
    background-color: var(--primary-deep);
    z-index: -1;
    display: none;
    /* Hidden by default for full-screen web app style */
}

/* Full screen mode always */
/* Removed media query for 1441px to ensure app fits the screen properly */


/* 
   ----------------
   LEFT SIDEBAR 
   ---------------- 
*/
.sidebar {
    width: 30%;
    /* Resizable ideally, but fixed for now */
    min-width: 340px;
    max-width: 450px;
    display: flex;
    flex-direction: column;
    background-color: var(--background-default);
    border-right: 1px solid var(--border-strong);
    z-index: 100;
}

/* Sidebar Header */
.sidebar-header {
    height: var(--header-height);
    background-color: var(--background-header);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    background-color: var(--background-default-active);
    cursor: pointer;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sidebar-actions {
    display: flex;
    gap: 24px;
    color: var(--panel-header-icon);
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Tab Bar (Custom for WPB Business/Personal) */
.tab-bar {
    display: flex;
    background-color: var(--background-default);
    border-bottom: 0px solid var(--border-list);
    padding: 0 10px;
    /* Custom style to blend */
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    color: var(--secondary);
    padding: 12px 0;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.tab-btn:hover {
    background-color: var(--background-default-hover);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Search Bar */
.search-container {
    padding: 8px 12px;
    background-color: var(--background-default);
    border-bottom: 1px solid var(--border-list);
    flex-shrink: 0;
}

.search-wrapper {
    background-color: var(--background-input);
    border-radius: 8px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    height: 35px;
}

.search-icon {
    color: var(--secondary);
    margin-right: 16px;
    /* WhatsApp puts icon left, back button animates */
    width: 16px;
}

.search-input {
    background: transparent;
    border: none;
    color: var(--inverse);
    width: 100%;
    font-size: 14px;
    outline: none;
}

.search-input::placeholder {
    color: var(--secondary);
}

/* Conversation List */
.chat-list {
    flex: 1;
    overflow-y: auto;
    background-color: var(--background-default);
}

.chat-item {
    height: 72px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    cursor: pointer;
    background-color: var(--background-default);
    position: relative;
    /* transition: background-color 0.1s; */
}

.chat-item:hover {
    background-color: var(--background-default-hover);
}

.chat-item.active {
    background-color: var(--background-default-active);
}

.chat-avatar {
    width: 49px;
    height: 49px;
    border-radius: 50%;
    margin-right: 15px;
    flex-shrink: 0;
    background-color: var(--secondary);
    /* Default gray */
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    font-weight: 500;
    overflow: hidden;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-info {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-bottom: 1px solid var(--border-list);
    min-width: 0;
    /* Text truncation fix */
    padding-right: 4px;
}

.chat-row-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 3px;
}

.chat-name {
    font-size: 17px;
    font-weight: 400;
    color: var(--inverse);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.chat-time {
    font-size: 12px;
    color: var(--secondary);
    flex-shrink: 0;
}

.chat-row-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-preview {
    font-size: 13px;
    color: var(--secondary);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    flex: 1;
    display: flex;
    /* For icon alignment */
    align-items: center;
}

.status-check {
    margin-right: 4px;
    font-size: 16px;
}

.chat-unread {
    background-color: var(--primary);
    color: var(--background-default);
    font-size: 12px;
    font-weight: 500;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    margin-left: 6px;
}


/* 
   ----------------
   RIGHT MAIN PANEL 
   ---------------- 
*/
.main-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #0b141a;
    /* Darker than default bg */
    border-left: 1px solid var(--border-list);
    position: relative;
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
    /* Helper pattern */
    background-repeat: repeat;
    background-size: 400px;
    /* Overlay to darken the pattern */
}

/* Pattern overlay trick */
.main-panel::after {
    content: "";
    position: absolute;
    inset: 0;
    background-color: rgba(11, 20, 26, 0.95);
    /* Tint */
    z-index: 0;
    pointer-events: none;
}

/* Chat Header */
.main-header {
    height: var(--header-height);
    background-color: var(--background-header);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    cursor: pointer;
}

.header-profile {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 15px;
    overflow: hidden;
    cursor: pointer;
}

.header-avatar img {
    width: 100%;
    height: 100%;
}

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

.header-name {
    font-size: 16px;
    font-weight: 500;
    color: var(--inverse);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-status {
    font-size: 13px;
    color: var(--secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-actions {
    display: flex;
    gap: 20px;
    color: var(--panel-header-icon);
}

/* Chat Search Box (in header usually, but we keep simple actions) */

/* Messages Area */
.messages-container {
    flex: 1;
    padding: 20px 60px;
    /* Large side padding on desktop */
    overflow-y: auto;
    z-index: 1;
    display: flex;
    flex-direction: column;
    /* gap: 8px; No gap, use margin on messages for cleaner grouping */
}

/* Date Bubble */
.date-bubble {
    align-self: center;
    background-color: var(--system-message-background);
    color: var(--secondary);
    font-size: 12.5px;
    padding: 6px 12px;
    border-radius: 8px;
    margin: 8px 0;
    text-transform: uppercase;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}

/* Message Bubbles */
.message-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 2px;
}

.message-bubble {
    max-width: 65%;
    padding: 6px 7px 8px 9px;
    border-radius: 7.5px;
    position: relative;
    font-size: 14.2px;
    line-height: 19px;
    color: var(--inverse);
    word-wrap: break-word;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
}

.message-incoming {
    background-color: var(--incoming-background);
    align-self: flex-start;
    border-top-left-radius: 0;
    margin-left: 10px;
    /* Spacer for tail */
}

.message-outgoing {
    background-color: var(--outgoing-background);
    align-self: flex-end;
    border-top-right-radius: 0;
    margin-right: 10px;
    /* Spacer for tail */
}

/* Tails CSS Shapes */
.message-incoming::before {
    content: "";
    position: absolute;
    top: 0;
    left: -8px;
    width: 8px;
    height: 13px;
    background: linear-gradient(to bottom left, var(--incoming-background) 50%, transparent 50%);
}

.message-outgoing::before {
    content: "";
    position: absolute;
    top: 0;
    right: -8px;
    width: 8px;
    height: 13px;
    background: linear-gradient(to bottom right, var(--outgoing-background) 50%, transparent 50%);
}

/* Message Content */
.msg-text {
    padding-right: 20px;
    /* Room for time */
    white-space: pre-wrap;
}

.msg-meta {
    float: right;
    margin-top: -6px;
    /* Pull into text block if space allows */
    margin-left: 8px;
    padding-left: 4px;
    display: flex;
    align-items: center;
    color: rgba(255, 255, 255, 0.6);
    font-size: 11px;
    height: 18px;
    /* Force height */
    position: relative;
    top: 6px;
    /* Push down */
}

.msg-status-icon {
    margin-left: 3px;
    font-size: 16px;
}

.msg-status-icon.read {
    color: var(--icon-ack);
}

/* Media styling */
.msg-media {
    margin: -3px -4px 4px -4px;
    border-radius: 7.5px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    background: rgba(0, 0, 0, 0.1);
}

.msg-media img,
.msg-media video {
    display: block;
    max-width: 330px;
    max-height: 330px;
    min-width: 100px;
    object-fit: contain;
}

.caption {
    margin-top: 4px;
    font-size: 14.2px;
}

/* Footer / Input Area */
.chat-footer {
    min-height: 62px;
    background-color: var(--background-header);
    z-index: 10;
    display: flex;
    align-items: center;
    padding: 5px 16px;
    gap: 10px;
}

.input-actions {
    display: flex;
    gap: 16px;
    color: var(--secondary);
}

.chat-input-bar {
    flex: 1;
    background-color: var(--background-default-active);
    border-radius: 8px;
    padding: 9px 12px;
    display: flex;
    align-items: center;
}

.chat-input-field {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--inverse);
    font-size: 15px;
    outline: none;
    max-height: 100px;
    overflow-y: auto;
}

.chat-input-field::placeholder {
    color: var(--secondary);
}

.btn-send {
    color: var(--secondary);
    /* Mic icon usually */
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
}

.btn-send.active {
    color: var(--primary);
    /* Send icon when typing */
}

/* 
   ----------------
   INTRO SCREEN (Empty State)
   ---------------- 
*/
.intro-screen {
    flex: 1;
    background-color: var(--background-default);
    /* Actually slightly different, but consistent dark */
    border-bottom: 6px solid var(--primary-deep);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    z-index: 20;
    color: var(--secondary);
}

.intro-image {
    margin-bottom: 40px;
    opacity: 0.8;
}

.intro-title {
    font-size: 32px;
    font-weight: 300;
    color: var(--inverse);
    margin-bottom: 16px;
}

.intro-text {
    font-size: 14px;
    line-height: 20px;
    max-width: 560px;
    margin-bottom: 30px;
    color: var(--secondary);
}

/* 
   ----------------
   MODALS & UTILS
   ---------------- 
*/

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px !important;
    height: 6px !important;
}

::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2) !important;
}

::-webkit-scrollbar-track {
    background: transparent !important;
}

/* Login Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(11, 20, 26, 0.8);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background-color: var(--modal-background);
    padding: 24px;
    border-radius: 4px;
    /* WhatsApp is square-ish */
    width: 400px;
    box-shadow: 0 17px 50px 0 rgba(0, 0, 0, 0.19), 0 12px 15px 0 rgba(0, 0, 0, 0.24);
}

.modal-title {
    font-size: 20px;
    margin-bottom: 20px;
    color: var(--inverse);
}

.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    color: var(--secondary);
    font-size: 13px;
    margin-bottom: 8px;
}

.modal-input {
    width: 100%;
    padding: 10px;
    background-color: var(--background-input);
    border: 1px solid var(--border-list);
    border-radius: 4px;
    color: var(--inverse);
    outline: none;
}

.modal-input:focus {
    border-color: var(--primary);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

.btn-primary {
    background-color: var(--primary);
    color: #111b21;
    /* High contrast text */
    border: none;
    padding: 10px 24px;
    border-radius: 20px;
    font-weight: 500;
    cursor: pointer;
}

.btn-primary:hover {
    background-color: var(--primary-deep);
}

.btn-text {
    background: none;
    border: 1px solid var(--border-list);
    color: var(--primary);
    padding: 9px 23px;
    border-radius: 20px;
    cursor: pointer;
}

/* File Preview Bar */
.file-preview-bar {
    height: 70px;
    background-color: var(--background-header);
    border-bottom: 1px solid var(--border-list);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    z-index: 5;
    display: none;
    /* hidden by default */
}

.file-preview-bar.visible {
    display: flex;
}

/* Responsive Mobile overrides */
@media (max-width: 900px) {
    .sidebar {
        width: 40%;
    }

    .messages-container {
        padding: 20px 5%;
    }
}

@media (max-width: 640px) {
    .sidebar {
        width: 100%;
        position: absolute;
        height: 100%;
        transition: transform 0.3s ease;
    }

    .main-panel {
        width: 100%;
        position: absolute;
        height: 100%;
        background-color: #0b141a;
        /* Force dark bg on mobile */
    }

    .sidebar.hidden {
        transform: translateX(-100%);
    }

    .main-panel.hidden {
        transform: translateX(100%);
    }

    /* Back button */
    .btn-back {
        display: block !important;
        margin-right: 12px;
        color: var(--inverse);
        font-size: 24px;
        background: none;
        border: none;
    }

    .app-wrapper {
        position: fixed;
        /* prevent rubber banding */
    }
}

.btn-back {
    display: none;
}