:root {
    --primary: #25d366;
    --primary-dark: #128c7e;
    --bg: #0b0f1a;
    --sidebar-bg: #161b22;
    --card-bg: #1c2128;
    --border: rgba(255, 255, 255, 0.1);
    --text: #f0f6fc;
    --text-muted: #8b949e;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, sans-serif;
}

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

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.sidebar-logo {
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 2.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: linear-gradient(to right, var(--primary), #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    border-radius: 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
}

.nav-item.active {
    background: rgba(37, 211, 102, 0.1);
    color: var(--primary);
}

.nav-item i {
    font-size: 1.2rem;
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 2.5rem;
}

.section {
    max-width: 1200px;
    margin: 0 auto;
}

/* Cards & Components */
.glass-card {
    background: var(--card-bg);
    border-radius: 1rem;
    padding: 2rem;
    border: 1px solid var(--border);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

h1 { font-size: 1.75rem; font-weight: 700; }

/* Instance Grid */
.instance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.instance-card {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 1rem;
    padding: 1.5rem;
    border: 1px solid var(--border);
    transition: transform 0.2s;
}

.instance-card:hover { transform: translateY(-4px); }

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 2rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.status-connected { background: rgba(37, 211, 102, 0.1); color: var(--primary); }
.status-qr { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }
.status-closed { background: rgba(239, 68, 68, 0.1); color: #ef4444; }
.status-connecting { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }

/* Buttons & Inputs */
button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 0.6rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

button:hover { opacity: 0.9; }

input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    color: white;
    padding: 0.6rem 1rem;
    border-radius: 0.6rem;
    outline: none;
}

/* Chat Interface */
.chat-container {
    display: flex;
    height: calc(100vh - 180px);
    background: var(--card-bg);
    border-radius: 1rem;
    border: 1px solid var(--border);
    overflow: hidden;
}

.chat-sidebar {
    width: 300px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: background 0.2s;
}

.chat-item:hover { background: rgba(255, 255, 255, 0.05); }
.chat-item.active { background: rgba(37, 211, 102, 0.1); }

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.1);
}

.chat-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--sidebar-bg);
}

.messages-area {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.message-bubble {
    max-width: 70%;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    font-size: 0.9rem;
    line-height: 1.4;
    position: relative;
}

.msg-in {
    align-self: flex-start;
    background: #262d31;
    border-bottom-left-radius: 0.2rem;
}

.msg-out {
    align-self: flex-end;
    background: #056162;
    border-bottom-right-radius: 0.2rem;
}

.chat-input-area {
    padding: 1rem;
    background: var(--sidebar-bg);
    display: flex;
    gap: 1rem;
}

.chat-input-area input { flex: 1; }

.instance-selector {
    padding: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid var(--border);
}

.instance-selector select {
    width: 100%;
    padding: 0.5rem;
    background: var(--bg);
    color: white;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
}

/* Utils */
.hidden { 
    display: none !important; 
}

/* Login Page Override */
#login-page {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

#login-card { width: 400px; }
