/* ==========================================================================
   WHATSAPP AUTOMATION HUB & LIVE CRM - DESIGN SYSTEM
   ========================================================================== */

:root {
  /* DARK THEME (DEFAULT) */
  --bg-app: #0c1317;
  --bg-surface: #111b21;
  --bg-subsurface: #202c33;
  --bg-card: #182229;
  --bg-hover: rgba(255, 255, 255, 0.05);
  --bg-active: rgba(0, 168, 132, 0.12);
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #00a884;

  --text-primary: #e9edef;
  --text-secondary: #8696a0;
  --text-muted: #667781;
  --text-inverse: #111b21;

  --accent-emerald: #00a884;
  --accent-green-bright: #25d366;
  --accent-cyan: #00b4d8;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  --bubble-in: #202c33;
  --bubble-out: #005c4b;
  --bubble-text: #e9edef;

  --tick-grey: #8696a0;
  --tick-blue: #53bdeb;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);

  --font-sans: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* LIGHT THEME */
body.light-theme {
  --bg-app: #eae6df;
  --bg-surface: #ffffff;
  --bg-subsurface: #f0f2f5;
  --bg-card: #f7f9fa;
  --bg-hover: rgba(0, 0, 0, 0.04);
  --bg-active: rgba(0, 168, 132, 0.1);

  --border-color: rgba(0, 0, 0, 0.08);
  --border-focus: #00a884;

  --text-primary: #111b21;
  --text-secondary: #667781;
  --text-muted: #8696a0;
  --text-inverse: #ffffff;

  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
  --bubble-text: #111b21;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* MAIN APPLICATION LAYOUT */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background-color: var(--bg-app);
}

/* 1. LEFT NAVIGATION RAIL */
.nav-rail {
  width: 64px;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  z-index: 50;
  flex-shrink: 0;
}

.nav-brand {
  position: relative;
  margin-bottom: 24px;
}

.brand-logo {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #00a884, #128c7e);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 14px rgba(0, 168, 132, 0.4);
}

.online-indicator {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  background-color: #22c55e;
  border-radius: 50%;
  border: 2px solid var(--bg-surface);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.8);
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.nav-btn {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.nav-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
  transform: scale(1.05);
}

.nav-btn.active {
  background-color: var(--bg-active);
  color: var(--accent-emerald);
}

.nav-btn .badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background-color: var(--accent-green-bright);
  color: #111b21;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.nav-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.theme-toggle {
  font-size: 18px;
}

.user-avatar img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid var(--border-color);
}

/* MAIN VIEWS */
.main-view {
  display: none;
  flex: 1;
  height: 100vh;
  overflow: hidden;
}

.main-view.active {
  display: flex;
}

/* 2. CONTACTS SIDEBAR */
.contacts-sidebar {
  width: 360px;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.header-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-title-row h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: var(--bg-subsurface);
  padding: 8px 12px;
  border-radius: 10px;
  color: var(--text-secondary);
  border: 1px solid transparent;
  transition: var(--transition);
}

.search-box:focus-within {
  border-color: var(--border-focus);
  background-color: var(--bg-card);
}

.search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 13.5px;
  width: 100%;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.filter-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.filter-chips::-webkit-scrollbar {
  display: none;
}

.chip {
  background: var(--bg-subsurface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.chip:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.chip.active {
  background-color: var(--bg-active);
  color: var(--accent-emerald);
  border-color: var(--accent-emerald);
}

/* CONTACT LIST ITEMS */
.contacts-list {
  flex: 1;
  overflow-y: auto;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  position: relative;
}

.contact-item:hover {
  background-color: var(--bg-hover);
}

.contact-item.active {
  background-color: var(--bg-subsurface);
  border-left: 3px solid var(--accent-emerald);
}

.contact-avatar {
  position: relative;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.contact-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background-color: var(--bg-subsurface);
}

.contact-info {
  flex: 1;
  min-width: 0;
}

.contact-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.contact-name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-time {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.contact-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.contact-snippet {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.unread-badge {
  background-color: var(--accent-green-bright);
  color: #111b21;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  flex-shrink: 0;
}

.contact-tags-row {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.tag-pill {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 168, 132, 0.15);
  color: var(--accent-emerald);
}

.tag-pill.tag-vip {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
}

.tag-pill.tag-hot-lead {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
}

/* 3. CHAT CONVERSATION AREA */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-app);
  height: 100vh;
  position: relative;
  overflow: hidden;
}

/* EMPTY STATE */
.chat-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 40px;
  max-width: 520px;
  margin: 0 auto;
}

.empty-illustration {
  position: relative;
  margin-bottom: 24px;
}

.glow-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90px;
  height: 90px;
  background: radial-gradient(circle, rgba(0, 168, 132, 0.25) 0%, transparent 70%);
  border-radius: 50%;
  animation: pulse 3s infinite ease-in-out;
}

@keyframes pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.6; }
  50% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
}

.chat-empty-state h3 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}

.chat-empty-state p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.6;
}

.empty-actions {
  display: flex;
  gap: 12px;
}

/* ACTIVE CHAT WRAPPER */
.chat-wrapper {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
}

.chat-header {
  height: 64px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 10;
}

.chat-contact-info {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
}

.header-details h3 {
  font-size: 15px;
  font-weight: 600;
}

.phone-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mode-pill {
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
}

.pill-simulator {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* MESSAGES CONTAINER */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background-color: var(--bg-app);
  background-image: radial-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 20px 20px;
}

.date-divider {
  align-self: center;
  background-color: var(--bg-surface);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  margin: 10px 0;
}

/* MESSAGE BUBBLE */
.msg-bubble {
  max-width: 65%;
  padding: 8px 12px 6px;
  border-radius: 10px;
  position: relative;
  font-size: 14px;
  line-height: 1.45;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.msg-inbound {
  align-self: flex-start;
  background-color: var(--bubble-in);
  color: var(--text-primary);
  border-top-left-radius: 2px;
}

.msg-outbound {
  align-self: flex-end;
  background-color: var(--bubble-out);
  color: #e9edef;
  border-top-right-radius: 2px;
}

.msg-body {
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.msg-outbound .msg-meta {
  color: rgba(255, 255, 255, 0.6);
}

.msg-ticks svg {
  vertical-align: middle;
}

.tick-sent { color: var(--tick-grey); }
.tick-delivered { color: var(--tick-grey); }
.tick-read { color: var(--tick-blue); }

/* INTERACTIVE BUTTONS CARD */
.interactive-card {
  margin-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.quick-reply-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #00a884;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}

.quick-reply-btn:hover {
  background: rgba(0, 168, 132, 0.2);
  transform: translateY(-1px);
}

/* CANNED RESPONSES BAR */
.canned-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  overflow-x: auto;
}

.canned-bar::-webkit-scrollbar {
  display: none;
}

.canned-label {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

.canned-chip {
  background: var(--bg-subsurface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.canned-chip:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent-emerald);
}

/* CHAT INPUT FOOTER */
.chat-input-footer {
  background-color: var(--bg-surface);
  padding: 10px 16px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.chat-input-footer textarea {
  flex: 1;
  background-color: var(--bg-subsurface);
  border: 1px solid transparent;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  padding: 10px 14px;
  border-radius: 12px;
  outline: none;
  resize: none;
  max-height: 120px;
  line-height: 1.4;
  transition: var(--transition);
}

.chat-input-footer textarea:focus {
  border-color: var(--border-focus);
  background-color: var(--bg-card);
}

.btn-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.btn-send:hover {
  background-color: var(--accent-green-bright);
  transform: scale(1.05);
}

/* 4. CUSTOMER DRAWER */
.customer-drawer {
  width: 320px;
  background-color: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  display: none;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
}

.customer-drawer.open {
  display: flex;
}

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

.drawer-body {
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.drawer-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.drawer-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  margin-bottom: 10px;
  border: 2px solid var(--border-color);
}

.drawer-phone {
  font-size: 13px;
  color: var(--text-secondary);
}

.drawer-section label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.add-tag-row {
  display: flex;
  gap: 6px;
}

.add-tag-row input {
  flex: 1;
  background: var(--bg-subsurface);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-primary);
  outline: none;
}

.drawer-section textarea {
  width: 100%;
  height: 90px;
  background: var(--bg-subsurface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  outline: none;
  resize: none;
}

.save-indicator {
  font-size: 11px;
  color: var(--accent-emerald);
  display: block;
  text-align: right;
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.save-indicator.show {
  opacity: 1;
}

.quick-sim-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-sim-quick {
  background: var(--bg-subsurface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
}

.btn-sim-quick:hover {
  background: var(--bg-hover);
  color: var(--accent-emerald);
  border-color: var(--accent-emerald);
}

/* 5. AUTOMATION STUDIO VIEW */
#view-automations {
  flex-direction: column;
  padding: 32px 40px;
  overflow-y: auto;
}

.studio-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}

.studio-header h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.studio-header .subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

.rule-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  position: relative;
}

.rule-card:hover {
  border-color: rgba(0, 168, 132, 0.4);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.rule-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.rule-name {
  font-size: 16px;
  font-weight: 700;
}

.rule-trigger-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(0, 168, 132, 0.15);
  color: var(--accent-emerald);
}

.rule-keywords-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.kw-badge {
  background: var(--bg-subsurface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
}

.rule-response-box {
  background: var(--bg-card);
  border-left: 3px solid var(--accent-emerald);
  padding: 10px 12px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  max-height: 120px;
  overflow-y: auto;
}

.rule-buttons-preview {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}

.preview-btn-pill {
  background: rgba(0, 168, 132, 0.1);
  border: 1px solid rgba(0, 168, 132, 0.3);
  color: var(--accent-emerald);
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
  text-align: center;
}

.rule-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
  margin-top: auto;
}

/* BUTTONS & CONTROLS */
.btn {
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  transition: var(--transition);
}

.btn-primary {
  background: var(--accent-emerald);
  color: white;
}

.btn-primary:hover {
  background: #009374;
}

.btn-secondary {
  background: var(--bg-subsurface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-icon:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.btn-small {
  padding: 4px 10px;
  font-size: 12px;
  background: var(--bg-subsurface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
}

/* TOGGLE SWITCH */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-subsurface);
  border: 1px solid var(--border-color);
  transition: .3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent-emerald);
  border-color: var(--accent-emerald);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* MODALS */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

.modal-large {
  max-width: 680px;
}

.modal-simulator {
  max-width: 580px;
}

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

.modal-header h3 {
  font-size: 17px;
  font-weight: 700;
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
  background: var(--bg-subsurface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13.5px;
  outline: none;
  transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--border-focus);
  background-color: var(--bg-card);
}

.help-text {
  font-size: 11.5px;
  color: var(--text-muted);
}

.toggle-row {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
}

.notice-box {
  background: rgba(0, 168, 132, 0.1);
  border: 1px solid rgba(0, 168, 132, 0.3);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.5;
}

.notice-box strong {
  color: var(--accent-emerald);
}

.settings-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

.set-tab {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 13.5px;
  padding: 6px 12px;
  cursor: pointer;
  border-radius: 6px;
  transition: var(--transition);
}

.set-tab.active {
  background: var(--bg-active);
  color: var(--accent-emerald);
}

.simulator-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-pill {
  background: var(--bg-subsurface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 16px;
  cursor: pointer;
  transition: var(--transition);
}

.preset-pill:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent-amber);
}

.sim-response-card {
  background: var(--bg-subsurface);
  border: 1px solid var(--accent-emerald);
  padding: 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
}

/* TOAST NOTIFICATIONS */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideUp 0.25s ease-out;
}

.toast-success { border-left: 4px solid var(--accent-emerald); }
.toast-error { border-left: 4px solid var(--accent-rose); }

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* LOGIN OVERLAY */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at center, #111b21 0%, #0c1317 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(8px);
}

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  width: 90%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: slideUp 0.3s ease-out;
}

.login-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 8px;
  background: linear-gradient(135deg, #00a884, #128c7e);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 8px 24px rgba(0, 168, 132, 0.4);
}

.login-card h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.login-sub {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.btn-block {
  width: 100%;
  padding: 12px;
  font-size: 14px;
  justify-content: center;
  margin-top: 10px;
}

.login-error {
  color: var(--accent-rose);
  font-size: 12px;
  font-weight: 600;
  margin-top: 4px;
}
/* ==========================================================================
   ADVANCED SIMULATOR STUDIO & PHONE MOCKUP STYLES
   ========================================================================== */
.modal-simulator-studio {
  max-width: 960px;
  width: 95%;
  height: 88vh;
  max-height: 720px;
}

.simulator-studio-grid {
  display: grid;
  grid-template-columns: 1.15fr 360px;
  gap: 20px;
  padding: 20px;
  height: calc(100% - 64px);
  overflow: hidden;
}

/* LEFT CONTROLS PANEL */
.sim-controls-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding-right: 8px;
}

.sim-toggles-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-subsurface);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.sim-toggle-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  cursor: pointer;
  color: var(--text-secondary);
}

.sim-toggle-pill input:checked + span {
  color: var(--accent-emerald);
  font-weight: 600;
}

.sim-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.sim-count-badge {
  font-size: 11px;
  background: rgba(0, 168, 132, 0.15);
  color: var(--accent-emerald);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

.dynamic-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
  padding: 2px;
}

.preset-card-pill {
  background: var(--bg-subsurface);
  border: 1px solid var(--border-color);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-primary);
  transition: var(--transition);
}

.preset-card-pill:hover {
  background: rgba(0, 168, 132, 0.15);
  border-color: var(--accent-emerald);
  transform: translateY(-1px);
}

.preset-trigger-hint {
  font-size: 10.5px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 1px 5px;
  border-radius: 4px;
}

.sim-input-row {
  display: flex;
  gap: 8px;
}

.sim-input-row textarea {
  flex: 1;
  resize: none;
  font-size: 13px;
}

.btn-sim-send {
  padding: 0 16px;
}

.sim-footer-actions {
  display: flex;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}

.btn-danger-soft {
  background: rgba(244, 63, 94, 0.1);
  color: #f43f5e;
  border: 1px solid rgba(244, 63, 94, 0.25);
}

.btn-danger-soft:hover {
  background: rgba(244, 63, 94, 0.2);
}

/* RIGHT SMARTPHONE DEVICE FRAME */
.sim-phone-frame {
  width: 100%;
  height: 100%;
  background: #0b141a;
  border-radius: 32px;
  border: 5px solid #202c33;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7), inset 0 0 4px rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.phone-notch {
  height: 20px;
  background: #0b141a;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  z-index: 20;
}

.phone-speaker {
  width: 48px;
  height: 4px;
  background: #202c33;
  border-radius: 2px;
}

.phone-cam {
  width: 6px;
  height: 6px;
  background: #111b21;
  border-radius: 50%;
  border: 1px solid #202c33;
}

.phone-wa-header {
  background: #1f2c34;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #e9edef;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.phone-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.phone-back-arrow {
  font-size: 16px;
  color: #aebac1;
}

.phone-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #111b21;
}

.phone-contact-meta {
  display: flex;
  flex-direction: column;
}

.phone-contact-name {
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.wa-check {
  font-size: 11px;
  color: #25d366;
}

.phone-contact-status {
  font-size: 10px;
  color: #8696a0;
}

.phone-header-icons {
  color: #aebac1;
  font-size: 16px;
  cursor: pointer;
}

.phone-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background-color: #0b141a;
  background-image: radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 16px 16px;
}

.phone-bubble {
  max-width: 82%;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.4;
  position: relative;
  word-break: break-word;
}

.phone-bubble-in {
  align-self: flex-start;
  background: #202c33;
  color: #e9edef;
  border-top-left-radius: 2px;
}

.phone-bubble-out {
  align-self: flex-end;
  background: #005c4b;
  color: #e9edef;
  border-top-right-radius: 2px;
}

.phone-bubble-time {
  font-size: 9.5px;
  color: rgba(255, 255, 255, 0.5);
  text-align: right;
  margin-top: 2px;
}

/* INTERACTIVE BUTTONS INSIDE PHONE */
.phone-interactive-box {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 6px;
}

.phone-action-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(0, 168, 132, 0.3);
  color: #00a884;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}

.phone-action-btn:hover {
  background: rgba(0, 168, 132, 0.25);
  color: #25d366;
  transform: scale(1.02);
}

.phone-wa-footer {
  background: #1f2c34;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.phone-wa-footer input {
  flex: 1;
  background: #2a3942;
  border: none;
  color: #e9edef;
  font-size: 12.5px;
  padding: 7px 12px;
  border-radius: 18px;
  outline: none;
}

.phone-send-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #00a884;
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: var(--transition);
}

.phone-send-btn:hover {
  background: #25d366;
}