/* 
  Samtale - Modern Web App Styles
  Using premium CSS variables, flexbox, and smooth aesthetics
*/

:root {
  /* Colors - Light Theme */
  --bg-primary: #f0f2f5;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e9edef;
  
  --brand-primary: #00a884;
  --brand-primary-hover: #008f6f;
  --brand-secondary: #128c7e;
  
  --text-primary: #111b21;
  --text-secondary: #667781;
  --text-inverse: #ffffff;
  
  --border-color: #d1d7db;
  --divider-color: #e9edef;
  
  --msg-out: #d9fdd3;
  --msg-in: #ffffff;
  
  --status-open: #00a884;
  --status-pending: #f5b041;
  --status-closed: #667781;
  
  --danger: #ef4444;
  --danger-hover: #dc2626;

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  
  /* Layout */
  --sidebar-width: 380px;
  --nav-rail-width: 72px;
  --header-height: 60px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  
  /* Transitions */
  --transition-fast: 0.15s ease-in-out;
  --transition-normal: 0.3s ease-in-out;
}

/* Reset & Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  width: 100%;
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
}

input, select, textarea {
  font-family: inherit;
  font-size: 15px;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  color: var(--text-primary);
}

.hidden {
  display: none !important;
}

/* Component Buttons */
.btn-primary {
  background-color: var(--brand-primary);
  color: var(--text-inverse);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-weight: 500;
  transition: background-color var(--transition-fast), transform var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 100px;
}

.btn-primary:hover:not(:disabled) { background-color: var(--brand-primary-hover); }
.btn-primary:active:not(:disabled) { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-weight: 500;
  transition: background-color var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-secondary:hover:not(:disabled) { background-color: #d6dadd; }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text-secondary);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

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

.input-field {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

.input-field:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 2px rgba(0, 168, 132, 0.2);
}

/* App Layout */
.app-container {
  width: 100vw;
  height: 100vh;
  display: flex;
}

.view {
  width: 100%;
  height: 100%;
}

/* --- Login View --- */
#login-view {
  background-color: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  background-image: linear-gradient(180deg, var(--brand-primary) 0%, var(--brand-primary) 30%, var(--bg-primary) 30%, var(--bg-primary) 100%);
}

.login-wrapper {
  animation: slideUp 0.5s ease;
}

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

.login-box {
  background-color: var(--bg-secondary);
  width: 400px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px;
}

.login-brand {
  text-align: center;
  margin-bottom: 30px;
}

.login-brand .logo {
  font-size: 48px;
  margin-bottom: 15px;
  color: var(--brand-primary);
}

.login-brand h1 { font-size: 24px; margin-bottom: 5px; }
.login-brand p { color: var(--text-secondary); font-size: 14px; }

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 2px rgba(0, 168, 132, 0.2);
}

.login-form button {
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  font-size: 16px;
}

.auth-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 15px;
  text-align: center;
  background: #fee2e2;
  padding: 10px;
  border-radius: var(--radius-md);
  border: 1px solid #fca5a5;
}

.login-footer {
  margin-top: 30px;
  text-align: center;
  color: var(--text-secondary);
  border-top: 1px solid var(--divider-color);
  padding-top: 20px;
}

.login-footer p { margin-bottom: 5px; }

/* Spinner */
.loader {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 1s ease-in-out infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --- Dashboard View --- */
#dashboard-view {
  display: flex;
  background-color: var(--bg-primary);
}

/* --- Navigation Rail --- */
.nav-rail {
  width: var(--nav-rail-width);
  background-color: #1f2c33;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  height: 100%;
  flex-shrink: 0;
}

.nav-top, .nav-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
}

.nav-logo {
  font-size: 28px;
  color: var(--brand-primary);
  margin-bottom: 20px;
}

.nav-btn {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #8696a0;
  transition: all var(--transition-fast);
  font-size: 12px;
  position: relative;
}

.nav-btn i { font-size: 22px; }
.nav-btn span { font-size: 10px; font-weight: 500; }

.nav-btn:hover {
  background-color: rgba(255,255,255,0.08);
  color: #e9edef;
}

.nav-btn.active {
  background-color: rgba(0, 168, 132, 0.15);
  color: var(--brand-primary);
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  min-width: 300px;
  background-color: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-color);
  height: 100%;
}

.sidebar-header {
  height: var(--header-height);
  background-color: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--divider-color);
}

.user-profile { display: flex; align-items: center; gap: 12px; }

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #dfe5e7;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 18px;
  flex-shrink: 0;
}

.user-info h2 { font-size: 15px; margin: 0; }
.user-info p { font-size: 12px; color: var(--text-secondary); margin: 0; }

.sidebar-search {
  padding: 10px 14px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--divider-color);
  position: relative;
}

.sidebar-search-icon {
  position: absolute;
  left: 26px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 18px;
  pointer-events: none;
}

.sidebar-search input {
  width: 100%;
  background-color: var(--bg-primary);
  border: none;
  padding: 10px 15px 10px 38px;
  border-radius: var(--radius-md);
}

.sidebar-search input:focus {
  outline: none;
  background-color: white;
  box-shadow: 0 0 0 1px var(--brand-primary);
}

.sidebar-filters {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
}

.sidebar-filters::-webkit-scrollbar { display: none; }

.filter-btn {
  padding: 6px 12px;
  border-radius: 16px;
  background-color: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.filter-btn:hover { background-color: var(--bg-tertiary); }
.filter-btn.active { background-color: var(--brand-primary); color: white; }

.conversation-list {
  flex: 1;
  overflow-y: auto;
  background-color: var(--bg-secondary);
}

.conversation-list::-webkit-scrollbar { width: 6px; }
.conversation-list::-webkit-scrollbar-thumb { background-color: rgba(0,0,0,0.2); border-radius: 10px; }

.conversation-item {
  display: flex;
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--divider-color);
  transition: background-color var(--transition-fast);
}

.conversation-item:hover { background-color: var(--bg-primary); }
.conversation-item.active { background-color: var(--bg-tertiary); }
.conversation-item .avatar { background-color: #bbdefb; color: #1565c0; }

.conversation-details {
  margin-left: 14px;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

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

.conversation-name {
  font-size: 16px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-time {
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
  margin-left: 8px;
}

.conversation-bottom {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.conversation-msg {
  font-size: 14px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.unread-badge {
  background-color: var(--brand-primary);
  color: white;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  padding: 0 6px;
  flex-shrink: 0;
}

.badge {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge.open { background-color: #d1fae5; color: #065f46; }
.badge.pending { background-color: #fef3c7; color: #92400e; }
.badge.closed { background-color: #f3f4f6; color: #374151; }

.platform-mini-icon {
  font-size: 12px;
  font-weight: bold;
  padding: 2px 4px;
  border-radius: 4px;
  color: white;
  margin-right: 2px;
}
.platform-mini-icon.whatsapp { background-color: #25D366; }
.platform-mini-icon.telegram { background-color: #0088cc; }

.loading-spinner {
  margin: 20px auto;
  width: 30px;
  height: 30px;
  border: 3px solid var(--bg-tertiary);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Main Content Wrapper */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background-color: var(--bg-primary);
}

/* Empty State */
.empty-state {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-primary);
  border-bottom: 6px solid var(--brand-primary);
  text-align: center;
  z-index: 10;
}

.empty-state .empty-icon { font-size: 64px; margin-bottom: 20px; opacity: 0.8; color: var(--brand-secondary); }
.empty-state h2 { font-size: 32px; font-weight: 300; color: var(--text-secondary); margin-bottom: 15px; }
.empty-state p { color: var(--text-secondary); font-size: 14px; }
.encryption-notice { margin-top: 40px; font-size: 13px !important; color: #8696a0 !important; display: flex; align-items: center; gap: 6px; }

/* Chat Area */
.chat-area {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  background-image: url('data:image/svg+xml;utf8,<svg width="100" height="100" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><g fill="%23d6dace" fill-opacity="0.4" fill-rule="evenodd"><path d="M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3z"/></g></svg>');
  background-color: var(--bg-primary);
  background-size: 400px;
}

.chat-header {
  height: var(--header-height);
  background-color: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  z-index: 5;
}

.chat-contact-info { display: flex; align-items: center; gap: 15px; }
.chat-contact-info .avatar { width: 44px; height: 44px; }
.contact-details h2 { font-size: 16px; margin-bottom: 2px; }
.contact-details p { font-size: 13px; color: var(--text-secondary); }
.chat-actions { display: flex; align-items: center; gap: 12px; }

.status-badge {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.status-badge.open { border-color: #00a884; color: #00a884; background-color: rgba(0,168,132,0.1); }
.status-badge.pending { border-color: #f5b041; color: #f5b041; background-color: rgba(245,176,65,0.1); }
.status-badge.closed { border-color: #667781; color: #667781; background-color: rgba(102,119,129,0.1); }

.agent-select {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-primary);
  font-size: 13px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-thumb { background-color: rgba(0,0,0,0.2); border-radius: 10px; }

.message-bubble {
  max-width: 65%;
  padding: 8px 12px;
  border-radius: 8px;
  box-shadow: 0 1px 1px rgba(0,0,0,0.1);
  position: relative;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
}

.message-bubble .time {
  font-size: 11px;
  color: var(--text-secondary);
  float: right;
  margin-left: 10px;
  margin-top: 10px;
}

.message-bubble.client { align-self: flex-start; background-color: var(--msg-in); border-top-left-radius: 0; }
.message-bubble.agent { align-self: flex-end; background-color: var(--msg-out); border-top-right-radius: 0; }

.message-sender {
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-secondary);
  margin-bottom: 4px;
  display: block;
}

/* Message Ticks / Status */
.msg-status {
  display: inline-block;
  margin-left: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: bold;
}
.msg-status.read { color: #53bdeb; }
.msg-status.sent::after { content: "✓"; }
.msg-status.delivered::after { content: "✓✓"; }
.msg-status.read::after { content: "✓✓"; }

/* Typing Indicator */
.typing-indicator {
  position: absolute;
  bottom: 70px;
  left: 30px;
  background-color: var(--bg-secondary);
  padding: 8px 14px;
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 10;
}

.typing-indicator .dot {
  width: 6px;
  height: 6px;
  background-color: var(--text-secondary);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-indicator .dot:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator .dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Chat Input Area */
.chat-input-area {
  min-height: 62px;
  background-color: var(--bg-secondary);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.message-form { display: flex; flex: 1; align-items: center; gap: 10px; }

.message-form input {
  flex: 1;
  padding: 12px 20px;
  border-radius: var(--radius-lg);
  border: none;
  background-color: var(--bg-primary);
}

.message-form input:focus {
  outline: none;
  background-color: #ffffff;
  box-shadow: 0 0 0 1px var(--brand-primary);
}

.send-btn { color: var(--text-secondary); }
.message-form input:not(:placeholder-shown) ~ .send-btn { color: var(--brand-primary); }

/* --- Contact Profile Right Sidebar --- */
.contact-profile {
  width: 350px;
  background-color: var(--bg-primary);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-normal);
  z-index: 15;
}

.profile-header {
  height: var(--header-height);
  background-color: var(--bg-secondary);
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-color);
}

.profile-header h2 { font-size: 16px; font-weight: 500; margin-left: 10px; }

.profile-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: var(--bg-secondary);
}

.profile-avatar-large {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background-color: #dfe5e7;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  margin: 30px 0 20px;
}

.profile-content h2 { font-size: 22px; margin-bottom: 5px; }
.profile-content p { color: var(--text-secondary); font-size: 15px; margin-bottom: 20px; }

.profile-actions {
  width: 100%;
  padding: 0 20px 20px;
  border-bottom: 10px solid var(--bg-primary);
  display: flex;
  justify-content: center;
}

.profile-section {
  width: 100%;
  padding: 20px;
  border-bottom: 10px solid var(--bg-primary);
  background-color: var(--bg-secondary);
}

.profile-section h3 { font-size: 14px; color: var(--brand-secondary); margin-bottom: 10px; }

/* --- Panel Areas (Users, Settings, Admin) --- */
.panel-area {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--bg-primary);
  z-index: 20;
  display: flex;
  flex-direction: column;
}

.panel-header {
  height: var(--header-height);
  background-color: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.panel-header h2 {
  font-size: 18px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-content {
  padding: 24px;
  flex: 1;
  overflow-y: auto;
}

/* Data table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.data-table th, .data-table td {
  padding: 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  background-color: #f9fafb;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.05em;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover { background-color: #f9fafb; }

.role-badge {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  background-color: var(--bg-tertiary);
  display: inline-block;
}

.role-badge.admin { background-color: #e0e7ff; color: #4338ca; }
.role-badge.agent { background-color: #d1fae5; color: #065f46; }
.role-badge.superadmin { background-color: #fef3c7; color: #92400e; }

/* --- Settings Tabs --- */
.settings-tabs {
  display: flex;
  gap: 4px;
  background-color: var(--bg-secondary);
  padding: 6px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.settings-tab {
  flex: 1;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.settings-tab:hover { background-color: var(--bg-primary); }

.settings-tab.active {
  background-color: var(--brand-primary);
  color: var(--text-inverse);
}

.settings-tab-content {
  display: none;
  max-width: 800px;
}

.settings-tab-content.active { display: block; }

.settings-section {
  background-color: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.settings-section h3 {
  margin-bottom: 20px;
  color: var(--text-primary);
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.settings-grid .form-group:last-child:nth-child(odd) {
  grid-column: span 2;
}

/* Toggle Switches */
.toggle-group {
  display: flex;
  flex-direction: column;
  gap: 0;
}

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

.toggle-item:last-child { border-bottom: none; }

.toggle-item strong { font-size: 14px; color: var(--text-primary); }
.toggle-item p { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

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

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

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #ccc;
  border-radius: 24px;
  transition: var(--transition-fast);
}

.toggle-slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: var(--transition-fast);
}

.toggle-switch input:checked + .toggle-slider { background-color: var(--brand-primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* --- Connections List --- */
.connections-list { display: flex; flex-direction: column; gap: 12px; }

.connection-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-primary);
}

.connection-info { display: flex; align-items: center; gap: 15px; }

.platform-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: white;
  font-size: 20px;
}

.platform-icon.whatsapp { background-color: #25D366; }
.platform-icon.telegram { background-color: #0088cc; }

.connection-details h4 { font-size: 15px; margin-bottom: 4px; color: var(--text-primary); }
.connection-details p { font-size: 13px; color: var(--text-secondary); }

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 12px;
  background-color: rgba(37, 211, 102, 0.1);
  color: #25D366;
  border: 1px solid rgba(37, 211, 102, 0.2);
}

.status-indicator::before {
  content: "";
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #25D366;
}

/* --- Admin Dashboard --- */
.admin-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.admin-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--border-color);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.admin-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.admin-card-icon {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
  flex-shrink: 0;
}

.card-companies .admin-card-icon { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.card-conversations .admin-card-icon { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.card-messages .admin-card-icon { background: linear-gradient(135deg, #f59e0b, #d97706); }
.card-connections .admin-card-icon { background: linear-gradient(135deg, #10b981, #059669); }

.admin-card-info { display: flex; flex-direction: column; }
.admin-card-value { font-size: 28px; font-weight: 700; color: var(--text-primary); }
.admin-card-label { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

.admin-charts {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.admin-chart-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.admin-chart-card h3 {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-chart-card canvas { width: 100% !important; }

.admin-section {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.admin-section h3 {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- Modal Styles --- */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(11, 20, 26, 0.4);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: var(--bg-secondary);
  width: 90%;
  max-width: 450px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 101;
  animation: scaleIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn {
  from { opacity: 0; transform: translate(-50%, -48%) scale(0.95); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

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

.modal-header h3 { font-size: 18px; }

.modal-form { padding: 24px; }

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

/* Responsiveness */
@media (max-width: 768px) {
  .app-container { flex-direction: column; }
  .nav-rail { display: none; }
  .sidebar { width: 100%; height: 100%; }

  body.chat-active .sidebar { display: none; }
  body.chat-active .main-content { display: flex; }

  .admin-cards { grid-template-columns: repeat(2, 1fr); }
  .admin-charts { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
}
