@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap');

/* ==========================================================================
   DESIGN SYSTEM & VARIABLES - PROSPECTOR LOCAL
   ========================================================================== */
:root {
  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  /* Harmonious Color Palette (Premium Dark Mode) */
  --bg-app: #0F1117;
  --bg-sidebar: #0B0D12;
  --bg-card: #171A21;
  --bg-card-hover: #1e2530;
  --bg-input: #0F1117;
  --bg-terminal: #0B0D12;
  
  --border-color: #272B36;
  --border-focus: #8B5CF6;
  
  --text-main: #F5F7FA;
  --text-muted: #9CA3AF;
  --text-inverse: #ffffff;
  
  /* Action Colors */
  --color-primary: #8B5CF6;      /* Roxo Principal */
  --color-primary-hover: #7C3AED;/* Roxo Hover */
  --color-success: #10B981;      /* Verde */
  --color-success-hover: #059669;
  --color-warning: #F59E0B;      /* Amarelo */
  --color-warning-hover: #d97706;
  --color-danger: #EF4444;       /* Vermelho */
  --color-danger-hover: #dc2626;
  --color-info: #3B82F6;         /* Azul */
  --color-info-hover: #2563eb;
  
  /* Status Colors */
  --status-new-bg: rgba(56, 189, 248, 0.15);
  --status-new-text: #38bdf8;
  --status-prospect-bg: rgba(139, 92, 246, 0.15);
  --status-prospect-text: #c084fc;
  --status-contacted-bg: rgba(59, 130, 246, 0.15);
  --status-contacted-text: #60a5fa;
  --status-waiting-bg: rgba(245, 158, 11, 0.15);
  --status-waiting-text: #fbbf24;
  --status-responded-bg: rgba(236, 72, 153, 0.15);
  --status-responded-text: #f472b6;
  --status-meeting-bg: rgba(16, 185, 129, 0.15);
  --status-meeting-text: #34d399;
  --status-closed-bg: rgba(16, 185, 129, 0.3);
  --status-closed-text: #10b981;
  --status-nointerest-bg: rgba(107, 114, 128, 0.2);
  --status-nointerest-text: #9ca3af;
  --status-discarded-bg: rgba(239, 68, 68, 0.15);
  --status-discarded-text: #f87171;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 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.4), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
  --shadow-glow: 0 0 15px rgba(139, 92, 246, 0.25);
  
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
}

/* ==========================================================================
   BASE STYLES
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  /* Suporte para scrollbar moderna no Firefox */
  scrollbar-width: thin;
  scrollbar-color: var(--color-primary) var(--bg-app);
}

/* Custom Scrollbar para navegadores Webkit (Chrome, Edge, Safari, Brave, Opera) */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-app);
}

::-webkit-scrollbar-thumb {
  background-color: var(--color-primary);
  border-radius: 9999px;
  border: 2px solid var(--bg-app);
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-primary-hover);
}

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  margin: 0;
  overflow: hidden;
  background-image: 
    radial-gradient(circle at 5% 10%, rgba(139, 92, 246, 0.04) 0%, transparent 35%),
    radial-gradient(circle at 95% 85%, rgba(16, 185, 129, 0.03) 0%, transparent 35%);
}

.app-layout {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 24px;
  flex-shrink: 0;
  height: 100%;
}

.sidebar .logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 5px;
}

.sidebar .logo-icon {
  font-size: 1.8rem;
  filter: drop-shadow(0 0 10px rgba(139, 92, 246, 0.4));
  animation: float 4s ease-in-out infinite;
}

.sidebar h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  background: linear-gradient(135deg, #ffffff 40%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar .tagline {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 400;
  margin-bottom: 25px;
  text-align: left;
}

/* Categorias e Itens de Menu (Vertical) */
.sidebar-menu-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  overflow-y: auto;
  padding-right: 4px;
}

.menu-category {
  font-size: 0.68rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-top: 18px;
  margin-bottom: 8px;
  padding-left: 8px;
  opacity: 0.7;
}

.app-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background-color: transparent;
  border: none;
  padding: 0;
  margin-top: 0;
  box-shadow: none;
  width: 100%;
}

.nav-tab {
  width: 100%;
  justify-content: flex-start;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-tab:hover:not(:disabled):not(.disabled):not(.active) {
  color: var(--text-main);
  background-color: rgba(255, 255, 255, 0.04);
  transform: translateX(4px);
}

.nav-tab.active {
  color: var(--text-inverse);
  background-color: var(--color-primary);
  border-color: rgba(139, 92, 246, 0.1);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.25);
}

.nav-tab.active:not(.sub-item)::after {
  content: '\203A'; /* Seta fina › */
  margin-left: auto;
  font-size: 1.3rem;
  font-weight: 300;
  line-height: 1;
  color: var(--text-inverse);
  opacity: 0.85;
}

/* Submenus Expansíveis */
.submenu {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-left: 14px;
  margin-top: 2px;
  margin-bottom: 6px;
  border-left: 1px solid rgba(255, 255, 255, 0.05);
}

.submenu.collapsed {
  display: none;
}

.nav-tab.sub-item {
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 400;
  border-radius: var(--radius-sm);
}

.nav-tab.sub-item.active {
  color: var(--color-primary);
  font-weight: 600;
  background-color: rgba(139, 92, 246, 0.06);
  border-left: 2px solid var(--color-primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  box-shadow: none;
}

.nav-tab .arrow {
  margin-left: auto;
  font-size: 0.65rem;
  transition: transform 0.2s ease;
  opacity: 0.7;
}

.nav-tab.open .arrow {
  transform: rotate(180deg);
}

/* Itens de Menu Desabilitados */
.nav-tab.disabled,
.nav-tab:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  background-color: transparent !important;
  color: var(--text-muted) !important;
  box-shadow: none !important;
  border-color: transparent !important;
}

.sidebar-footer {
  margin-top: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 15px;
}

/* Área de Conteúdo Principal */
.main-content {
  flex-grow: 1;
  background-color: var(--bg-app);
  padding: 30px;
  overflow-y: auto;
  overflow-x: hidden;
  height: 100%;
  min-width: 0;
}

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

.content-header-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.content-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

/* Breadcrumbs */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.breadcrumb-separator {
  opacity: 0.5;
}

.breadcrumb-item.active {
  color: var(--color-primary);
  font-weight: 500;
}

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

.app-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 25px;
}

/* Tab contents */
.tab-content {
  display: none;
  flex-direction: column;
  gap: 25px;
  animation: fadeIn 0.3s ease;
}

.tab-content.active {
  display: flex;
}

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

/* ==========================================================================
   COMPONENTS: CARD
   ========================================================================== */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 25px;
  box-shadow: var(--shadow-lg);
}

.card-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 12px;
}

/* ==========================================================================
   FORMS & INPUTS
   ========================================================================== */
.form-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 20px;
}

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

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

label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-main);
  letter-spacing: 0.025em;
}

input[type="text"],
input[type="date"],
select,
textarea {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  padding: 10px 14px;
  outline: none;
  transition: all 0.2s ease;
}

input[type="text"]::placeholder,
textarea::placeholder {
  color: #64748b;
}

input[type="text"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--color-primary);
  color: var(--text-inverse);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  background-color: var(--color-primary-hover);
  box-shadow: var(--shadow-glow);
}

.btn-secondary {
  background-color: #334155;
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.btn-secondary:hover {
  background-color: #475569;
}

.btn-warning {
  background-color: var(--color-warning);
  color: #000000;
}
.btn-warning:hover {
  background-color: var(--color-warning-hover);
}

.btn-danger {
  background-color: var(--color-danger);
  color: var(--text-inverse);
}
.btn-danger:hover {
  background-color: var(--color-danger-hover);
}

.btn-success {
  background-color: var(--color-success);
  color: var(--text-inverse);
}
.btn-success:hover {
  background-color: var(--color-success-hover);
}

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

.hidden {
  display: none !important;
}

/* ==========================================================================
   CAPTCHA ALERTA
   ========================================================================== */
.captcha-banner {
  border-left: 5px solid var(--color-warning);
  background-color: rgba(245, 158, 11, 0.06);
  display: flex;
  gap: 20px;
  align-items: flex-start;
  animation: pulse-border 2s infinite alternate;
}

.captcha-icon {
  font-size: 2rem;
}

.captcha-content h3 {
  color: var(--color-warning);
  font-size: 1.1rem;
  margin-bottom: 6px;
}

.captcha-content p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ==========================================================================
   STATUS & PROGRESS
   ========================================================================== */
.status-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.status-badge {
  background-color: rgba(59, 130, 246, 0.1);
  color: #60a5fa;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 9999px;
  border: 1px solid rgba(59, 130, 246, 0.2);
  text-transform: uppercase;
}

.progress-bar-container {
  background-color: rgba(255, 255, 255, 0.03);
  border-radius: 9999px;
  height: 18px;
  position: relative;
  overflow: hidden;
  margin-bottom: 20px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.progress-bar-fill {
  background: linear-gradient(90deg, var(--color-primary) 0%, #60a5fa 100%);
  height: 100%;
  border-radius: 9999px;
  transition: width 0.3s ease;
}

.progress-percentage {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-main);
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

/* ==========================================================================
   TERMINAL LOGS
   ========================================================================== */
.terminal-logs {
  background-color: var(--bg-terminal);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.terminal-header {
  background-color: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  padding: 8px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.terminal-dots {
  display: flex;
  gap: 5px;
}

.terminal-dots .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot.red { background-color: #ef4444; }
.dot.yellow { background-color: #f59e0b; }
.dot.green { background-color: #10b981; }

.terminal-body {
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  scroll-behavior: smooth;
  color: #38bdf8;
}

.log-line {
  word-break: break-all;
}
.log-line.error { color: #f87171; }
.log-line.warning { color: #fbbf24; }
.log-line.success { color: #34d399; }

/* ==========================================================================
   STATS GRID
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 15px;
  margin-bottom: 10px;
}

.stat-card {
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-md);
  padding: 18px 12px;
  text-align: center;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.stat-card:hover {
  transform: translateY(-2px);
  background-color: rgba(255, 255, 255, 0.03);
}

.stat-num {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 2px;
  color: var(--text-main);
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.stat-card.opportunity-high {
  border-color: rgba(16, 185, 129, 0.25);
  background-color: rgba(16, 185, 129, 0.02);
}
.stat-card.opportunity-high .stat-num {
  color: #34d399;
}

/* ==========================================================================
   CRM STATS COMPACT CARD THEMES
   ========================================================================== */
.crm-stats .stat-card {
  padding: 12px 8px;
}
.crm-stats .stat-num {
  font-size: 1.5rem;
}

/* ==========================================================================
   CRM FILTERS PANEL
   ========================================================================== */
.crm-filter-panel {
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding: 20px;
}

.crm-filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 15px;
}

.crm-actions-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  padding-top: 15px;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.checkbox-group input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--color-primary);
}

.crm-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ==========================================================================
   CRM TABLE
   ========================================================================== */
.crm-table-container {
  padding: 15px;
}

.table-scroll {
  overflow-x: auto;
  max-width: 100%;
}

.crm-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.crm-table th,
.crm-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  font-size: 0.88rem;
}

.crm-table th {
  background-color: rgba(255, 255, 255, 0.02);
  font-weight: 600;
  color: var(--text-main);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--border-color);
}

.crm-table tbody tr {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.crm-table tbody tr:hover {
  background-color: rgba(139, 92, 246, 0.06);
  transform: translateY(-0.5px);
}

/* Elementos editáveis na tabela */
.crm-table select,
.crm-table input[type="text"],
.crm-table input[type="date"] {
  font-size: 0.8rem;
  padding: 5px 8px;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  border-radius: 4px;
}

.crm-table select:focus,
.crm-table input:focus {
  border-color: var(--color-primary);
  background-color: var(--bg-input);
}

.crm-table .btn-action-small {
  padding: 4px 8px;
  font-size: 0.75rem;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Badges de Status do Lead */
.status-pill {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-block;
  text-transform: none;
}

.status-new { background-color: var(--status-new-bg); color: var(--status-new-text); }
.status-prospect { background-color: var(--status-prospect-bg); color: var(--status-prospect-text); }
.status-contacted { background-color: var(--status-contacted-bg); color: var(--status-contacted-text); }
.status-waiting { background-color: var(--status-waiting-bg); color: var(--status-waiting-text); }
.status-responded { background-color: var(--status-responded-bg); color: var(--status-responded-text); }
.status-meeting { background-color: var(--status-meeting-bg); color: var(--status-meeting-text); }
.status-closed { background-color: var(--status-closed-bg); color: var(--status-closed-text); }
.status-nointerest { background-color: var(--status-nointerest-bg); color: var(--status-nointerest-text); }
.status-discarded { background-color: var(--status-discarded-bg); color: var(--status-discarded-text); }

/* Badges de Oportunidade */
.opt-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}
.opt-high { background-color: rgba(16, 185, 129, 0.15); color: #34d399; }
.opt-medium { background-color: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.opt-low { background-color: rgba(239, 68, 68, 0.15); color: #f87171; }

.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

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

.cell-actions a,
.cell-actions button {
  text-decoration: none;
  cursor: pointer;
}

/* ==========================================================================
   MESSAGES LAYOUT
   ========================================================================== */
.messages-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 25px;
}

@media (max-width: 900px) {
  .messages-layout {
    grid-template-columns: 1fr;
  }
}

.variables-hint {
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.var-badge {
  background-color: rgba(255, 255, 255, 0.05);
  color: #38bdf8;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  margin-right: 4px;
  margin-top: 4px;
  display: inline-block;
  cursor: pointer;
  transition: background-color 0.2s;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.var-badge:hover {
  background-color: rgba(56, 189, 248, 0.15);
}

.message-cards-grid {
  display: flex;
  flex-direction: column;
  gap: 15px;
  max-height: 550px;
  overflow-y: auto;
  padding-right: 5px;
}

.message-card {
  background-color: rgba(255, 255, 255, 0.015);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.message-card-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.message-card-service {
  font-size: 0.7rem;
  background-color: rgba(59, 130, 246, 0.1);
  color: #60a5fa;
  padding: 3px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.message-card-body {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: pre-wrap;
  background-color: rgba(0, 0, 0, 0.15);
  padding: 10px;
  border-radius: 6px;
  font-family: var(--font-sans);
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.message-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  padding-top: 10px;
}

/* ==========================================================================
   MODAL DIALOGS
   ========================================================================== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.25s ease;
}

.modal-content {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 700px;
  margin: 15px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: modalSlide 0.25s ease;
  max-height: 90vh;
}

@keyframes modalSlide {
  from { transform: translateY(-15px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
}

.close-modal {
  font-size: 1.6rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s;
  line-height: 1;
}
.close-modal:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

.modal-body-scroll {
  padding: 24px;
  overflow-y: auto;
  max-height: 55vh;
}

.form-grid-modal {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 600px) {
  .form-grid-modal {
    grid-template-columns: 1fr;
  }
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Preview area para modal WhatsApp */
.preview-area {
  background-color: var(--bg-terminal);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  padding: 14px;
  font-size: 0.85rem;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow-y: auto;
  font-family: var(--font-sans);
}

/* ==========================================================================
   EXPORT SECTION AND FOOTER
   ========================================================================== */
.export-section {
  background-color: rgba(255, 255, 255, 0.01);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 20px;
}

.download-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.btn-download {
  flex-grow: 1;
  min-width: 180px;
}

.app-footer {
  text-align: center;
  color: #475569;
  font-size: 0.8rem;
  margin-top: 5px;
}

/* ==========================================================================
   SPINNER & MICRO-ANIMATIONS
   ========================================================================== */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--text-inverse);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes pulse-border {
  0% {
    box-shadow: 0 0 5px rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.4);
  }
  100% {
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.35);
    border-color: rgba(245, 158, 11, 0.8);
  }
}

/* ==========================================================================
   RESPONSIVENESS
   ========================================================================== */
@media (max-width: 700px) {
  .app-nav {
    flex-wrap: wrap;
  }
  .nav-tab {
    padding: 8px 12px;
    font-size: 0.85rem;
  }
  .form-row {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  .app-header h1 {
    font-size: 1.8rem;
  }
  .card {
    padding: 20px;
  }
}

/* ==========================================================================
   Fase 4: Estilos de Planilhas e Campanhas
   ========================================================================== */
.planilha-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, border-color 0.2s ease;
  position: relative;
  overflow: hidden;
}
.planilha-card:hover {
  transform: translateY(-3px);
  border-color: rgba(139, 92, 246, 0.4);
}

.planilha-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 12px;
  margin-bottom: 12px;
  gap: 10px;
}

.planilha-card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.3;
}

.planilha-status-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}
.planilha-status-ativa { background-color: rgba(16, 185, 129, 0.15); color: #10b981; }
.planilha-status-pausada { background-color: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.planilha-status-finalizada { background-color: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.planilha-status-arquivada { background-color: rgba(107, 114, 128, 0.2); color: #9ca3af; }

.planilha-card-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}
.planilha-meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.planilha-card-services {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}
.planilha-service-badge {
  font-size: 0.65rem;
  background: rgba(139, 92, 246, 0.08);
  color: #c084fc;
  border: 1px solid rgba(139, 92, 246, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
}

.planilha-card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
  background: rgba(0, 0, 0, 0.15);
  padding: 12px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.02);
}
.planilha-stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
}
.planilha-stat-num {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}
.planilha-stat-num.stat-success { color: #10b981; }
.planilha-stat-num.stat-warning { color: #fbbf24; }
.planilha-stat-num.stat-info { color: #60a5fa; }
.planilha-stat-num.stat-danger { color: #f87171; }

.planilha-stat-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 500;
  letter-spacing: 0.025em;
}

.planilha-card-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 15px;
  margin-top: auto;
}
.planilha-card-actions .btn {
  padding: 8px 12px;
  font-size: 0.78rem;
  border-radius: 6px;
  flex-grow: 1;
}
.planilha-card-actions .btn-open {
  background-color: var(--color-primary);
  color: var(--text-inverse);
}
.planilha-card-actions .btn-open:hover {
  background-color: var(--color-primary-hover);
}

/* ==========================================================================
   ALERTA DE SINCRONIZAÇÃO PENDENTE
   ========================================================================== */
.sync-alert-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid var(--color-warning);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  color: var(--text-main);
  animation: fadeIn 0.3s ease-in-out;
}

.sync-alert-content {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.sync-alert-icon {
  font-size: 1.25rem;
  color: var(--color-warning);
}

.sync-alert-text {
  font-size: 0.95rem;
  line-height: 1.5;
}

.sync-alert-banner .btn-warning {
  background-color: var(--color-warning);
  color: #000000;
  border: none;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  transition: background-color 0.2s ease, transform 0.1s ease;
  white-space: nowrap;
}

.sync-alert-banner .btn-warning:hover {
  background-color: var(--color-warning-hover);
}

.sync-alert-banner .btn-warning:active {
  transform: scale(0.98);
}

.sync-alert-banner.hidden {
  display: none !important;
}
