/* ===========================
   WA BOT PLATFORM — style.css
   =========================== */

/* ROOT VARIABLES */
:root {
  --green: #25D366;
  --dark-green: #128C7E;
  --teal: #075E54;
  --msg-out: #dcf8c6;
  --sidebar-bg: #111b21;
  --sidebar-text: #aebac1;
  --sidebar-active: #00a884;
  --topbar-bg: #1f2c33;
  --bg: #0b141a;
  --surface: #1f2c33;
  --surface2: #2a3942;
  --border: #2d3f49;
  --text: #e9edef;
  --text-dim: #8696a0;
  --danger: #f15c6d;
  --warning: #f0b429;
  --info: #34b7f1;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0,0,0,0.4);
  --sidebar-w: 240px;
  --topbar-h: 56px;
}

/* RESET */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--green); text-decoration: none; }
ul { list-style: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* LAYOUT */
body { display: flex; overflow: hidden; }

/* SIDEBAR */
#sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  height: 100vh;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  transition: width 0.2s;
  overflow: hidden;
}
#sidebar.collapsed { width: 60px; }
#sidebar.collapsed .logo-text,
#sidebar.collapsed .nav-btn span,
#sidebar.collapsed .nav-btn em,
#sidebar.collapsed .user-info { display: none; }
#sidebar.collapsed #sidebar-user { justify-content: center; padding: 12px 0; }

#sidebar-logo {
  padding: 18px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.logo-icon { font-size: 28px; }
.logo-text { font-size: 18px; font-weight: 700; color: var(--green); white-space: nowrap; }

#nav-links { flex: 1; padding: 8px 0; overflow-y: auto; }
#nav-links li { margin: 2px 6px; }
.nav-btn {
  width: 100%;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sidebar-text);
  border-radius: 8px;
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  position: relative;
}
.nav-btn:hover { background: var(--surface2); color: var(--text); }
.nav-btn.active { background: var(--sidebar-active); color: #fff; }
.nav-btn em.badge {
  background: var(--danger);
  color: #fff;
  border-radius: 12px;
  font-size: 11px;
  font-style: normal;
  padding: 1px 6px;
  margin-left: auto;
}

#sidebar-user {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--border);
}
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 600;
  flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; overflow: hidden; }
.user-info strong { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info span { font-size: 11px; color: var(--text-dim); }

/* MAIN */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* TOPBAR */
#topbar {
  height: var(--topbar-h);
  background: var(--topbar-bg);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#sidebar-toggle { font-size: 20px; color: var(--text-dim); padding: 4px 8px; border-radius: 6px; }
#sidebar-toggle:hover { background: var(--surface2); color: var(--text); }
#page-title { font-size: 17px; font-weight: 600; flex: 1; }
#topbar-right { display: flex; align-items: center; gap: 8px; }
.btn-icon { font-size: 18px; padding: 6px; border-radius: 6px; color: var(--text-dim); }
.btn-icon:hover { background: var(--surface2); color: var(--text); }
.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
.status-dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }

/* PAGE CONTAINER */
#page-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* PAGE SECTIONS */
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* CARDS */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
}
.card-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  margin-bottom: 14px;
  font-weight: 600;
}

/* STAT CARDS */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-card .stat-icon { font-size: 28px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--text); }
.stat-card .stat-label { font-size: 12px; color: var(--text-dim); }
.stat-card .stat-change { font-size: 12px; color: var(--green); }
.stat-card .stat-change.down { color: var(--danger); }

/* GRID HELPERS */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.col-span-2 { grid-column: span 2; }

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  transition: opacity 0.15s, transform 0.1s;
  cursor: pointer;
  border: none;
}
.btn:hover { opacity: 0.88; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--green); color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #111; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

/* INPUTS */
.field-group { margin-bottom: 16px; }
.field-group label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }
.input-field, .select-field, .textarea-field {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s;
  outline: none;
}
.input-field:focus, .select-field:focus, .textarea-field:focus {
  border-color: var(--green);
}
.textarea-field { resize: vertical; min-height: 80px; }

/* TABLES */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { background: var(--surface2); padding: 10px 14px; text-align: left; color: var(--text-dim); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
.data-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface2); }
.table-wrap { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); overflow-x: auto; }

/* BADGES / PILLS */
.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.pill-green { background: rgba(37,211,102,0.15); color: var(--green); }
.pill-red { background: rgba(241,92,109,0.15); color: var(--danger); }
.pill-yellow { background: rgba(240,180,41,0.15); color: var(--warning); }
.pill-blue { background: rgba(52,183,241,0.15); color: var(--info); }
.pill-gray { background: var(--surface2); color: var(--text-dim); }

/* MODAL */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 999;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; animation: fadeIn 0.15s ease; }
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  width: min(560px, 94vw);
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-header h2 { font-size: 17px; font-weight: 600; }
.modal-close { font-size: 22px; color: var(--text-dim); line-height: 1; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

/* TABS */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  border-bottom: 2px solid transparent;
  border-radius: 0;
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--green); border-bottom-color: var(--green); }
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.15s; }

/* SEARCH BOX */
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
}
.search-box input { flex: 1; background: none; border: none; outline: none; color: var(--text); font-size: 13px; }
.search-box span { color: var(--text-dim); }

/* TOAST */
#toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; }
.toast {
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  animation: toastIn 0.25s ease, toastOut 0.25s ease 2.7s forwards;
  max-width: 340px;
  box-shadow: var(--shadow);
}
.toast-success { background: #1a3c2a; border: 1px solid var(--green); color: #7ce8a2; }
.toast-error { background: #3c1a1a; border: 1px solid var(--danger); color: #f9a5af; }
.toast-info { background: #1a2e3c; border: 1px solid var(--info); color: #a5d8f9; }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }

/* PROGRESS BAR */
.progress-bar { height: 6px; border-radius: 3px; background: var(--surface2); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; background: var(--green); transition: width 0.4s ease; }

/* CHAT UI */
#chat-layout { display: flex; height: calc(100vh - var(--topbar-h)); margin: -24px; }
#chat-sidebar { width: 340px; border-right: 1px solid var(--border); display: flex; flex-direction: column; background: var(--surface); flex-shrink: 0; }
#chat-sidebar-header { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
#contact-list { flex: 1; overflow-y: auto; }
.contact-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; border-bottom: 1px solid var(--border); transition: background 0.1s; }
.contact-item:hover { background: var(--surface2); }
.contact-item.active { background: var(--surface2); }
.contact-info { flex: 1; overflow: hidden; }
.contact-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-preview { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-time { font-size: 11px; color: var(--text-dim); }
#chat-main { flex: 1; display: flex; flex-direction: column; background: var(--bg); }
#chat-header { padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
#chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Ccircle cx='20' cy='20' r='1' fill='%23ffffff08'/%3E%3C/svg%3E"); }
.msg { max-width: 65%; padding: 8px 12px 6px; border-radius: 8px; font-size: 14px; line-height: 1.45; position: relative; }
.msg-in { background: var(--surface); align-self: flex-start; border-radius: 0 8px 8px 8px; }
.msg-out { background: var(--msg-out); color: #111; align-self: flex-end; border-radius: 8px 8px 0 8px; }
.msg-time { font-size: 10px; color: var(--text-dim); text-align: right; margin-top: 4px; }
.msg-out .msg-time { color: #567a60; }
#chat-input-bar { padding: 10px 14px; background: var(--surface); border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
#chat-input { flex: 1; background: var(--surface2); border: 1px solid var(--border); border-radius: 22px; padding: 9px 16px; color: var(--text); font-size: 14px; outline: none; }
#chat-input:focus { border-color: var(--green); }

/* SECTION HEADER */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.section-header h2 { font-size: 20px; font-weight: 600; }
.section-header p { font-size: 13px; color: var(--text-dim); margin-top: 2px; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 3px; }

/* RESPONSIVE */
@media (max-width: 900px) {
  #sidebar { width: 60px; }
  #sidebar .logo-text, #sidebar .nav-btn span, #sidebar .nav-btn em, #sidebar .user-info { display: none; }
  #sidebar-user { justify-content: center; padding: 12px 0; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  #chat-layout { flex-direction: column; }
  #chat-sidebar { width: 100%; height: 220px; }
}
@media (max-width: 600px) {
  #page-container { padding: 12px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}
