/**
 * WhatsApp Bot TJ - User Dashboard Styles
 * v1.5.2-beta.1
 * Mobile-First Design
 */

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

:root {
  /* WhatsApp Colors */
  --primary: #25D366;
  --primary-dark: #128C7E;
  --secondary: #075E54;
  --background: #f0f2f5;
  --surface: #ffffff;
  --text: #111b21;
  --text-light: #667781;
  --border: #e9edef;
  --error: #ea0038;
  --success: #00a884;
  --bg: #f0f2f5;
  --bg-secondary: #f5f5f5;

  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Shadow */
  --shadow: 0 1px 3px rgba(11, 20, 26, 0.08);
  --shadow-lg: 0 2px 8px rgba(11, 20, 26, 0.12);

  /* Safe area for notch devices */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
  :root {
    --background: #111b21;
    --surface: #1f2c33;
    --text: #e9edef;
    --text-light: #8696a0;
    --border: #2a3942;
    --bg: #111b21;
    --bg-secondary: #2a3942;
  }
}

html, body {
  height: 100%;
}

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

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

/* ===================== */
/* LOGIN SCREEN          */
/* ===================== */

#login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--secondary) 0%, var(--secondary) 30%, var(--background) 30%);
  padding: var(--spacing-md);
  padding-top: calc(var(--safe-top) + var(--spacing-xl));
}

.login-header {
  text-align: center;
  color: white;
  margin-bottom: var(--spacing-xl);
}

.login-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: var(--spacing-xs);
}

.login-header .version {
  font-size: 0.75rem;
  opacity: 0.8;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.login-card h2 {
  font-size: 1.25rem;
  margin-bottom: var(--spacing-lg);
  text-align: center;
}

/* Form */
.form-group {
  margin-bottom: var(--spacing-md);
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-light);
  margin-bottom: var(--spacing-xs);
}

.form-group input {
  width: 100%;
  padding: var(--spacing-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: var(--surface);
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.15);
}

.form-group input::placeholder {
  color: var(--text-light);
}

/* Buttons */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: var(--spacing-md);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

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

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

.btn-secondary {
  background-color: var(--border);
  color: var(--text);
}

/* Error Message */
.error-message {
  margin-top: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-md);
  background-color: #ffeef0;
  border-radius: var(--radius-sm);
  color: var(--error);
  font-size: 0.875rem;
  text-align: center;
}

/* Remember me */
.form-checkbox {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-lg);
}

.form-checkbox input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.form-checkbox label {
  font-size: 0.875rem;
  color: var(--text-light);
  cursor: pointer;
}

/* ===================== */
/* DASHBOARD SCREEN      */
/* ===================== */

#dashboard-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--safe-bottom);
}

/* Header */
.header {
  background: var(--secondary);
  color: white;
  padding: var(--spacing-md);
  padding-top: calc(var(--safe-top) + var(--spacing-md));
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.menu-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--spacing-xs);
  -webkit-tap-highlight-color: transparent;
}

.header h1 {
  font-size: 1.125rem;
  font-weight: 600;
}

.header-version {
  font-size: 0.625rem;
  opacity: 0.7;
  background: rgba(255, 255, 255, 0.15);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

/* Bot Status Indicator */
.bot-status {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  font-size: 0.75rem;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  cursor: pointer;
}

.bot-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-light);
  animation: pulse 2s infinite;
}

.bot-status.online .bot-status-dot {
  background: #4ade80;
  box-shadow: 0 0 6px #4ade80;
}

.bot-status.offline .bot-status-dot {
  background: #f87171;
  box-shadow: 0 0 6px #f87171;
  animation: none;
}

.bot-status.loading .bot-status-dot {
  background: #fbbf24;
  animation: pulse 1s infinite;
}

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

.bot-status-text {
  color: rgba(255, 255, 255, 0.9);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
}

/* Main Content */
.main-content {
  flex: 1;
  padding: var(--spacing-md);
  overflow-y: auto;
}

/* Welcome Card */
.welcome-card {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  padding: var(--spacing-lg);
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-md);
}

.welcome-card h2 {
  font-size: 1.25rem;
  margin-bottom: var(--spacing-xs);
}

.welcome-card p {
  font-size: 0.875rem;
  opacity: 0.9;
}

/* Bot Power Card */
.bot-power-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--spacing-md) var(--spacing-lg);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--spacing-md);
  border-left: 4px solid var(--error);
  transition: border-color 0.3s;
}

.bot-power-card.active {
  border-left-color: var(--success);
}

.bot-power-info {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.bot-power-icon {
  font-size: 1.5rem;
}

.bot-power-info h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.bot-power-info p {
  font-size: 0.75rem;
  color: var(--text-light);
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
  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;
  transition: 0.3s;
  border-radius: var(--radius-full);
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--success);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(24px);
}

/* Feature Cards */
.feature-grid {
  display: grid;
  gap: var(--spacing-md);
}

.feature-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.feature-card:active {
  transform: scale(0.98);
}

.feature-card:hover {
  box-shadow: var(--shadow-lg);
}

.feature-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.feature-icon.messages {
  background: #e7f8f0;
  color: var(--success);
}

.feature-icon.settings {
  background: #e8f4fd;
  color: #0088cc;
}

.feature-icon.history {
  background: #fef3e7;
  color: #f5a623;
}

.feature-icon.session-history {
  background: #e8eaf6;
  color: #5c6bc0;
}

.feature-info h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: var(--spacing-xs);
}

.feature-info p {
  font-size: 0.875rem;
  color: var(--text-light);
}

.feature-badge {
  margin-left: auto;
  background: var(--error);
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

/* Footer */
.footer {
  padding: var(--spacing-md);
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-light);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* ===================== */
/* SIDEBAR (Mobile)      */
/* ===================== */

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 80vw;
  background: var(--surface);
  z-index: 201;
  transform: translateX(-100%);
  transition: transform 0.3s;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
}

.sidebar.active {
  transform: translateX(0);
}

.sidebar-header {
  background: var(--secondary);
  color: white;
  padding: var(--spacing-lg);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.sidebar-avatar {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1.25rem;
}

.sidebar-name {
  font-weight: 600;
  margin-bottom: var(--spacing-xs);
}

.sidebar-email {
  font-size: 0.875rem;
  opacity: 0.8;
}

.sidebar-menu {
  flex: 1;
  padding: var(--spacing-md) 0;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-md) var(--spacing-lg);
  color: var(--text);
  text-decoration: none;
  transition: background 0.2s;
  cursor: pointer;
}

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

.sidebar-item.active {
  background: #e7f8f0;
  color: var(--primary-dark);
}

.sidebar-item-icon {
  font-size: 1.25rem;
  width: 24px;
  text-align: center;
}

.sidebar-footer {
  padding: var(--spacing-md) var(--spacing-lg);
  border-top: 1px solid var(--border);
}

.logout-btn {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  color: var(--error);
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  padding: var(--spacing-sm) 0;
  width: 100%;
}

/* ===================== */
/* RESPONSIVE            */
/* ===================== */

@media (min-width: 768px) {
  .feature-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .main-content {
    max-width: 800px;
    margin: 0 auto;
    padding: var(--spacing-lg);
  }
}

@media (min-width: 1024px) {
  .feature-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* PWA Install Banner */
.install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  padding: var(--spacing-md);
  padding-bottom: calc(var(--safe-bottom) + var(--spacing-md));
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  z-index: 100;
}

.install-banner p {
  flex: 1;
  font-size: 0.875rem;
}

.install-banner .btn {
  width: auto;
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: 0.875rem;
}

.install-banner .close-btn {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-light);
  cursor: pointer;
}

/* ===================== */
/* SETTINGS SCREEN       */
/* ===================== */

#settings-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--safe-bottom);
}

.back-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--spacing-xs);
  -webkit-tap-highlight-color: transparent;
}

.settings-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow);
}

.settings-card h3 {
  font-size: 1.125rem;
  margin-bottom: var(--spacing-xs);
}

.settings-desc {
  color: var(--text-light);
  font-size: 0.875rem;
  margin-bottom: var(--spacing-lg);
}

.status-message {
  margin-top: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 0.875rem;
}

.status-message.success {
  background: #e7f8f0;
  color: var(--success);
}

.status-message.error {
  background: #ffeef0;
  color: var(--error);
}

/* Phone Saved Box */
.phone-saved-box {
  background: #e7f8f0;
  border: 2px solid var(--success);
  border-radius: var(--radius-md);
  padding: var(--spacing-lg);
  text-align: center;
}

.phone-saved-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  color: var(--success);
  font-weight: 600;
  margin-bottom: var(--spacing-md);
}

.phone-saved-icon {
  width: 24px;
  height: 24px;
  background: var(--success);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
}

.phone-saved-number {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--spacing-lg);
  letter-spacing: 1px;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-light);
}

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

/* ===================== */
/* FORM SELECT           */
/* ===================== */

.form-select {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  padding-right: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23667781' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color 0.2s;
}

.form-select:focus {
  outline: none;
  border-color: var(--primary);
}

.form-select:hover {
  border-color: var(--primary-dark);
}

/* Session Timeout Row */
.session-timeout-row {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.session-timeout-row .session-select {
  flex: 1;
  min-width: 120px;
}

.session-separator {
  color: var(--text-muted);
  font-size: 0.875rem;
  flex-shrink: 0;
}

/* Session Current Value Indicator */
.session-current-value {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--surface-alt, rgba(0,0,0,0.2));
  border-radius: var(--radius-sm);
  margin-bottom: var(--spacing-md);
  border-left: 3px solid var(--primary);
}

.session-current-value .session-label {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.session-current-value .session-value {
  color: var(--primary);
  font-weight: 600;
  font-size: 0.95rem;
}

.session-current-value.saved {
  border-left-color: var(--success, #22c55e);
  animation: flash-success 0.5s ease-out;
}

.session-current-value.saved .session-value {
  color: var(--success, #22c55e);
}

@keyframes flash-success {
  0% { background: var(--success, #22c55e); }
  100% { background: var(--surface-alt, rgba(0,0,0,0.2)); }
}

/* ===================== */
/* SETTINGS ACTIONS      */
/* ===================== */

.settings-actions {
  margin-top: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.settings-actions .btn {
  width: 100%;
}

.settings-card + .settings-card {
  margin-top: var(--spacing-md);
}

/* ===================== */
/* PHONE INPUT GROUP     */
/* ===================== */

.phone-input-group {
  display: flex;
  gap: var(--spacing-sm);
  align-items: stretch;
}

.country-selector {
  position: relative;
  flex-shrink: 0;
}

.country-btn {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-size: 1rem;
  height: 100%;
  min-width: 100px;
}

.country-btn:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.15);
}

.country-flag {
  font-size: 1.25rem;
}

.country-code {
  font-weight: 500;
  color: var(--text);
}

.country-arrow {
  font-size: 0.625rem;
  color: var(--text-light);
  margin-left: auto;
}

.country-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  margin-top: var(--spacing-xs);
  max-height: 250px;
  overflow-y: auto;
}

.country-option {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-md);
  cursor: pointer;
  transition: background 0.15s;
}

.country-option:hover {
  background: var(--background);
}

.country-option.selected {
  background: #e7f8f0;
  color: var(--primary-dark);
}

.phone-input-group input {
  flex: 1;
  min-width: 0;
}

/* ===================== */
/* QR CODE               */
/* ===================== */

.feature-icon.qrcode {
  background: #e8f5e9;
  color: #2e7d32;
}

.qrcode-container {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: var(--spacing-md);
}

.qrcode-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--spacing-xl);
  text-align: center;
  max-width: 350px;
  width: 100%;
  animation: slideUp 0.3s ease;
}

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

.qrcode-box h3 {
  margin-bottom: var(--spacing-md);
  color: var(--secondary);
}

.qrcode-image {
  background: white;
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-md);
  min-height: 256px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qrcode-image img {
  max-width: 100%;
  height: auto;
}

.qrcode-loading {
  color: var(--text-light);
}

.qrcode-error {
  color: var(--error);
  font-size: 0.875rem;
  text-align: center;
  padding: var(--spacing-md);
}

/* QR Code Status */
.qrcode-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-lg);
  text-align: center;
}

.qrcode-status-icon {
  font-size: 3rem;
}

.qrcode-status.connected {
  color: var(--success);
}

.qrcode-status.waiting {
  color: var(--text-light);
}

.qrcode-phone {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--primary-dark);
  margin-bottom: var(--spacing-md);
}

.qrcode-instructions {
  font-size: 0.875rem;
  color: var(--text-light);
  margin-bottom: var(--spacing-lg);
  line-height: 1.6;
}

/* ===================== */
/* WORKFLOW SELECTOR     */
/* ===================== */

/* Workflow Card Icon */
.feature-icon.workflow {
  background: #fff3e0;
  color: #e65100;
}

/* Modal Overlay (Generic) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: var(--spacing-md);
  overflow-y: auto;
}

/* Workflow Modal */
.workflow-modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

.workflow-modal h3 {
  color: var(--secondary);
  margin-bottom: var(--spacing-xs);
}

.modal-subtitle {
  color: var(--text-light);
  font-size: 0.875rem;
  margin-bottom: var(--spacing-lg);
}

/* Workflow Options */
.workflow-options {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.workflow-option {
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  cursor: pointer;
  transition: all 0.2s;
}

.workflow-option:hover:not(.disabled) {
  border-color: var(--primary);
  background: #f0fdf4;
}

.workflow-option.active {
  border-color: var(--primary);
  background: #f0fdf4;
}

.workflow-option.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--background);
}

.workflow-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
}

.workflow-icon {
  font-size: 1.5rem;
}

.workflow-option h4 {
  font-size: 1rem;
  margin: 0;
}

.workflow-badge {
  font-size: 0.625rem;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--border);
  color: var(--text-light);
  margin-left: var(--spacing-xs);
}

.workflow-badge.active {
  background: var(--primary);
  color: white;
}

.workflow-badge.coming-soon {
  background: #fef3c7;
  color: #92400e;
}

.workflow-option p {
  font-size: 0.875rem;
  color: var(--text);
  margin-bottom: var(--spacing-sm);
}

.workflow-option ul {
  font-size: 0.75rem;
  color: var(--text-light);
  margin: 0;
  padding-left: var(--spacing-lg);
}

.workflow-option ul li {
  margin-bottom: 2px;
}

/* Modal Actions */
.modal-actions {
  display: flex;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-lg);
}

.modal-actions .btn {
  flex: 1;
}

/* =============================================
   PENDENTES - Tela de Mensagens (Semi-Automatico)
   v1.5.2-beta.10
   ============================================= */

/* Toggle de filtro por status (beta feature) */
.pendentes-filter-toggle {
  display: flex;
  gap: 6px;
  padding: 8px 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.pendentes-filter-toggle::-webkit-scrollbar {
  display: none;
}

.filter-btn {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border, #333);
  background: var(--bg-secondary, #2a2a2a);
  color: var(--text-light, #9ca3af);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.filter-btn.active {
  background: var(--primary, #25D366);
  color: #fff;
  border-color: var(--primary, #25D366);
}

.filter-btn:hover:not(.active) {
  background: var(--bg-hover, #333);
  color: var(--text, #fff);
}

/* beta feature: multiplephone */
.phone-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.phone-header label {
  margin-bottom: 0;
}

.add-phone-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--primary, #25D366);
  background: transparent;
  color: var(--primary, #25D366);
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.add-phone-btn:hover {
  background: var(--primary, #25D366);
  color: #fff;
}

.phone-row {
  margin-bottom: 6px;
}

.remove-phone-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--danger, #ef4444);
  background: transparent;
  color: var(--danger, #ef4444);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.remove-phone-btn:hover {
  background: var(--danger, #ef4444);
  color: #fff;
}

/* beta feature: mensagempadrao */
.msg-type-selector {
  margin-bottom: 12px;
}

.msg-type-selector label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary, #9ca3af);
}

.msg-type-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.msg-type-pill {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border, #374151);
  background: transparent;
  color: var(--text, #e5e7eb);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.msg-type-pill.active {
  background: var(--primary, #25D366);
  color: #fff;
  border-color: var(--primary, #25D366);
}

.msg-type-pill:hover:not(.active) {
  border-color: var(--primary, #25D366);
  color: var(--primary, #25D366);
}

/* Lista de Pendentes */
.pendentes-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

/* Card de Pendente */
.pendente-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  box-shadow: var(--shadow);
  border-left: 4px solid var(--text-light);
  transition: transform 0.2s, box-shadow 0.2s;
}

.pendente-card:active {
  transform: scale(0.98);
}

.pendente-card.encontrado {
  border-left-color: var(--success);
}

.pendente-card.nao-encontrado {
  border-left-color: #f59e0b;
}

/* Header do Card */
.pendente-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-sm);
}

.pendente-telefone {
  font-weight: 600;
  color: var(--text);
  font-size: 0.95rem;
}

.pendente-tempo {
  font-size: 0.8rem;
  color: var(--text-light);
}

/* Dados Extraidos */
.pendente-dados {
  margin-bottom: var(--spacing-sm);
}

.pendente-linha {
  display: flex;
  gap: var(--spacing-sm);
  margin-bottom: 4px;
  font-size: 0.9rem;
}

.pendente-linha .label {
  color: var(--text-light);
  min-width: 70px;
}

.pendente-linha .valor {
  color: var(--text);
  font-weight: 500;
}

/* Status do Mandado */
.pendente-status {
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: var(--spacing-md);
}

.pendente-status.encontrado {
  background: rgba(0, 168, 132, 0.1);
  color: var(--success);
}

.pendente-status.nao-encontrado {
  background: rgba(245, 158, 11, 0.1);
  color: #d97706;
}

/* Acoes do Card */
.pendente-acoes {
  display: flex;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
}

.btn-acao {
  flex: 1;
  min-width: 70px;
  padding: var(--spacing-sm) var(--spacing-sm);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn-acao:active {
  transform: scale(0.95);
}

.btn-acao.preview {
  background: var(--border);
  color: var(--text);
}

.btn-acao.aprovar {
  background: var(--success);
  color: white;
}

.btn-acao.editar {
  background: var(--primary-dark);
  color: white;
}

.btn-acao.rejeitar {
  background: var(--error);
  color: white;
}

/* Estado Vazio */
.empty-state {
  text-align: center;
  padding: var(--spacing-xl) var(--spacing-md);
  color: var(--text-light);
}

.empty-state .empty-icon {
  font-size: 4rem;
  display: block;
  margin-bottom: var(--spacing-md);
}

.empty-state p {
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: var(--spacing-sm);
}

.empty-state small {
  font-size: 0.85rem;
}

/* Loading State */
.loading-state {
  text-align: center;
  padding: var(--spacing-xl) var(--spacing-md);
  color: var(--text-light);
}

.loading-state .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto var(--spacing-md);
  animation: spin 1s linear infinite;
}

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

/* Botao Refresh */
.refresh-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: var(--spacing-sm);
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

.refresh-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.refresh-btn:active {
  transform: rotate(180deg);
  transition: transform 0.3s;
}

/* Preview Modal */
.preview-modal {
  max-width: 500px;
}

.preview-para {
  color: var(--text-light);
  margin-bottom: var(--spacing-md);
}

.preview-content {
  background: var(--background);
  padding: var(--spacing-md);
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  font-size: 0.9rem;
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: var(--spacing-md);
}

.preview-info {
  font-size: 0.85rem;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

/* Edit Modal */
.edit-modal {
  max-width: 500px;
}

.edit-para {
  color: var(--text-light);
  margin-bottom: var(--spacing-md);
}

.edit-textarea {
  width: 100%;
  padding: var(--spacing-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
  min-height: 150px;
}

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

.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-md);
  cursor: pointer;
  font-size: 0.9rem;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

/* ===================== */
/* CONVERSATIONS SCREEN  */
/* ===================== */

.conversations-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.conversation-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  box-shadow: var(--shadow);
}

.conversation-card:hover {
  background: var(--background);
}

.conversation-card:active {
  transform: scale(0.98);
}

.conversation-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

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

.conversation-name {
  font-weight: 500;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.conversation-preview {
  font-size: 0.875rem;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-preview.from-me::before {
  content: "Voce: ";
  color: var(--text-light);
}

.conversation-meta {
  text-align: right;
  flex-shrink: 0;
}

.conversation-time {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-bottom: 4px;
}

.conversation-badge {
  background: var(--primary);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-block;
}

.btn-remove-pendente {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  margin-top: 4px;
  line-height: 1;
}

.btn-remove-pendente:hover {
  background: var(--error);
  color: white;
}

/* beta feature: finalizada */
.btn-finalizar-pendente {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  margin-top: 4px;
  line-height: 1;
}

.btn-finalizar-pendente:hover {
  background: var(--accent);
  color: white;
}

.pill-finalizada {
  display: inline-block;
  background: #6b7280;
  color: white;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 6px;
}

/* beta feature: operadores */
.pill-operador {
  display: inline-block;
  background: #3b82f6;
  color: white;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 6px;
}

.pendentes-operador-filter {
  padding: 4px 16px 8px;
}

.operador-filter-select {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border, #333);
  background: var(--bg-card, #1e1e1e);
  color: var(--text, #fff);
  font-size: 0.85rem;
}

/* Pendentes V2 - Reutiliza layout conversation-card */
.pendente-badge-found {
  background: var(--success);
}

.pendente-badge-notfound {
  background: #f59e0b;
}

.pendente-mandado-status {
  font-size: 0.75rem;
  font-weight: 500;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pendente-mandado-status.pendente-found {
  color: var(--success);
}

.pendente-mandado-status.pendente-not-found {
  color: #d97706;
}

.preview-from-me {
  color: var(--text-light);
}

/* ===================== */
/* CONVERSATION MODAL    */
/* ===================== */

.conversation-modal {
  width: 100%;
  max-width: 500px;
  height: 85vh;
  max-height: 700px;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.conversation-modal-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-md);
  background: var(--secondary);
  color: white;
}

.conversation-modal-header .back-btn {
  background: transparent;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--spacing-sm);
}

.conversation-contact {
  flex: 1;
}

.conversation-phone {
  display: block;
  font-weight: 600;
  font-size: 1rem;
}

.conversation-count {
  display: block;
  font-size: 0.75rem;
  opacity: 0.8;
}

.conversation-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-md);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  background: #e5ddd5;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d4cfc4' fill-opacity='0.4'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

/* Bolhas de mensagem */
.message-bubble {
  max-width: 85%;
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-sm);
  position: relative;
  word-wrap: break-word;
}

.message-bubble.sent {
  align-self: flex-end;
  background: #dcf8c6;
  color: var(--text);
  border-bottom-right-radius: 4px;
}

.message-bubble.received {
  align-self: flex-start;
  background: white;
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.message-content {
  font-size: 0.9rem;
  line-height: 1.4;
}

.message-time {
  font-size: 0.65rem;
  color: var(--text-light);
  text-align: right;
  margin-top: 2px;
}

.message-bubble.sent .message-time {
  color: #7a9976;
}

/* Mensagem de sistema (tipo documento) */
.message-bubble.system {
  align-self: center;
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-light);
  font-size: 0.8rem;
  padding: var(--spacing-xs) var(--spacing-md);
  border-radius: var(--radius-full);
  max-width: 90%;
}

/* Dark mode - bolhas de mensagem */
@media (prefers-color-scheme: dark) {
  .message-bubble.sent {
    background: #005c4b;
    color: #e9edef;
  }

  .message-bubble.received {
    background: #1f2c33;
    color: #e9edef;
  }

  .message-bubble.sent .message-time {
    color: rgba(255, 255, 255, 0.6);
  }

  .message-bubble.received .message-time {
    color: rgba(255, 255, 255, 0.5);
  }

  .message-bubble.system {
    background: rgba(255, 255, 255, 0.05);
    color: #8696a0;
  }

  .date-separator {
    background: rgba(255, 255, 255, 0.08);
    color: #8696a0;
  }
}

/* Data separator */
.date-separator {
  align-self: center;
  background: rgba(225, 221, 212, 0.9);
  color: var(--text-light);
  font-size: 0.75rem;
  padding: var(--spacing-xs) var(--spacing-md);
  border-radius: var(--radius-sm);
  margin: var(--spacing-sm) 0;
}

/* ===================== */
/* CHAT MODAL            */
/* ===================== */

.chat-modal {
  width: 100%;
  max-width: 500px;
  height: 90vh;
  max-height: 750px;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-md);
  background: var(--primary);
  color: white;
}

.chat-header .back-btn {
  background: transparent;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--spacing-sm);
}

.chat-contact {
  flex: 1;
}

.chat-phone {
  display: block;
  font-weight: 600;
  font-size: 1rem;
}

.chat-status {
  display: block;
  font-size: 0.75rem;
  opacity: 0.85;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-md);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  background: #e5ddd5;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d4cfc4' fill-opacity='0.4'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.chat-loading {
  text-align: center;
  padding: var(--spacing-xl);
  color: var(--text-light);
}

/* Barra de acoes rapidas */
.chat-quick-actions {
  display: flex;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--secondary);
  border-top: 1px solid var(--border);
}

.quick-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.8rem;
  color: var(--text);
}

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

.quick-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.quick-icon {
  font-size: 1rem;
}

.quick-label {
  font-weight: 500;
}

/* Area de input */
.chat-input-area {
  display: flex;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--secondary);
  border-top: 1px solid var(--border);
}

.chat-input-area textarea {
  flex: 1;
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  resize: none;
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--text);
}

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

.send-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: background 0.2s;
}

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

.send-btn:disabled {
  background: var(--text-light);
  cursor: not-allowed;
}

/* =============================================
   INICIAR CONVERSA - Scanner OCR
   ============================================= */

/* Scan Cards */
.scan-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
  box-shadow: var(--shadow);
}

.scan-card label {
  display: block;
  font-size: 0.875rem;
  color: var(--text-light);
  margin-bottom: var(--spacing-sm);
  font-weight: 500;
}

.scan-input-group {
  display: flex;
  gap: var(--spacing-sm);
  align-items: center;
}

.scan-input-group input {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
}

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

.scan-input-full {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  background: var(--background);
  color: var(--text-light);
}

.scan-btn {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: white;
  font-size: 1.25rem;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
  flex-shrink: 0;
}

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

.scan-btn:active {
  transform: scale(0.95);
}

/* Country Selector Mini */
.country-selector-mini {
  position: relative;
}

.country-btn-mini {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.875rem;
}

/* Mandado Status */
.mandado-status {
  margin-top: var(--spacing-sm);
  font-size: 0.875rem;
  min-height: 1.25rem;
}

.mandado-status.found {
  color: var(--success);
}

.mandado-status.not-found {
  color: var(--error);
}

.mandado-status.warning {
  color: #f59e0b;
  font-size: 0.8rem;
  line-height: 1.3;
}

.mandado-status.warning small {
  color: var(--text-light);
}

.mandado-status.loading {
  color: var(--text-light);
}

/* Frases Pre-Prontas */
.frases-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.frase-option {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-sm);
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--surface);
}

.frase-option:has(input:checked) {
  border-color: var(--primary);
  background: rgba(37, 211, 102, 0.05);
}

.frase-option input[type="radio"] {
  margin-top: 2px;
  accent-color: var(--primary);
}

.frase-option span {
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--text);
}

#ic-frase-custom {
  width: 100%;
  margin-top: var(--spacing-sm);
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
  font-size: 0.875rem;
}

#ic-frase-custom:focus {
  outline: none;
  border-color: var(--primary);
}

/* Scan Actions */
.scan-actions {
  margin-top: var(--spacing-lg);
}

.btn-large {
  width: 100%;
  padding: 1rem;
  font-size: 1.1rem;
}

/* Scanner Modal */
.scanner-modal {
  width: 100%;
  max-width: 400px;
  height: auto;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

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

.scanner-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.close-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.scanner-preview {
  position: relative;
  background: black;
  aspect-ratio: 4/3;
  overflow: hidden;
}

.scanner-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-guide {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.guide-box {
  width: 80%;
  height: 60px;
  border: 2px dashed rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-sm);
  background: rgba(37, 211, 102, 0.1);
}

.scanner-guide p {
  color: white;
  margin-top: var(--spacing-sm);
  font-size: 0.875rem;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.scanner-result {
  padding: var(--spacing-md);
  background: var(--background);
  text-align: center;
}

.result-label {
  color: var(--text-light);
  font-size: 0.875rem;
}

.result-value {
  display: block;
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: var(--spacing-xs);
  font-family: monospace;
  color: var(--text);
}

.scanner-actions {
  display: flex;
  gap: var(--spacing-sm);
  padding: var(--spacing-md);
}

.scanner-actions .btn {
  flex: 1;
}

/* Feature Icon - Iniciar Conversa */
.feature-icon.iniciar-conversa {
  background: linear-gradient(135deg, #00a884 0%, #25D366 100%);
}

/* ==================== SESSION HISTORY ==================== */

.session-history-filters {
  padding: var(--spacing-md);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.search-group {
  display: flex;
  gap: var(--spacing-sm);
}

.search-group .form-input {
  flex: 1;
}

.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
}

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

.filter-row {
  display: flex;
  gap: var(--spacing-sm);
}

.form-select-sm {
  padding: 6px 10px;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

.session-history-list {
  padding: 0 var(--spacing-md);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.sh-card {
  cursor: pointer;
  padding: var(--spacing-md);
}

.sh-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-xs);
}

.sh-telefone {
  font-weight: 600;
  color: var(--text);
}

.sh-reason-badge {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 500;
}

.reason-success {
  background: #dcfce7;
  color: #166534;
}

.reason-info {
  background: #dbeafe;
  color: #1e40af;
}

.reason-danger {
  background: #fecaca;
  color: #991b1b;
}

.reason-warning {
  background: #fef3c7;
  color: #92400e;
}

.reason-muted {
  background: var(--secondary-light, #e5e7eb);
  color: var(--text-light);
}

.sh-card-body {
  margin-bottom: var(--spacing-xs);
}

.sh-mandado {
  font-size: 0.9rem;
  color: var(--primary);
  font-family: monospace;
}

.sh-tarefa {
  color: var(--secondary);
  font-weight: 600;
}

.reason-active {
  background: #16a34a;
  color: #fff;
}

.sh-card-active {
  border-left: 3px solid #16a34a;
}

.sh-sub-status {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

.sub-status-noreply {
  color: #dc2626;
}

.sub-status-waiting-me {
  color: #d97706;
}

.sub-status-waiting-person {
  color: #2563eb;
}

.sh-ultima-msg {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sh-nome {
  font-size: 0.85rem;
  color: var(--text-light);
}

.sh-card-footer {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-light);
}

.sh-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-md);
}

.sh-pagination .btn {
  min-width: 80px;
}

#sh-page-info {
  font-size: 0.9rem;
  color: var(--text-light);
}

/* Session Detail Modal */
.session-detail-content {
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
}

.session-detail-content h3 {
  color: var(--text);
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-sm);
  border-bottom: 1px solid var(--border);
}

.session-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-sm);
}

.detail-item {
  padding: var(--spacing-sm);
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

.detail-item label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-light);
  margin-bottom: 2px;
  text-transform: uppercase;
}

.detail-item span {
  display: block;
  font-size: 0.9rem;
  color: var(--text);
  word-break: break-word;
}

.detail-full {
  grid-column: 1 / -1;
}

.loading-text {
  text-align: center;
  padding: var(--spacing-lg);
  color: var(--text-light);
}

/* =============================================
   ANOTAÇÃO - Botão e Modal (beta.50)
   ============================================= */

/* Botão de anotação no card de pendentes */
.btn-anotacao-pendente {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  margin-top: 4px;
  line-height: 1;
}

.btn-anotacao-pendente:hover {
  background: var(--primary);
  color: white;
}

/* Modal de Anotação */
.annotation-modal-content {
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.annotation-modal-content .modal-body {
  padding: var(--spacing-md);
}

.annotation-modal-content .form-group {
  margin-bottom: var(--spacing-md);
}

.annotation-modal-content .form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: var(--spacing-xs);
  font-weight: 500;
}

.annotation-modal-content .form-input {
  width: 100%;
  padding: var(--spacing-sm);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}

.annotation-modal-content .form-input:focus {
  outline: none;
  border-color: var(--primary);
}

.annotation-modal-content textarea.form-input {
  resize: vertical;
  min-height: 150px;
  font-family: inherit;
}

.annotation-modal-content .form-row {
  display: flex;
  gap: var(--spacing-md);
}

.annotation-modal-content .form-group.half {
  flex: 1;
}

.annotation-modal-content .checkbox-group {
  margin-bottom: var(--spacing-md);
}

.annotation-modal-content .checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  cursor: pointer;
  font-size: 0.9rem;
}

.annotation-modal-content .checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.annotation-modal-content .modal-actions {
  display: flex;
  gap: var(--spacing-sm);
  justify-content: flex-end;
  margin-top: var(--spacing-md);
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--border);
}

.annotation-modal-content .btn {
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
}

.annotation-modal-content .btn-secondary {
  background: var(--bg-secondary);
  color: var(--text);
}

.annotation-modal-content .btn-secondary:hover {
  background: var(--border);
}

.annotation-modal-content .btn-primary {
  background: var(--primary);
  color: white;
}

.annotation-modal-content .btn-primary:hover {
  background: var(--primary-dark, #2563eb);
}

.annotation-modal-content .btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Badges de anotação no histórico */
.badge-anotacao {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-anotacao-enviada {
  background: var(--primary);
  color: white;
}

.badge-anotacao-ok {
  background: var(--success);
  color: white;
}

.badge-anotacao-erro {
  background: var(--error);
  color: white;
}

.btn-reenviar {
  padding: 4px 8px;
  background: var(--warning, #f59e0b);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  cursor: pointer;
}

.btn-reenviar:hover {
  opacity: 0.9;
}

.btn-reenviar-detail {
  padding: 6px 12px;
  background: var(--warning, #f59e0b);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  cursor: pointer;
  margin-left: 8px;
}

.btn-reenviar-detail:hover {
  opacity: 0.9;
}

/* Botao de compartilhar sessao */
.btn-share-session {
  padding: 4px 8px;
  background: var(--primary, #075E54);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-share-session:hover {
  opacity: 0.85;
}

.btn-share-session[data-share-id]:not([data-share-id=""]) {
  background: var(--success, #10b981);
}

/* Botao Ver Conversa Completa */
.btn-ver-conversa {
  padding: 4px 8px;
  background: var(--secondary, #075E54);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-ver-conversa:hover {
  opacity: 0.85;
}

/* Modal de Conversa Completa */
.full-conversation-modal {
  width: 100%;
  max-width: 500px;
  height: 80vh;
  background: var(--surface);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.full-conversation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md);
  background: var(--secondary);
  color: white;
}

.full-conv-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#full-conv-telefone {
  font-weight: 600;
  font-size: 1rem;
}

.full-conv-count {
  font-size: 0.75rem;
  opacity: 0.8;
}

.full-conversation-header .close-btn {
  background: transparent;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

.full-conversation-header .close-btn:hover {
  opacity: 0.8;
}

.full-conversation-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-md);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg, #f0f2f5);
}

.full-conv-message {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  max-width: 85%;
  word-break: break-word;
}

.full-conv-message.sent {
  align-self: flex-end;
  background: #dcf8c6;
  border-bottom-right-radius: 4px;
}

.full-conv-message.received {
  align-self: flex-start;
  background: var(--surface);
  border-bottom-left-radius: 4px;
}

.full-conv-msg-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.full-conv-msg-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.full-conv-message.sent .full-conv-msg-label {
  color: var(--primary-dark, #128C7E);
}

.full-conv-message.received .full-conv-msg-label {
  color: var(--secondary, #075E54);
}

.full-conv-msg-time {
  font-size: 0.65rem;
  color: var(--text-light);
}

.full-conv-msg-content {
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text);
  white-space: pre-wrap;
}

/* Dark mode adjustments for full conversation */
@media (prefers-color-scheme: dark) {
  .full-conv-message.sent {
    background: var(--primary-dark, #128C7E);
    color: white;
  }

  .full-conv-message.sent .full-conv-msg-label {
    color: rgba(255, 255, 255, 0.9);
  }

  .full-conv-message.sent .full-conv-msg-content {
    color: white;
  }

  .full-conv-message.sent .full-conv-msg-time {
    color: rgba(255, 255, 255, 0.7);
  }
}

/* Badges de anotacao no card do historico */
.sh-anotacao-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
  align-items: center;
}

/* Secao de detalhes da sessao */
.session-detail-section {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.session-detail-section h4 {
  margin: 0 0 12px 0;
  color: var(--text);
  font-size: 1rem;
}

/* Relato preview */
.relato-preview {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 0.85rem;
  line-height: 1.5;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  font-family: inherit;
  margin: 0;
}

/* Lista de mensagens da sessao */
.session-messages-list {
  max-height: 400px;
  overflow-y: auto;
  padding: 8px 0;
}

.session-message {
  padding: 10px 12px;
  margin: 6px 0;
  border-radius: var(--radius-md);
  background: var(--bg);
  border: 1px solid var(--border);
}

.session-message.sent {
  background: var(--primary-light, #e0f2fe);
  border-color: var(--primary);
  margin-left: 20px;
}

.session-message.received {
  background: var(--bg-secondary, #f5f5f5);
  margin-right: 20px;
}

.session-message-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 0.75rem;
}

.session-message-label {
  font-weight: 600;
  color: var(--text-secondary);
}

.session-message.sent .session-message-label {
  color: var(--primary);
}

.session-message-time {
  color: var(--text-muted);
}

.session-message-content {
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text);
  word-break: break-word;
}

/* ==================== VERSION TIER (CANARY) ==================== */

.feature-icon.version-tier {
  background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
}

.tier-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tier-badge.tier-beta {
  background: #fee2e2;
  color: #dc2626;
}

.tier-badge.tier-pre-release {
  background: #fef3c7;
  color: #d97706;
}

/* Tier Modal */
.tier-modal-content {
  background: var(--surface, #1e1e1e);
  border-radius: var(--radius-lg, 16px);
  padding: var(--spacing-lg, 24px);
  max-width: 420px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.tier-modal-content .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.tier-modal-content .modal-header h3 {
  margin: 0;
  color: var(--text, #fff);
  font-size: 1.1rem;
}

.tier-modal-content .modal-close {
  background: transparent;
  border: none;
  color: var(--text-light, #aaa);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  border-radius: 4px;
}

.tier-modal-content .modal-close:hover {
  background: var(--bg-secondary, #333);
  color: var(--text, #fff);
}

.tier-modal-content .modal-subtitle {
  color: var(--text-light, #9ca3af);
  font-size: 0.85rem;
  margin: 0 0 16px 0;
}

.tier-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.tier-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border: 2px solid var(--border, #333);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-secondary, #2a2a2a);
}

.tier-option:hover {
  border-color: var(--primary, #25D366);
  background: var(--bg-hover, #333);
}

.tier-option input[type="radio"] {
  margin-top: 3px;
  accent-color: var(--primary, #25D366);
  width: 18px;
  height: 18px;
}

.tier-option input[type="radio"]:checked ~ .tier-option-info strong {
  color: var(--primary, #25D366);
}

.tier-option-info {
  flex: 1;
}

.tier-option-info strong {
  display: inline;
  font-size: 0.95rem;
  color: var(--text, #fff);
}

.tier-option-info p {
  margin: 4px 0 0 0;
  font-size: 0.8rem;
  color: var(--text-light, #9ca3af);
}

.tier-label-beta {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 6px;
  background: #fee2e2;
  color: #dc2626;
  vertical-align: middle;
  margin-left: 4px;
}

.tier-version-info {
  font-size: 0.75rem;
  color: var(--text-light, #9ca3af);
  margin-bottom: 12px;
  text-align: center;
}

.tier-modal-content .modal-actions {
  display: flex;
  gap: var(--spacing-sm, 8px);
  margin-top: 16px;
}

.tier-modal-content .modal-actions .btn {
  flex: 1;
  padding: 12px 16px;
  border-radius: var(--radius-sm, 8px);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
}

.tier-modal-content .btn-secondary {
  background: var(--bg-secondary, #2a2a2a);
  color: var(--text, #fff);
  border: 1px solid var(--border, #444);
}

.tier-modal-content .btn-secondary:hover {
  background: var(--bg-hover, #333);
}

.tier-modal-content .btn-primary {
  background: var(--primary, #25D366);
  color: #fff;
}

.tier-modal-content .btn-primary:hover {
  background: var(--primary-dark, #1da851);
}

.tier-modal-content .btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ==================== SERVIDOR ==================== */

.feature-icon.servidor {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

.server-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  background: #e0e7ff;
  color: #4338ca;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.server-badge.beta {
  background: #fef3c7;
  color: #92400e;
}

/* Server Modal */
.server-modal-content {
  max-width: 500px;
  width: 90%;
}

.server-status-grid {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
}

.server-card {
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  transition: border-color 0.2s;
  cursor: pointer;
}

.server-card.active {
  border-color: var(--primary);
  background: rgba(0, 168, 132, 0.05);
}

.server-card-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
}

.server-card-icon {
  font-size: 1.5rem;
}

.server-card-header h4 {
  margin: 0;
  font-size: 1rem;
}

.server-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.server-active-badge {
  margin-left: auto;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  background: #dcfce7;
  color: #166534;
  text-transform: uppercase;
}

.server-card-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.server-detail {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}

.detail-label {
  color: var(--text-muted);
}

.detail-value {
  font-weight: 500;
}

.detail-value.online {
  color: #16a34a;
}

.detail-value.offline {
  color: #dc2626;
}

/* Switch area */
.server-switch-area {
  text-align: center;
  padding: var(--spacing-md) 0;
}

.server-switch-warning {
  margin-top: var(--spacing-sm);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Switch progress */
.server-switch-progress {
  padding: var(--spacing-md);
}

.server-switch-progress h4 {
  margin: 0 0 var(--spacing-md) 0;
  text-align: center;
}

.switch-steps {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.switch-step {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
}

.switch-step.done {
  background: #dcfce7;
}

.switch-step.active {
  background: #fef3c7;
}

.switch-step.error {
  background: #fee2e2;
}

.step-icon {
  font-size: 1.2rem;
  min-width: 24px;
  text-align: center;
}

.step-text {
  font-size: 0.9rem;
}

/* beta feature: blacklist */
.blacklist-add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.blacklist-add-row .form-input {
  flex: 1;
}
.blacklist-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.blacklist-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-radius: 8px;
  font-size: 0.95rem;
}
.btn-remove-blacklist {
  background: none;
  border: none;
  color: #e74c3c;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
