:root {
  --bg-main: #0c0c14;
  --bg-sidebar: #141421;
  --bg-card: rgba(26, 26, 46, 0.7);
  --bg-input: #0f0f1d;
  --accent-primary: #00d2ff;
  --accent-secondary: #3a7bd5;
  --accent-glow: rgba(0, 210, 255, 0.4);
  --text-main: #f0f0f8;
  --text-dim: #94a3b8;
  --border-color: rgba(255, 255, 255, 0.08);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --font-family: 'Outfit', 'Inter', system-ui, sans-serif;
  --glass: rgba(255, 255, 255, 0.03);
  --glass-border: rgba(255, 255, 255, 0.1);
  --sidebar-width: 80px;
  --conv-list-width: 320px;
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-family);
  height: 100vh;
  overflow: hidden;
  line-height: 1.5;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 12px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: var(--font-family);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

input, textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 14px;
  border-radius: 12px;
  font-family: var(--font-family);
  transition: all 0.2s;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(0, 210, 255, 0.15);
}

/* APP LAYOUT - FIXED 100vh */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* SIDEBAR TABS */
.sidebar-tabs {
  width: var(--sidebar-width);
  background: var(--bg-main);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 0;
  gap: 20px;
  flex-shrink: 0;
}

.tab-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--bg-card);
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  color: var(--text-dim);
  border: 1px solid var(--border-color);
}

.tab-icon:hover {
  transform: translateY(-2px);
  background: rgba(255,255,255,0.1);
  color: white;
}

.tab-icon.active {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: white;
  box-shadow: 0 8px 16px var(--accent-glow);
  border: none;
}

/* CONVERSATION LIST */
.conv-list {
  width: var(--conv-list-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

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

.conv-header span {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.btn-master-toggle {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 800;
  border-radius: 8px;
  text-transform: uppercase;
}

.btn-master-toggle.on {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.btn-master-toggle.off {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.conv-items {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.conv-item {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-radius: 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.conv-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.conv-item.active {
  background: rgba(0, 210, 255, 0.08);
  border-color: rgba(0, 210, 255, 0.2);
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, #4f46e5, #3b82f6);
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  font-size: 18px;
}

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

.conv-name {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-last-msg {
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* CHAT AREA - THE CORE FIX */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  min-width: 0;
  position: relative;
}

.chat-header {
  height: 80px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background: rgba(20, 20, 33, 0.8);
  backdrop-filter: blur(12px);
  z-index: 10;
  flex-shrink: 0;
}

.chat-user-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  background: radial-gradient(circle at top right, rgba(0, 210, 255, 0.03), transparent 400px);
}

/* MESSAGE BUBBLES */
.msg {
  max-width: 75%;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.3s ease-out;
}

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

.msg-user { align-self: flex-end; }
.msg-bot, .msg-operator { align-self: flex-start; }

.msg-bubble {
  padding: 14px 20px;
  border-radius: 20px;
  font-size: 15px;
  line-height: 1.6;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.msg-user .msg-bubble {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: white;
  border-bottom-right-radius: 4px;
}

.msg-bot .msg-bubble {
  background: var(--bg-sidebar);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px;
}

.msg-operator .msg-bubble {
  background: rgba(16, 185, 129, 0.1);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-bottom-left-radius: 4px;
}

.msg-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 8px;
  padding: 0 4px;
}

.msg-user .msg-meta { text-align: right; }

/* CHAT CONTROLS - FIXED AT BOTTOM */
.chat-controls {
  padding: 24px 32px;
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
  z-index: 10;
}

.trigger-buttons {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.btn-trigger {
  background: var(--bg-card);
  color: var(--text-main);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--border-color);
  white-space: nowrap;
}

.btn-trigger:hover {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
}

.input-container {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  background: var(--bg-input);
  padding: 8px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  resize: none;
  min-height: 50px;
  max-height: 150px;
  padding: 12px;
  font-size: 15px;
  color: white;
}

.chat-input:focus {
  box-shadow: none;
}

.btn-send {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: white;
  font-size: 20px;
  flex-shrink: 0;
}

.btn-send:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px var(--accent-glow);
}

/* HELPER CLASSES */
.switch-mode-btn {
  background: var(--bg-card);
  color: var(--accent-primary);
  border: 1px solid var(--accent-primary);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
}

.switch-mode-btn:hover {
  background: var(--accent-primary);
  color: white;
}

.mode-badge {
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
.bonum-panel {
  padding: 12px 32px;
  background: rgba(20, 20, 33, 0.4);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  animation: slideDown 0.4s ease-out;
}
@keyframes slideDown {
  from { transform: translateY(-10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.bonum-controls {
  display: flex;
  align-items: center;
  gap: 24px;
}
.bonum-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bonum-field label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
}
.bonum-field select, .bonum-field input {
  background: var(--bg-input);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  border: 1px solid var(--border-color);
  width: 200px;
}
.bonum-field input { width: 100px; }
.bonum-total {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 100px;
}
.bonum-total span { font-size: 10px; color: var(--text-dim); }
.bonum-total strong { font-size: 18px; color: var(--accent-primary); font-weight: 800; }
.btn-bonum-pay {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  padding: 10px 24px;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
  margin-left: auto;
}
.btn-bonum-pay:hover { transform: scale(1.05); box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4); }
.bonum-controls {
  flex-wrap: wrap;
  gap: 16px;
}
.bonum-field select { width: 160px; }
.bonum-field input[type="text"] { min-width: 250px; }
.bonum-total strong { color: #10b981; }
