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

:root {
    --primary: #075e54;
    --primary-light: #25d366;
    --secondary: #128c7e;
    --dark: #0a0e27;
    --light: #f5f5f5;
    --text-primary: #111;
    --text-secondary: #666;
    --border: #e0e0e0;
    --gold: #C9A961;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
    background: var(--dark);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 360px;
    background: white;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    box-shadow: -1px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h1 {
    font-size: 32px;
    font-weight: 800;
    color: var(--primary);
}

.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    background: #e8f5e9;
    color: var(--primary);
    animation: pulse 2s infinite;
}

.status-badge.ready {
    background: #e8f5e9;
    color: var(--primary);
    animation: none;
}

.status-badge.authenticating {
    background: #fff3e0;
    color: #ff6f00;
}

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

.search-box {
    padding: 12px 20px;
}

.search-box input {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s;
}

.search-box input:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 8px rgba(37, 211, 102, 0.2);
}

.chats-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.chat-item {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    gap: 12px;
    align-items: center;
}

.chat-item:hover {
    background: #f5f5f5;
}

.chat-item.active {
    background: #e8f5e9;
    border-left: 4px solid var(--primary-light);
    padding-left: 16px;
}

.chat-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.chat-preview {
    flex: 1;
    min-width: 0;
}

.chat-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.loading {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Main Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    position: relative;
}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.chat-info {
    font-size: 12px;
    color: var(--text-secondary);
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f5f5f5;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    text-align: center;
}

.empty-state svg {
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state p {
    font-size: 14px;
}

.message {
    display: flex;
    margin-bottom: 8px;
    animation: slideIn 0.3s ease-out;
}

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

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

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

.message-bubble {
    max-width: 55%;
    padding: 10px 14px;
    border-radius: 8px;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.4;
}

.message.sent .message-bubble {
    background: var(--primary-light);
    color: white;
    border-radius: 8px 0 8px 8px;
}

.message.received .message-bubble {
    background: #e0e0e0;
    color: var(--text-primary);
    border-radius: 0 8px 8px 8px;
}

.message-time {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.message.sent .message-time {
    color: rgba(255, 255, 255, 0.7);
}

.message-media {
    max-width: 300px;
    margin-top: 8px;
    border-radius: 8px;
}

.message-media img,
.message-media video {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

/* Message Input */
.message-input-area {
    padding: 12px 24px;
    background: white;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.message-input-area input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: all 0.3s;
    resize: none;
    max-height: 100px;
}

.message-input-area input:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 8px rgba(37, 211, 102, 0.2);
}

.send-btn {
    background: var(--primary-light);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.3s;
    flex-shrink: 0;
}

.send-btn:hover {
    background: var(--primary);
    transform: scale(1.1);
}

.send-btn:active {
    transform: scale(0.95);
}

.send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* QR Code */
.qr-container {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.qr-content {
    background: white;
    padding: 40px;
    border-radius: 12px;
    text-align: center;
    max-width: 400px;
}

.qr-content h3 {
    margin-bottom: 20px;
    color: var(--primary);
}

.qr-code {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-code img {
    max-width: 100%;
    height: auto;
}

.qr-content p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 20px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 12px;
    text-align: center;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-content h2 {
    margin-bottom: 16px;
    color: var(--primary);
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.qr-modal {
    background: #f5f5f5;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    min-height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-modal img {
    max-width: 100%;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-light);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

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

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Responsivo */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .chat-area {
        min-height: 60vh;
    }

    .message-bubble {
        max-width: 85%;
    }

    .sidebar-header h1 {
        font-size: 24px;
    }
}
