:root {
    --bg-dark: #121212;
    --bg-sidebar: #1e1e1e;
    --bg-chat: #0a0a0a;
    --primary: #3b82f6;
    --text-main: #ffffff;
    --text-dim: #a1a1aa;
    --border: #333;
    --msg-sent: #2563eb;
    --msg-received: #27272a;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }

body { background-color: var(--bg-dark); color: var(--text-main); height: 100vh; overflow: hidden; }

.app-container { display: flex; height: 100%; width: 100%; }

/* Sidebar */
.sidebar {
    width: 300px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 10;
}

.sidebar-header { padding: 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.my-id-display { padding: 15px; background: #2a2a2a; margin: 10px; border-radius: 8px; text-align: center; cursor: pointer; }
.id-box { font-family: monospace; font-size: 1.2rem; color: var(--primary); margin-top: 5px; letter-spacing: 1px; }

.chat-list { flex: 1; overflow-y: auto; }
.chat-item { padding: 15px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.2s; }
.chat-item:hover, .chat-item.active { background-color: #333; }
.chat-item h4 { margin-bottom: 5px; font-weight: 500; }
.chat-item p { font-size: 0.8rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#new-chat-btn { margin: 15px; padding: 12px; background: var(--primary); border: none; color: white; border-radius: 6px; cursor: pointer; font-weight: bold; }

/* Main Chat */
.main-chat { flex: 1; display: flex; flex-direction: column; background-color: var(--bg-chat); position: relative; }

.top-bar { height: 60px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 15px; background: var(--bg-sidebar); }
.left-controls { display: flex; align-items: center; gap: 10px; }
.icon-btn { background: none; border: none; color: white; font-size: 1.5rem; cursor: pointer; }

.profile-circle { width: 40px; height: 40px; background: #333; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background 0.2s; }
.profile-circle:hover { background: #444; }

.messages-area { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.placeholder { margin: auto; text-align: center; color: var(--text-dim); }

.message { max-width: 70%; padding: 10px 15px; border-radius: 12px; font-size: 0.95rem; line-height: 1.4; word-wrap: break-word; }
.message.sent { align-self: flex-end; background-color: var(--msg-sent); border-bottom-right-radius: 2px; }
.message.received { align-self: flex-start; background-color: var(--msg-received); border-bottom-left-radius: 2px; }

.input-area { height: 70px; padding: 15px; border-top: 1px solid var(--border); display: flex; gap: 10px; background: var(--bg-sidebar); }
input { flex: 1; background: #333; border: none; padding: 10px; border-radius: 20px; color: white; outline: none; }
#send-btn { padding: 0 20px; background: var(--primary); border: none; color: white; border-radius: 20px; cursor: pointer; font-weight: bold; }
#send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Modal */
.hidden { display: none !important; }
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); display: flex; justify-content: center; align-items: center; z-index: 100; }
.modal-content { background: var(--bg-sidebar); padding: 30px; border-radius: 12px; width: 90%; max-width: 400px; position: relative; border: 1px solid var(--border); text-align: center; }
.close-modal { position: absolute; top: 10px; right: 15px; font-size: 1.5rem; cursor: pointer; }
.sync-options { margin-top: 20px; display: flex; flex-direction: column; gap: 20px; }
.sync-section { background: #2a2a2a; padding: 15px; border-radius: 8px; }
.sync-section h3 { font-size: 1rem; margin-bottom: 5px; color: var(--primary); }
.sync-section p { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 10px; }
.divider { display: flex; align-items: center; justify-content: center; color: var(--text-dim); font-size: 0.8rem; font-weight: bold; }
.pin-code { font-family: monospace; font-size: 2rem; display: block; margin: 10px 0; letter-spacing: 5px; color: var(--primary); }
.warning { color: #ef4444 !important; font-size: 0.7rem !important; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { position: absolute; height: 100%; transform: translateX(-100%); width: 85%; }
    .sidebar.open { transform: translateX(0); }
    .mobile-only { display: block; }
}
@media (min-width: 769px) {
    .mobile-only { display: none; }
}