:root {
    --primary: #128C7E;
    --primary-dark: #075E54;
    --primary-light: #00a884;
    --bg: #ede5d8;
    --sidebar-bg: #ffffff;
    --sidebar-border: #e9edef;
    --chat-bg: #efe7dd;
    --msg-sent: #d9fdd3;
    --msg-received: #ffffff;
    --text-primary: #111b21;
    --text-secondary: #667781;
    --text-muted: #8696a0;
    --danger: #ef5350;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text-primary); }

.btn {
    padding: 10px 20px; border: none; border-radius: 8px; cursor: pointer;
    font-size: 14px; font-weight: 600; transition: all 0.2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-send { background: var(--primary); color: #fff; border-radius: 50%; width: 42px; height: 42px; padding: 0; }
.btn-logout { background: transparent; font-size: 18px; padding: 8px; }
.btn-send:hover { background: var(--primary-dark); transform: scale(1.05); }

input, textarea {
    width: 100%; padding: 10px 14px; border: 1px solid var(--sidebar-border);
    border-radius: 8px; font-size: 14px; outline: none; transition: border 0.2s;
    background: #fff; color: var(--text-primary);
}
input:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: none; }

.login-wrapper {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
}
.login-card {
    background: #fff; border-radius: 16px; padding: 40px; width: 100%; max-width: 400px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.login-header { text-align: center; margin-bottom: 30px; }
.login-header h1 { font-size: 28px; color: var(--primary-dark); }
.login-header p { color: var(--text-secondary); margin-top: 6px; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 13px; color: var(--text-secondary); }
.btn-full { width: 100%; padding: 13px; font-size: 16px; }
.login-footer { text-align: center; margin-top: 20px; color: var(--text-muted); font-size: 12px; background: var(--sidebar-border); padding: 10px; border-radius: 8px; }
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
.alert-error { background: #fdecea; color: var(--danger); border: 1px solid #fecaca; }

/* ===================== DASHBOARD ===================== */
.dashboard-wrapper { display: flex; height: 100vh; overflow: hidden; }

/* SIDEBAR */
.sidebar { width: 350px; min-width: 320px; background: var(--sidebar-bg); border-right: 1px solid var(--sidebar-border); display: flex; flex-direction: column; }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; background: #f0f2f5; border-bottom: 1px solid var(--sidebar-border); }
.agent-info { display: flex; align-items: center; gap: 10px; }
.agent-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.agent-info strong { font-size: 15px; }
.status-badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 600; }
.status-online { background: #d4f8e8; color: #1b8a5e; }

.search-box { padding: 10px 14px; }
.search-box input { background: #f0f2f5; border: none; padding: 8px 14px; font-size: 13px; border-radius: 20px; }
.search-box input:focus { box-shadow: 0 0 0 2px var(--primary); }

.customer-list { flex: 1; overflow-y: auto; }
.customer-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; transition: background 0.15s; position: relative; }
.customer-item:hover { background: #f5f6f6; }
.customer-item.active { background: #f0f2f5; }
.customer-avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--primary-light); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; flex-shrink: 0; }
.customer-info { flex: 1; min-width: 0; }
.customer-name { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.customer-number { font-weight: 400; font-size: 12px; color: var(--text-muted); }
.customer-last-msg { font-size: 13px; color: var(--text-secondary); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread-badge { background: var(--danger); color: #fff; font-size: 12px; font-weight: 700; border-radius: 50%; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }

/* CHAT AREA */
.chat-area { flex: 1; display: flex; flex-direction: column; background: var(--chat-bg); background-image: url('https://www.transparenttextures.com/patterns/subtle-white-feathers.png'); }
.chat-header { padding: 14px 20px; background: var(--sidebar-border); border-bottom: 1px solid var(--sidebar-border); display: flex; align-items: center; gap: 12px; }
.chat-header .chat-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.chat-header h2 { font-size: 16px; }

/* MESSAGES */
.messages-container { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 4px; }
.empty-chat { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-muted); text-align: center; }
.empty-chat-icon { font-size: 64px; margin-bottom: 16px; }

.msg-wrapper { display: flex; margin: 2px 0; }
.msg-wrapper.sent { justify-content: flex-end; }
.msg-wrapper.received { justify-content: flex-start; }
.msg-bubble { max-width: 65%; padding: 8px 12px; border-radius: 8px; font-size: 14px; line-height: 1.5; word-wrap: break-word; position: relative; box-shadow: var(--shadow); }
.msg-bubble.sent { background: var(--msg-sent); border-top-right-radius: 2px; }
.msg-bubble.received { background: var(--msg-received); border-top-left-radius: 2px; }
.msg-meta { display: flex; justify-content: flex-end; gap: 4px; margin-top: 3px; }
.msg-time { font-size: 11px; color: var(--text-muted); }
.msg-status { font-size: 12px; color: var(--primary-light); }

/* INPUT AREA */
.input-area { padding: 12px 16px; background: var(--sidebar-border); }
.input-wrapper { display: flex; gap: 10px; align-items: flex-end; }
.input-wrapper textarea { flex: 1; min-height: 42px; max-height: 120px; padding: 10px 14px; border-radius: 20px; border: 1px solid var(--sidebar-border); background: #fff; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #bec9cc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #8696a0; }

/* RESPONSIVE */
@media (max-width: 768px) {
    .sidebar { width: 100%; min-width: unset; }
    .sidebar.hidden { display: none; }
    .msg-bubble { max-width: 85%; }
}
