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

:root {
  --primary: #25D366;
  --primary-dark: #128C7E;
  --danger: #e74c3c;
  --warning: #f39c12;
  --bg: #f0f2f5;
  --card-bg: #ffffff;
  --text: #1a1a2e;
  --text-light: #667781;
  --border: #e0e0e0;
  --sidebar-bg: #202c33;
  --sidebar-text: #aebac1;
  --sidebar-active: #2a3942;
  --header-bg: #1a2329;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

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

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  height: 56px;
  background: var(--header-bg);
  color: white;
  flex-shrink: 0;
}

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

.logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

.logo-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: block;
}

.btn-icon {
  background: transparent;
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s;
}

.btn-icon:hover {
  background: rgba(255,255,255,0.1);
}

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

.subtitle {
  font-size: 13px;
  color: var(--sidebar-text);
}

.status-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.status-badge.ready {
  background: var(--primary);
  color: white;
}

.status-badge.disconnected,
.status-badge.qr {
  background: var(--danger);
  color: white;
  animation: pulse 2s infinite;
}

.status-badge.connecting {
  background: var(--warning);
  color: white;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Layout */
.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 200px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  padding: 16px 0;
  flex-shrink: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  transition: background 0.15s;
}

.nav-item:hover {
  background: var(--sidebar-active);
}

.nav-item.active {
  background: var(--sidebar-active);
  color: white;
  border-left: 3px solid var(--primary);
}

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

/* Content */
.content {
  flex: 1;
  padding: 24px 32px;
  overflow-y: auto;
}

.section {
  max-width: 800px;
}

.section.hidden {
  display: none;
}

.section h2 {
  font-size: 22px;
  margin-bottom: 20px;
  color: var(--text);
}

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

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

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input, .textarea, select.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  background: var(--card-bg);
  transition: border-color 0.15s;
}

.input:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.input-sm {
  width: auto;
  padding: 6px 10px;
  font-size: 13px;
}

.textarea {
  resize: vertical;
  min-height: 100px;
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: var(--card-bg);
  color: var(--text);
  transition: all 0.15s;
  font-family: inherit;
}

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

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

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-secondary {
  background: var(--primary-dark);
  color: white;
  border-color: var(--primary-dark);
}

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 11px;
}

/* Groups multi-select */
.groups-select {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  overflow: hidden;
}

.groups-select .input {
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
}

.groups-list {
  max-height: 180px;
  overflow-y: auto;
  padding: 4px;
}

.group-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

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

.group-item.selected {
  background: #dcf8c6;
}

.group-item input[type="checkbox"] {
  accent-color: var(--primary);
}

.selected-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  min-height: 10px;
}

.selected-groups:empty {
  display: none;
}

.group-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--primary);
  color: white;
  border-radius: 20px;
  font-size: 12px;
}

.group-tag .remove {
  cursor: pointer;
  font-weight: bold;
  margin-left: 4px;
}

.group-tag.draggable {
  cursor: grab;
}

.group-tag.draggable:active {
  cursor: grabbing;
}

.group-tag.dragging {
  opacity: 0.4;
}

.group-tag.drop-target {
  box-shadow: 0 0 0 2px var(--primary);
}

.drag-handle {
  font-size: 10px;
  opacity: 0.6;
  margin-right: 2px;
}

/* Mode toggle */
.mode-toggle {
  display: flex;
  gap: 8px;
}

.mode-toggle .btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Message preview */
.message-preview-toggle {
  margin-top: 6px;
}

.message-preview {
  margin-top: 8px;
  padding: 12px;
  background: #dcf8c6;
  border-radius: var(--radius);
  font-size: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--text-light);
  transition: border-color 0.2s, background 0.2s;
}

.drop-zone.dragover {
  border-color: var(--primary);
  background: #dcf8c620;
}

.drop-zone .link {
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
}

.hint {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

.file-list {
  margin-top: 8px;
}

.file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  font-size: 13px;
}

.file-item .file-name {
  font-weight: 500;
}

.file-item .file-size {
  color: var(--text-light);
  margin-left: 8px;
}

/* Send options */
.send-options {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.or {
  color: var(--text-light);
  font-size: 13px;
}

.schedule-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.schedule-row .input {
  width: auto;
}

/* Queue */
.queue-list .empty {
  color: var(--text-light);
  font-style: italic;
}

.queue-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.queue-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.queue-item-header .date {
  font-weight: 600;
  color: var(--primary-dark);
}

.queue-item-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.queue-item-content {
  font-size: 13px;
  color: var(--text);
  white-space: pre-wrap;
  max-height: 80px;
  overflow: hidden;
  margin-bottom: 8px;
}

.queue-item-actions {
  display: flex;
  gap: 8px;
}

/* Templates grid */
.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.template-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.template-card h3 {
  font-size: 15px;
  margin-bottom: 8px;
}

.template-card .preview {
  font-size: 13px;
  color: var(--text-light);
  max-height: 60px;
  overflow: hidden;
  margin-bottom: 12px;
  white-space: pre-wrap;
}

.template-card .actions {
  display: flex;
  gap: 6px;
}

/* Card */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.card h3 {
  margin-bottom: 16px;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* Table */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table th, .table td {
  padding: 10px 14px;
  text-align: left;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.table th {
  background: var(--bg);
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}

.table td.status-sent {
  color: var(--primary-dark);
  font-weight: 600;
}

.table td.status-error {
  color: var(--danger);
  font-weight: 600;
}

.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  max-width: 400px;
  width: 90%;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 28px;
  color: var(--text-light);
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
}

.modal-content {
  position: relative;
}

.modal-content h2 {
  margin-bottom: 12px;
}

#qr-container {
  margin: 20px auto;
}

#qr-container img {
  max-width: 280px;
  border-radius: var(--radius);
}

/* Profiles */
.profiles-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin-bottom: 24px;
}

.profile-card {
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow);
}

.profile-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  margin: 0 auto 12px;
}

.profile-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.profile-status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-block;
}

.profile-status.ready {
  background: #dcf8c6;
  color: var(--primary-dark);
}

.profile-status.disconnected {
  background: #fde8e8;
  color: var(--danger);
}

.profile-status.qr,
.profile-status.connecting {
  background: #fef3cd;
  color: #856404;
}

.profile-delete {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-light);
  cursor: pointer;
  background: none;
  border: none;
  text-decoration: underline;
}

.profile-delete:hover {
  color: var(--danger);
}

.add-profile {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

#section-profiles {
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
}

#section-profiles h2 {
  text-align: center;
}

#section-profiles .profiles-grid {
  justify-items: center;
}

.current-user {
  font-size: 13px;
  color: var(--primary);
  font-weight: 600;
  margin-right: 8px;
}

/* Loading & Spinner */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  color: var(--text-light);
  font-size: 14px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

.connection-overlay {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

/* Formatting toolbar + Emoji picker */
.textarea-wrapper {
  position: relative;
}

.contenteditable.textarea {
  padding: 10px 12px;
  line-height: 1.5;
}

.format-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  flex-wrap: wrap;
}

.format-toolbar + .textarea-wrapper .textarea {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.fmt-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
  min-width: 30px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.fmt-btn:hover {
  background: var(--bg);
  border-color: var(--border);
}

.fmt-separator {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

.fmt-emoji {
  font-size: 16px;
}

.emoji-picker-container {
  position: absolute;
  z-index: 50;
  margin-top: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  border-radius: 12px;
  overflow: hidden;
}

emoji-picker {
  --background: var(--card-bg);
  --border-color: var(--border);
  --button-active-background: var(--primary);
  --indicator-color: var(--primary);
  --input-border-color: var(--border);
  --input-placeholder-color: var(--text-light);
  --num-columns: 8;
  height: 380px;
  width: 340px;
}

@media (max-width: 768px) {
  emoji-picker {
    width: 100vw;
    max-width: 340px;
  }
}

.btn-mini-refresh {
  background: transparent;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  margin-left: 4px;
  border-radius: 50%;
}
.btn-mini-refresh:hover {
  background: var(--bg);
}

/* Google Places autocomplete */
.pac-container {
  z-index: 10001 !important;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  font-family: inherit;
}
.pac-item {
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
}
.pac-item:hover {
  background: var(--bg);
}

/* Add-on blocks */
.addon-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.addon-block {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.addon-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-weight: 600;
  font-size: 14px;
}

.addon-remove {
  background: transparent;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--text-light);
  cursor: pointer;
  padding: 0 6px;
}

.addon-remove:hover { color: var(--danger); }

/* Quick schedule relative to events */
.quick-event-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
}

.quick-event-card .event-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--primary-dark);
  margin-bottom: 6px;
}

.quick-event-card .quick-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.quick-event-card .quick-btn {
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 12px;
  cursor: pointer;
  color: var(--text);
}

.quick-event-card .quick-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.quick-event-card .custom-offset {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-top: 6px;
  font-size: 12px;
}

.quick-event-card .custom-offset input {
  width: 60px;
  padding: 2px 6px;
}

/* Batch offsets */
.batch-offset-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.batch-offset-row input { flex: none; }

/* Compose split view with live preview */
.compose-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: stretch;
}

.compose-editor { min-width: 0; }
.compose-live-preview {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.compose-live-preview-label {
  font-size: 10px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.compose-live-preview .wa-bubble {
  flex: 1;
  min-height: 100px;
}
@media (max-width: 768px) {
  .compose-split {
    grid-template-columns: 1fr;
  }
}

/* Poll options */
.poll-option-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 4px;
}
.poll-option-row input {
  flex: 1;
}

/* Audio recording */
#btn-record-audio.recording {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
  animation: pulse 1.5s infinite;
}

.audio-recorder,
.audio-preview {
  margin-top: 10px;
  padding: 12px 14px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.audio-recorder {
  border-color: var(--danger);
  background: #fff5f5;
}

.audio-rec-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
}

.audio-rec-icon {
  font-size: 20px;
  animation: pulse 1.5s infinite;
}

.audio-preview .audio-rec-icon {
  animation: none;
}

.audio-rec-timer {
  font-family: monospace;
  font-size: 16px;
  font-weight: 600;
  color: var(--danger);
  margin-left: auto;
  margin-right: 8px;
}

/* Preview modal (message as WhatsApp bubble) */
.preview-modal-content {
  max-width: 520px !important;
  text-align: left !important;
  padding: 24px !important;
}

.preview-meta {
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.preview-meta strong {
  color: var(--text);
}

.wa-bubble {
  background: #dcf8c6;
  padding: 12px 14px;
  border-radius: 12px;
  border-top-right-radius: 2px;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
  margin-bottom: 12px;
  position: relative;
  max-height: 400px;
  overflow-y: auto;
}

.wa-bubble:empty::before {
  content: '(message vide)';
  color: var(--text-light);
  font-style: italic;
}

.preview-attachments {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.preview-attachment {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 8px;
  font-size: 13px;
}

.preview-notes {
  margin-top: 12px;
  padding: 10px 12px;
  background: #fef9e7;
  border-left: 3px solid #f39c12;
  border-radius: 4px;
  font-size: 13px;
  color: #7d6608;
  white-space: pre-wrap;
}

.preview-notes.hidden { display: none; }

/* Tags */
.message-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}

.message-tag {
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  background: var(--primary-dark);
}

.tags-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 40px;
}

.tags-selector:empty::before {
  content: 'Aucun tag defini. Cliquez sur "Gerer les tags" pour en creer.';
  color: var(--text-light);
  font-size: 12px;
  font-style: italic;
}

.tag-pill {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  color: white;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.15s, transform 0.15s;
  user-select: none;
}

.tag-pill:hover {
  opacity: 0.85;
}

.tag-pill.selected {
  opacity: 1;
  transform: scale(1.05);
  box-shadow: 0 0 0 2px rgba(0,0,0,0.15);
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 14px;
  color: white;
  font-size: 13px;
}

.tag-item .tag-delete {
  background: rgba(255,255,255,0.3);
  border: none;
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.tag-item .tag-delete:hover {
  background: rgba(255,255,255,0.5);
}

/* Contenteditable message area */
.contenteditable {
  min-height: 100px;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-y: auto;
  max-height: 280px;
  outline: none;
  cursor: text;
}

.contenteditable:empty::before {
  content: attr(data-placeholder);
  color: var(--text-light);
  pointer-events: none;
}

.mention-chip {
  display: inline-block;
  padding: 1px 8px;
  background: #e3f2fd;
  color: #1565c0;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  margin: 0 1px;
  white-space: nowrap;
  user-select: all;
}

.mention-chip::before {
  content: '@';
}

/* Mention autocomplete dropdown */
.mention-dropdown {
  position: absolute;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  max-height: 220px;
  overflow-y: auto;
  min-width: 240px;
  z-index: 30;
}

.mention-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  flex-direction: column;
}

.mention-item:hover,
.mention-item.active {
  background: var(--bg);
}

.mention-item .m-name { font-weight: 500; }
.mention-item .m-number { font-size: 11px; color: var(--text-light); }

/* Filter panel */
.filter-panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
}

.filter-panel .filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 8px;
}

.filter-panel .filter-row:last-child { margin-bottom: 0; }

.filter-panel label {
  font-size: 11px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-right: 8px;
}

.filter-tags-chips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* Utilities */
.hidden {
  display: none !important;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #c5c5c5;
  border-radius: 3px;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  color: white;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  animation: slideIn 0.3s ease;
  max-width: 360px;
}

.toast.success { background: var(--primary-dark); }
.toast.error { background: var(--danger); }
.toast.info { background: #3498db; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============================
   MOBILE RESPONSIVE (< 768px)
   ============================ */
@media (max-width: 768px) {
  /* Header */
  .header {
    padding: 0 10px;
    height: 52px;
    gap: 6px;
  }

  .logo {
    display: none; /* hide text, keep icon only on mobile */
  }

  .logo-icon {
    width: 32px;
    height: 32px;
  }

  .header-left {
    gap: 8px;
    flex: 1;
    min-width: 0;
  }

  .header-right {
    gap: 6px;
    flex-shrink: 0;
  }

  .current-user {
    display: inline-block !important;
    font-size: 14px;
    color: white;
    font-weight: 600;
    margin: 0;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .status-badge {
    font-size: 10px;
    padding: 3px 8px;
  }

  .btn-icon {
    width: 34px;
    height: 34px;
    font-size: 18px;
  }

  /* Sidebar -> bottom nav bar */
  .main-layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex-direction: row;
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 100;
    padding: 0;
    justify-content: space-around;
    height: 56px;
    border-top: 1px solid var(--sidebar-active);
  }

  .nav-item {
    flex-direction: column;
    gap: 2px;
    padding: 8px 4px;
    font-size: 10px;
    text-align: center;
    flex: 1;
    justify-content: center;
  }

  .nav-item.active {
    border-left: none;
    border-top: 2px solid var(--primary);
  }

  .nav-icon {
    font-size: 20px;
  }

  /* Content */
  .content {
    padding: 16px;
    margin-bottom: 60px;
  }

  .section {
    max-width: 100%;
  }

  .section h2 {
    font-size: 18px;
    margin-bottom: 14px;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  /* Forms */
  .form-group label {
    font-size: 11px;
  }

  .input, .textarea, select.input {
    font-size: 14px;
    padding: 10px;
  }

  /* Send options */
  .send-options {
    flex-direction: column;
    align-items: stretch;
  }

  .or {
    text-align: center;
  }

  .schedule-row {
    flex-direction: column;
  }

  .schedule-row .input {
    width: 100%;
  }

  /* Queue items */
  .queue-item-actions {
    flex-wrap: wrap;
  }

  .queue-item-actions .btn {
    flex: 1;
    text-align: center;
  }

  /* Templates grid */
  .templates-grid {
    grid-template-columns: 1fr;
  }

  /* Filters */
  .filters {
    flex-direction: column;
  }

  .filters .input,
  .filters select {
    width: 100%;
  }

  /* Table */
  .table th, .table td {
    padding: 8px 6px;
    font-size: 11px;
  }

  /* Modal */
  .modal-content {
    max-width: 95%;
    padding: 20px 16px;
  }

  #qr-container img {
    max-width: 220px;
  }

  /* Profiles */
  #section-profiles {
    margin: 40px auto 0;
    min-height: auto;
    padding: 0 16px;
  }

  .profiles-grid {
    gap: 12px;
  }

  .profile-card {
    padding: 16px 12px;
    min-width: 120px;
  }

  .profile-avatar {
    width: 44px;
    height: 44px;
    font-size: 20px;
  }

  .add-profile {
    flex-direction: column;
    width: 100%;
  }

  .add-profile .input {
    max-width: 100% !important;
    width: 100% !important;
  }

  /* Connection overlay */
  .connection-overlay .loading {
    font-size: 13px;
    padding: 14px;
  }

  /* Toast */
  .toast-container {
    left: 8px;
    right: 8px;
    top: 8px;
  }

  .toast {
    max-width: 100%;
    font-size: 13px;
  }

  /* Drop zone */
  .drop-zone {
    padding: 16px;
  }
}
