/* WhatsApp Web Theme & Layout */
:root {
    --wa-teal: #00a884;
    --wa-teal-dark: #008069;
    --wa-teal-light: #25d366;
    --wa-bg-app: #eae6df;
    --wa-bg-panel: #ffffff;
    --wa-bg-sidebar: #ffffff;
    --wa-bg-header: #f0f2f5;
    --wa-bg-chat: #efeae2;
    --wa-bubble-in: #ffffff;
    --wa-bubble-out: #d9fdd3;
    --wa-bubble-sys: #fff4d6;
    --wa-text-primary: #111b21;
    --wa-text-secondary: #667781;
    --wa-text-muted: #8696a0;
    --wa-border: #e9edef;
    --wa-border-light: #f0f2f5;
    --wa-hover: #f5f6f6;
    --wa-active: #ebebeb;
    --wa-danger: #ea4335;
    --wa-shadow: rgba(11, 20, 26, 0.1);
}

[data-theme="dark"] {
    --wa-bg-app: #0c1317;
    --wa-bg-panel: #111b21;
    --wa-bg-sidebar: #111b21;
    --wa-bg-header: #202c33;
    --wa-bg-chat: #0b141a;
    --wa-bubble-in: #202c33;
    --wa-bubble-out: #005c4b;
    --wa-bubble-sys: #182229;
    --wa-text-primary: #e9edef;
    --wa-text-secondary: #8696a0;
    --wa-text-muted: #667781;
    --wa-border: #222e35;
    --wa-border-light: #222e35;
    --wa-hover: #202c33;
    --wa-active: #2a3942;
    --wa-shadow: rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--wa-bg-app);
    color: var(--wa-text-primary);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-wrapper {
    width: 100vw;
    height: 100vh;
    display: flex;
    background-color: var(--wa-bg-panel);
    overflow: hidden;
    position: relative;
}

/* SIDEBAR */
.sidebar {
    width: 380px;
    min-width: 320px;
    max-width: 450px;
    height: 100%;
    border-right: 1px solid var(--wa-border);
    display: flex;
    flex-direction: column;
    background-color: var(--wa-bg-sidebar);
    z-index: 10;
}

.sidebar-header {
    height: 60px;
    padding: 10px 16px;
    background-color: var(--wa-bg-header);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--wa-border);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--wa-teal);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    text-transform: uppercase;
    overflow: hidden;
    flex-shrink: 0;
}

.avatar.avatar-group {
    background-color: #54656f;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--wa-text-primary);
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-icons {
    display: flex;
    align-items: center;
    gap: 4px;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--wa-text-secondary);
    transition: background-color 0.15s;
    position: relative;
}

.icon-btn:hover {
    background-color: var(--wa-hover);
    color: var(--wa-text-primary);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* SEARCH IN SIDEBAR */
.sidebar-search-box {
    padding: 8px 12px;
    border-bottom: 1px solid var(--wa-border);
    background-color: var(--wa-bg-sidebar);
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    background-color: var(--wa-bg-header);
    border-radius: 8px;
    padding: 6px 12px;
    gap: 8px;
}

.search-input-wrapper svg {
    width: 18px;
    height: 18px;
    fill: var(--wa-text-secondary);
    flex-shrink: 0;
}

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

/* CONVERSATION LIST */
.conversation-list {
    flex: 1;
    overflow-y: auto;
}

.conversation-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--wa-border-light);
    transition: background-color 0.15s;
    position: relative;
}

.conversation-item:hover {
    background-color: var(--wa-hover);
}

.conversation-item.active {
    background-color: var(--wa-active);
}

.conv-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    margin-right: 14px;
    flex-shrink: 0;
}

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

.conv-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
}

.conv-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--wa-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-time {
    font-size: 12px;
    color: var(--wa-text-muted);
    flex-shrink: 0;
    margin-left: 8px;
}

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

.conv-snippet {
    font-size: 13px;
    color: var(--wa-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.conv-badge {
    background-color: var(--wa-teal);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
    margin-left: 6px;
    flex-shrink: 0;
}

/* CHAT MAIN PANEL */
.chat-panel {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: var(--wa-bg-chat);
    position: relative;
    overflow: hidden;
}

/* Empty state */
.chat-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--wa-bg-header);
    border-bottom: 6px solid var(--wa-teal);
    text-align: center;
    padding: 30px;
}

.chat-empty-state svg {
    width: 140px;
    height: 140px;
    fill: var(--wa-text-muted);
    margin-bottom: 24px;
}

.chat-empty-state h2 {
    font-size: 28px;
    font-weight: 300;
    color: var(--wa-text-primary);
    margin-bottom: 12px;
}

.chat-empty-state p {
    font-size: 14px;
    color: var(--wa-text-secondary);
    max-width: 480px;
    line-height: 1.6;
    margin-bottom: 24px;
}

/* CHAT HEADER */
.chat-header {
    height: 60px;
    padding: 10px 16px;
    background-color: var(--wa-bg-header);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--wa-border);
    z-index: 5;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.chat-header-details h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--wa-text-primary);
}

.chat-header-details p {
    font-size: 12px;
    color: var(--wa-text-secondary);
}

/* IN-CHAT SEARCH DRAWER */
.chat-search-bar {
    background-color: var(--wa-bg-header);
    border-bottom: 1px solid var(--wa-border);
    padding: 8px 16px;
    display: none;
    align-items: center;
    gap: 10px;
    z-index: 4;
    animation: slideDown 0.2s ease-out;
}

.chat-search-bar.active {
    display: flex;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.filter-select {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--wa-border);
    background-color: var(--wa-bg-panel);
    color: var(--wa-text-primary);
    font-size: 13px;
    outline: none;
}

/* MESSAGES CONTAINER */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 50px 20px 50px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background-image: radial-gradient(var(--wa-border) 1px, transparent 1px);
    background-size: 20px 20px;
}

/* DATE SEPARATOR */
.chat-date-separator {
    align-self: center;
    margin: 12px 0 6px 0;
}

.chat-date-separator span {
    background-color: var(--wa-bg-panel);
    color: var(--wa-text-secondary);
    font-size: 12px;
    font-weight: 500;
    padding: 5px 12px;
    border-radius: 8px;
    box-shadow: 0 1px 2px var(--wa-shadow);
    text-transform: uppercase;
}

/* SYSTEM MESSAGE */
.message-system {
    align-self: center;
    max-width: 80%;
    margin: 8px 0;
    text-align: center;
}

.message-system span {
    background-color: var(--wa-bubble-sys);
    color: var(--wa-text-secondary);
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 8px;
    display: inline-block;
    box-shadow: 0 1px 2px var(--wa-shadow);
    line-height: 1.4;
}

/* MESSAGE BUBBLE */
.message-bubble {
    display: flex;
    flex-direction: column;
    max-width: 65%;
    padding: 6px 10px 6px 10px;
    border-radius: 8px;
    box-shadow: 0 1px 1.5px var(--wa-shadow);
    position: relative;
    word-break: break-word;
    font-size: 14px;
    line-height: 1.45;
}

.message-bubble.incoming {
    align-self: flex-start;
    background-color: var(--wa-bubble-in);
    border-top-left-radius: 0;
}

.message-bubble.outgoing {
    align-self: flex-end;
    background-color: var(--wa-bubble-out);
    border-top-right-radius: 0;
}

.message-sender {
    font-size: 12.5px;
    font-weight: 600;
    margin-bottom: 2px;
    cursor: pointer;
}

.message-sender:hover {
    text-decoration: underline;
}

.message-content {
    white-space: pre-wrap;
    color: var(--wa-text-primary);
}

.message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 2px;
    float: right;
    margin-left: 12px;
}

.message-time {
    font-size: 11px;
    color: var(--wa-text-muted);
}

/* MEDIA IN MESSAGES */
.media-preview-container {
    margin: 4px 0;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.media-image-container {
    cursor: pointer;
    display: inline-block;
}

.media-preview-img {
    max-width: 320px;
    max-height: 280px;
    width: auto;
    height: auto;
    object-fit: cover;
    border-radius: 8px;
    display: block;
    transition: transform 0.2s ease, filter 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.media-preview-img:hover {
    transform: scale(1.02);
    filter: brightness(0.96);
}

.media-video-container {
    max-width: 360px;
}

.media-video {
    width: 100%;
    max-width: 360px;
    max-height: 320px;
    border-radius: 8px;
    outline: none;
    display: block;
    background-color: #000;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.media-audio-container {
    margin: 4px 0;
    min-width: 260px;
    max-width: 340px;
}

.audio-player-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.04);
    padding: 8px 10px;
    border-radius: 20px;
}

[data-theme="dark"] .audio-player-card {
    background: rgba(255, 255, 255, 0.06);
}

.audio-icon-badge {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background-color: var(--wa-teal);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.audio-player-controls {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.media-audio {
    width: 100%;
    height: 34px;
    outline: none;
}

.audio-filename {
    font-size: 11px;
    color: var(--wa-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.media-document {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.05);
    padding: 10px 14px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--wa-text-primary);
    transition: background 0.15s;
    font-size: 13.5px;
}

.media-document:hover {
    background: rgba(0, 0, 0, 0.09);
}

.media-fallback {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 8px;
    color: var(--wa-text-muted);
    font-size: 12px;
}

/* HIGHLIGHT SEARCH MATCHES */
mark.search-highlight {
    background-color: #ffd43b;
    color: #000;
    padding: 1px 3px;
    border-radius: 2px;
    font-weight: 600;
}

/* CHAT FOOTER / STATUS BAR */
.chat-footer-bar {
    height: 48px;
    background-color: var(--wa-bg-header);
    border-top: 1px solid var(--wa-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    font-size: 13px;
    color: var(--wa-text-secondary);
}

/* MODAL SYSTEM */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(11, 20, 26, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

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

.modal-dialog {
    background-color: var(--wa-bg-panel);
    border-radius: 10px;
    width: 100%;
    max-width: 580px;
    box-shadow: 0 24px 48px rgba(0,0,0,0.2);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    animation: modalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    padding: 16px 20px;
    background-color: var(--wa-teal);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 17px;
    font-weight: 600;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.modal-close-btn:hover {
    background: rgba(255,255,255,0.2);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-footer {
    padding: 14px 20px;
    background-color: var(--wa-bg-header);
    border-top: 1px solid var(--wa-border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background-color 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background-color: var(--wa-teal);
    color: #ffffff;
}

.btn-primary:hover {
    background-color: var(--wa-teal-dark);
}

.btn-secondary {
    background-color: #e9edef;
    color: #3b4a54;
}

.btn-secondary:hover {
    background-color: #d1d7db;
}

.btn-danger {
    background-color: var(--wa-danger);
    color: #ffffff;
}

/* PROGRESS BAR */
.progress-container {
    width: 100%;
    background-color: #e9edef;
    border-radius: 6px;
    overflow: hidden;
    height: 12px;
    margin: 12px 0 6px 0;
}

.progress-bar {
    height: 100%;
    background-color: var(--wa-teal);
    width: 0%;
    transition: width 0.15s ease;
}

.progress-stats {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--wa-text-secondary);
}

/* LIGHTBOX */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

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

.lightbox-content {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.5);
}

.lightbox-toolbar {
    position: absolute;
    top: 20px;
    right: 25px;
    display: flex;
    gap: 12px;
}

.lightbox-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: background 0.2s;
}

.lightbox-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.lightbox-caption {
    color: #fff;
    margin-top: 14px;
    font-size: 14px;
    text-align: center;
}
