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

:root {
    --wa-green: #25D366;
    --wa-green-dark: #128C7E;
    --wa-teal: #075E54;
    --wa-blue: #34B7F1;
    --wa-light-green: #DCF8C6;
    --wa-bg: #E5DDD5;
    --wa-white: #FFFFFF;
    --wa-gray: #F0F0F0;
    --wa-text: #303030;
    --wa-text-gray: #667781;
    --header-bg: #008069;
    --message-out: #D9FDD3;
    --message-in: #FFFFFF;
}

body {
    font-family: "Segoe UI", Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
}

body.dark-mode {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

body.dark-mode {
    --wa-bg: #0B141A;
    --wa-white: #111B21;
    --wa-gray: #202C33;
    --wa-text: #E9EDEF;
    --wa-text-gray: #8696A0;
    --header-bg: #202C33;
    --message-out: #005C4B;
    --message-in: #202C33;
}

#app {
    width: 100%;
    height: 100vh;
    position: relative;
}

/* Drop Zone */
.drop-zone {
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--wa-white);
    transition: all 0.3s ease;
}

.drop-zone.active {
    display: flex;
}

.drop-zone.drag-over {
    background-color: rgba(37, 211, 102, 0.1);
    border: 3px dashed var(--wa-green);
}

.drop-content {
    text-align: center;
    padding: 40px;
}

.drop-content svg {
    margin-bottom: 20px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.drop-content h1 {
    color: var(--wa-text);
    font-size: 32px;
    margin-bottom: 10px;
    font-weight: 400;
}

.drop-content p {
    color: var(--wa-text-gray);
    font-size: 16px;
    margin-bottom: 30px;
}

.btn-primary {
    background-color: var(--wa-green);
    color: white;
    border: none;
    padding: 12px 32px;
    font-size: 16px;
    border-radius: 24px;
    cursor: pointer;
    transition: background-color 0.3s;
}

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

/* Chat Container */
.chat-container {
    width: 100%;
    max-width: 600px;
    height: 100vh;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    background-color: var(--wa-white);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* Header */
.chat-header {
    background-color: var(--header-bg);
    color: white;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

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

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.header-info h2 {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 2px;
}

.header-info span {
    font-size: 13px;
    opacity: 0.8;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

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

/* Search Bar */
.search-bar {
    background-color: var(--wa-white);
    padding: 8px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-bar input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    font-size: 14px;
    background-color: var(--wa-gray);
    color: var(--wa-text);
}

.search-bar input:focus {
    outline: none;
    border-color: var(--wa-green);
}

.search-results {
    font-size: 13px;
    color: var(--wa-text-gray);
    white-space: nowrap;
    min-width: 80px;
    text-align: right;
}

/* Messages Area */
.messages-area {
    flex: 1;
    overflow-y: auto;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><rect fill="%23E5DDD5" width="100" height="100"/><path fill="%23D8D0C8" d="M0 0h50v50H0z"/><path fill="%23D8D0C8" d="M50 50h50v50H50z"/></svg>');
    background-color: var(--wa-bg);
    padding: 12px 8% 12px 8%;
}

body.dark-mode .messages-area {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><rect fill="%230B141A" width="100" height="100"/><path fill="%23151F25" d="M0 0h50v50H0z"/><path fill="%23151F25" d="M50 50h50v50H50z"/></svg>');
}

.messages-list {
    max-width: 1000px;
    margin: 0 auto;
}

/* Loading Indicator */
.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    color: var(--wa-text-gray);
    font-size: 14px;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--wa-green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Date Divider */
.date-divider {
    text-align: center;
    margin: 16px 0;
}

.date-divider span {
    background-color: var(--wa-white);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--wa-text-gray);
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}

/* Message Bubble */
.message {
    display: flex;
    margin-bottom: 8px;
    animation: fadeIn 0.3s ease;
}

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

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

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

.message-bubble {
    max-width: 65%;
    padding: 6px 7px 8px 9px;
    border-radius: 8px;
    position: relative;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
}

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

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

.message-sender {
    font-weight: 600;
    font-size: 13px;
    color: var(--wa-green);
    margin-bottom: 4px;
}

.message-text {
    color: var(--wa-text);
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    white-space: pre-wrap;
    margin-bottom: 2px;
}

.message-text a {
    color: #34B7F1;
    text-decoration: none;
}

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

.message.system .message-bubble {
    background-color: rgba(241, 241, 242, 0.9);
    color: var(--wa-text-gray);
    font-size: 13px;
    text-align: center;
    box-shadow: none;
    padding: 8px 12px;
    margin: 0 auto;
    max-width: 80%;
}

body.dark-mode .message.system .message-bubble {
    background-color: rgba(32, 44, 51, 0.9);
}

.message-image,
.message-video,
.message-sticker {
    max-width: 250px;
    max-height: 250px;
    border-radius: 8px;
    margin-bottom: 4px;
    cursor: pointer;
    display: block;
    object-fit: cover;
    transition: all 0.3s ease;
}

.message-image.expanded,
.message-video.expanded {
    max-width: 400px;
    max-height: 400px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.message-image:hover,
.message-video:hover {
    transform: scale(1.02);
}

.message-sticker {
    max-width: 150px;
    max-height: 150px;
    background: transparent;
}

.media-container {
    position: relative;
    display: inline-block;
}

.message-audio {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
}

.message-audio audio {
    flex: 1;
    height: 32px;
}

.message-document {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.message-document:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.document-icon {
    width: 40px;
    height: 40px;
    background-color: var(--wa-green);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    flex-shrink: 0;
}

.document-info {
    flex: 1;
    min-width: 0;
}

.document-name {
    font-size: 14px;
    color: var(--wa-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.document-size {
    font-size: 12px;
    color: var(--wa-text-gray);
}

.message-time {
    font-size: 11px;
    color: var(--wa-text-gray);
    text-align: right;
    margin-top: 2px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-content {
    text-align: center;
    color: white;
}

.spinner-large {
    width: 60px;
    height: 60px;
    border: 6px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--wa-green);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.loading-content p {
    font-size: 18px;
}

/* Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
    cursor: pointer;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 40px;
    cursor: pointer;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    z-index: 10001;
}

.lightbox-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.lightbox img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    animation: zoomIn 0.3s ease;
    cursor: default;
}

@keyframes zoomIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .chat-container {
        max-width: 100%;
        box-shadow: none;
    }
    
    .messages-area {
        padding: 12px 4%;
    }
    
    .message-bubble {
        max-width: 80%;
    }
    
    .message-image,
    .message-video {
        max-width: 200px;
        max-height: 200px;
    }
}

/* Scrollbar */
.messages-area::-webkit-scrollbar {
    width: 8px;
}

.messages-area::-webkit-scrollbar-track {
    background: transparent;
}

.messages-area::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.messages-area::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.3);
}

/* Highlight search results */
.highlight {
    background-color: #ffeb3b;
    color: #000;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 500;
    animation: highlightPulse 0.5s ease;
}

.highlight.active {
    background-color: #FF4400;
    color: white;
}

@keyframes highlightPulse {
    0%, 100% {
        background-color: #ffeb3b;
    }
    50% {
        background-color: #fdd835;
    }
}
