@import url('https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap');
:root {
  --bg: #f3f6fb;
  --bg2: #ffffff;
  --bg3: #eef3fa;
  --surface: #edf2f9;
  --surface2: #e3ebf6;
  --border: #d8e2ef;
  --border2: #c4d3e6;
  --accent: #25d366;
  --accent2: #1ba857;
  --accent3: #128c7e;
  --blue: #2563eb;
  --amber: #d97706;
  --red: #dc2626;
  --text: #1f2a37;
  --text2: #516274;
  --text3: #718096;
  --mono: 'DM Mono', monospace;
  --sans: 'Syne', sans-serif;
  --radius: 12px;
  --sidebar-width: 240px;
}

* {
  box-sizing: border-box;
  font-family: "Open Sans", sans-serif;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #f5f8fd 0%, #eff4fb 100%);
  color: var(--text);
}

.layout-shell {
  min-height: 100vh;
}

.sidebar-fixed {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: #f7fbff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 10px;
  box-shadow: 8px 0 24px rgba(38, 68, 104, 0.06);
  z-index: 1000;
}

.logo-wrap {
  padding: 6px 10px 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.logo-title {
  color: var(--accent3);
  font-size: 18px;
  font-weight: 800;
  text-decoration: none;
}

.logo-subtitle {
  margin: 2px 0 0;
  color: var(--text3);
  font-size: 10px;
  letter-spacing: 0.4px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 4px;
}

.nav-section {
  color: var(--text3);
  font-size: 10px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 10px 10px 6px;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text2);
  border-radius: 10px;
  padding: 9px 10px;
  margin-bottom: 2px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

.sidebar-nav .nav-link i {
  font-size: 15px;
}

.sidebar-nav .nav-link:hover {
  background: var(--surface);
  color: var(--text);
}

.sidebar-nav .nav-link.active {
  background: #dff7e7;
  color: #0f5132;
  border: 1px solid #b7ebc8;
}

.status-bar {
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding: 12px 10px 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.status-text {
  color: var(--text3);
  font-size: 11px;
}

.content-shell {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.content-header {
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(4px);
  padding: 18px 24px;
}

.content-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
}

.content-header p {
  margin: 4px 0 0;
  color: var(--text3);
  font-size: 11px;
}

.content-body {
  padding-left: 24px;
  padding-right: 24px;
}

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(15, 42, 70, 0.06);
}

.card-header {
  background: #f7faff;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

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

.stat-card {
  min-height: 128px;
}

.display-6 {
  font-weight: 800 !important;
  letter-spacing: -0.5px;
}

.form-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text2);
  margin-bottom: 6px;
}

.form-control,
.form-select,
textarea.form-control {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 9px;
  font-size: 13px;
}

.form-control:focus,
.form-select:focus,
textarea.form-control:focus {
  background: #fff;
  border-color: #85b4ff;
  box-shadow: 0 0 0 0.22rem rgba(37, 99, 235, 0.1);
}

.form-check-label,
small,
.text-muted {
  color: var(--text3) !important;
}

.btn {
  border-radius: 9px;
  font-weight: 700;
  font-size: 12px;
}

.btn-primary {
  background: #2563eb;
  border-color: #2563eb;
}

.btn-primary:hover {
  background: #1e4fc2;
  border-color: #1e4fc2;
}

.btn-success {
  background: var(--accent);
  border-color: var(--accent);
  color: #0f172a;
}

.btn-success:hover {
  background: var(--accent2);
  border-color: var(--accent2);
  color: #0f172a;
}

.table {
  margin-bottom: 0;
  font-size: 13px;
}

.table thead th {
  background: var(--surface);
  color: var(--text2);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border);
}

.table > :not(caption) > * > * {
  border-color: var(--border);
}

.table tbody tr:hover td {
  background: #f9fbff;
}

.badge {
  border-radius: 99px;
  font-size: 10px;
  padding: 5px 8px;
}

.alert {
  border-radius: 10px;
  border: 1px solid transparent;
}

@media (max-width: 991.98px) {
  .sidebar-fixed {
    position: static;
    width: 100%;
    height: auto;
  }

  .content-shell {
    margin-left: 0;
  }

  .content-header,
  .content-body {
    padding-left: 14px;
    padding-right: 14px;
  }
}

.template-meta-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 11px;
}

#preview-template-name {
  color: var(--text);
  font-weight: 700;
}

.wa-preview-light {
  background: #e7f8ee;
  border-radius: 12px;
  padding: 14px;
  border: 1px solid #bfe8ce;
}

.wa-label-light {
  font-size: 10px;
  color: #197a4d;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.wa-bubble-light {
  background: #ffffff;
  border: 1px solid #d6ecd9;
  border-radius: 7px 14px 14px 14px;
  padding: 10px 12px;
  max-width: 100%;
  box-shadow: 0 3px 10px rgba(0, 64, 32, 0.06);
}

.wa-header-light {
  font-size: 12px;
  font-weight: 700;
  color: #1a3a2c;
  margin-bottom: 6px;
}

.wa-body-light {
  font-size: 13px;
  color: #1f2a37;
  line-height: 1.45;
  white-space: pre-wrap;
}

.wa-footer-light {
  margin-top: 7px;
  font-size: 11px;
  color: #6b7b87;
}

.wa-meta-light {
  font-size: 10px;
  color: #248a5a;
  margin-top: 5px;
  text-align: right;
}

.var-tag {
  display: inline-block;
  background: #fff4d6;
  color: #b45309;
  border: 1px solid #f8d58b;
  border-radius: 5px;
  padding: 0 5px;
  font-size: 11px;
}

#campaign-preview-body {
  white-space: pre-wrap;
  line-height: 1.45;
}

.wa-image-wrap {
  margin-bottom: 8px;
}

.wa-image {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #d6ecd9;
}

.wa-mobile-frame {
  width: 40%;
  min-width: 260px;
  margin: 0 auto;
  background: #101827;
  border-radius: 26px;
  padding: 10px 10px 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.wa-mobile-notch {
  width: 92px;
  height: 7px;
  border-radius: 999px;
  background: #293446;
  margin: 0 auto 10px;
}

.wa-preview-buttons {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.wa-btn-chip {
  border: 1px solid #b8dfc4;
  background: #f2fff6;
  color: #0f5132;
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 10px;
}

@media (max-width: 1199.98px) {
  .wa-mobile-frame {
    width: 55%;
  }
}

@media (max-width: 767.98px) {
  .wa-mobile-frame {
    width: 100%;
    min-width: 0;
  }
}

/* ===================== Bidirectional Chat / Messages UI ===================== */
.chat-shell {
  display: flex;
  height: calc(100vh - 148px);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(15, 42, 70, 0.09);
  background: #fff;
}

/* Contact list */
.chat-contacts {
  width: 300px;
  min-width: 260px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: #f7fbff;
  flex-shrink: 0;
}

.chat-contacts-header {
  display: flex;
  align-items: center;
  padding: 13px 16px;
  font-size: 13px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  background: #edf4ff;
  color: var(--text);
}

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

.chat-contact-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
  cursor: pointer;
}

.chat-contact-item:hover  { background: #e6f0ff; color: var(--text); }
.chat-contact-item.active {
  background: #dff7e7;
  color: var(--text);
  border-left: 3px solid var(--accent);
}

.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-avatar-lg { width: 44px; height: 44px; font-size: 15px; }

.chat-contact-info   { flex: 1; min-width: 0; }
.chat-contact-phone  { font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-contact-preview {
  font-size: 11px;
  color: var(--text3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.chat-contact-time { font-size: 10px; color: var(--text3); flex-shrink: 0; }

/* Main chat area */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #ece5dd;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.chat-header-phone  { font-weight: 700; font-size: 14px; }
.chat-header-status { font-size: 11px; color: var(--accent3); }

/* Messages scroll area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* Bubble rows */
.chat-bubble-row  { display: flex; }
.row-in  { justify-content: flex-start; }
.row-out { justify-content: flex-end; }

/* Bubbles */
.chat-bubble {
  max-width: 64%;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.bubble-in {
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-bottom-left-radius: 4px;
  color: #1f2a37;
}
.bubble-out {
  background: #dcf8c6;
  border: 1px solid #c3e8a8;
  border-bottom-right-radius: 4px;
  color: #1a3a1a;
}

.bubble-source { font-size: 10px; color: var(--accent3); font-weight: 700; margin-bottom: 3px; }
.bubble-text   { font-size: 13px; }
.bubble-meta   {
  font-size: 10px;
  color: #8a8a8a;
  margin-top: 4px;
  text-align: right;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
}
.badge-source {
  background: rgba(0,0,0,0.07);
  border-radius: 4px;
  padding: 1px 4px;
  font-size: 9px;
}

/* Input area */
.chat-input-area {
  background: #f0f0f0;
  border-top: 1px solid var(--border);
  padding: 10px 16px;
}
.chat-input-form { display: flex; align-items: flex-end; gap: 10px; }
.chat-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 13px;
  resize: none;
  outline: none;
  background: #fff;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.4;
  color: var(--text);
  transition: border-color 0.2s;
}
.chat-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(37,211,102,0.15); }

.chat-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.1s;
}
.chat-send-btn:hover  { background: var(--accent2); transform: scale(1.06); }
.chat-send-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.chat-send-status { font-size: 11px; margin-top: 5px; }

/* Placeholder / empty states */
.chat-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text3);
  text-align: center;
  padding: 40px;
}
.chat-placeholder i { font-size: 52px; margin-bottom: 16px; color: #c0cfe0; }

.chat-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text3);
  text-align: center;
}
.chat-no-messages {
  text-align: center;
  color: var(--text3);
  font-size: 12px;
  padding: 30px;
  background: rgba(255,255,255,0.6);
  border-radius: 10px;
  margin: auto;
}

/* Responsive */
@media (max-width: 767.98px) {
  .chat-shell { flex-direction: column; height: auto; }
  .chat-contacts { width: 100%; min-width: 0; max-height: 240px; }
  .chat-messages { min-height: 320px; }
}
/* ===================== Login Page ===================== */
.login-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 10%, rgba(14, 165, 233, 0.2) 0%, rgba(14, 165, 233, 0) 40%),
    radial-gradient(circle at 90% 85%, rgba(16, 185, 129, 0.16) 0%, rgba(16, 185, 129, 0) 40%),
    linear-gradient(180deg, #f8fbff 0%, #eef4fb 100%);
}

.login-shell {
  min-height: 100vh;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  background: #ffffff;
  border: 1px solid #dbe5f1;
  border-radius: 18px;
  padding: 30px 28px;
  box-shadow: 0 14px 34px rgba(30, 58, 111, 0.12);
}

.login-card-top {
  margin-bottom: 20px;
}

.login-kicker {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.5px;
  font-weight: 800;
  text-transform: uppercase;
  color: #0c4a6e;
}

.login-heading {
  margin: 0;
  font-size: 31px;
  line-height: 1.2;
  color: #0f172a;
  font-weight: 800;
}

.login-subtext {
  margin: 9px 0 0;
  color: #64748b;
  font-size: 13px;
}

.login-form .form-label {
  font-size: 12px;
  font-weight: 700;
  color: #1f2937;
}

.login-input {
  border-radius: 10px;
  border-color: #d2ddec;
  background: #ffffff;
  padding: 11px 12px;
}

.login-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.14);
}

.login-btn {
  border-radius: 10px;
  font-size: 13px;
  letter-spacing: 0.2px;
  padding: 12px 14px;
}

@media (max-width: 991.98px) {
  .login-shell {
    max-width: 500px;
    padding: 16px;
  }
}

@media (max-width: 575.98px) {
  .login-shell {
    padding: 10px;
  }

  .login-card {
    border-radius: 14px;
    padding: 22px 18px;
  }

  .login-heading {
    font-size: 25px;
  }
}
