/* Gupshup Middleware Dashboard — Base Styles */
:root {
  --primary: #25D366;
  --primary-dark: #128C7E;
  --secondary: #075E54;
  --bg: #f0f2f5;
  --card-bg: #fff;
  --text: #1a1a2e;
  --text-muted: #6c757d;
  --border: #dee2e6;
  --danger: #dc3545;
  --warning: #ffc107;
  --success: #198754;
  --info: #0dcaf0;
  --sidebar-w: 240px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ── Layout ─────────────────────────────────────────────────── */
.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--secondary);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-brand {
  padding: 20px 16px;
  font-size: 16px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-brand .brand-icon { font-size: 22px; }

.sidebar-nav { padding: 12px 0; flex: 1; }

.nav-section {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.45);
  padding: 16px 16px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  border-radius: 0;
  transition: background 0.15s;
}

.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,0.12);
  color: #fff;
}

.nav-link .icon { width: 18px; text-align: center; font-size: 15px; }

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--card-bg);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar h1 { font-size: 18px; font-weight: 600; }

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.page-body { padding: 24px; flex: 1; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 20px;
}

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

.card-title { font-size: 15px; font-weight: 600; }

/* ── Stat Tiles ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-tile {
  background: var(--card-bg);
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}

.stat-icon.green  { background: #d1fae5; color: var(--primary-dark); }
.stat-icon.blue   { background: #dbeafe; color: #1d4ed8; }
.stat-icon.orange { background: #ffedd5; color: #c2410c; }
.stat-icon.purple { background: #ede9fe; color: #6d28d9; }

.stat-value { font-size: 22px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: #f8f9fa;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:hover td { background: #fafafa; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}

.badge-success  { background: #d1fae5; color: #065f46; }
.badge-warning  { background: #fef3c7; color: #92400e; }
.badge-danger   { background: #fee2e2; color: #991b1b; }
.badge-info     { background: #dbeafe; color: #1e40af; }
.badge-secondary{ background: #f1f5f9; color: #475569; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: opacity 0.15s;
}

.btn:hover { opacity: 0.88; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-secondary { background: #6c757d; color: #fff; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-outline   { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-sm        { padding: 4px 10px; font-size: 12px; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }

input[type=text], input[type=email], input[type=password],
input[type=tel], input[type=number], select, textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,211,102,0.12);
}

/* ── Chat UI ─────────────────────────────────────────────────── */
.chat-layout { display: grid; grid-template-columns: 300px 1fr; gap: 0; height: calc(100vh - 130px); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }

.chat-sidebar { border-right: 1px solid var(--border); overflow-y: auto; }

.chat-contact {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.chat-contact:hover, .chat-contact.active { background: #f0fdf4; }

.chat-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: 16px;
  flex-shrink: 0;
}

.chat-contact-info .name { font-weight: 600; font-size: 14px; }
.chat-contact-info .last-msg { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }

.chat-main { display: flex; flex-direction: column; }

.chat-header { padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 600; }

.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: #ece5dd; }

.msg-bubble {
  max-width: 65%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.45;
  position: relative;
}

.msg-bubble.inbound  { background: #fff; align-self: flex-start; border-bottom-left-radius: 2px; }
.msg-bubble.outbound { background: #dcf8c6; align-self: flex-end;  border-bottom-right-radius: 2px; }

.msg-meta { font-size: 11px; color: var(--text-muted); margin-top: 3px; text-align: right; }

.chat-input-bar { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 10px; background: #f0f2f5; }

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

/* ── Alert ───────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 13px; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
