/* ═══════════════════════════════════════════════════════════════
   FUNIL CONVERT RK — Dashboard CSS
   Design: Dark mode premium com glassmorphism e gradientes
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-glass: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --blue: #3b82f6;
  --blue-glow: rgba(59, 130, 246, 0.25);
  --purple: #8b5cf6;
  --purple-glow: rgba(139, 92, 246, 0.25);
  --green: #10b981;
  --green-glow: rgba(16, 185, 129, 0.25);
  --orange: #f59e0b;
  --orange-glow: rgba(245, 158, 11, 0.25);
  --red: #ef4444;
  --red-glow: rgba(239, 68, 68, 0.25);
  --cyan: #06b6d4;
  --cyan-glow: rgba(6, 182, 212, 0.25);
  --yellow: #eab308;
  --yellow-glow: rgba(234, 179, 8, 0.25);

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ═══════════════ LOGIN ═══════════════ */

.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: 
    radial-gradient(ellipse at 20% 50%, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 50%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
    var(--bg-primary);
}

.login-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
  animation: fadeInUp 0.5s ease-out;
}

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

.login-logo {
  text-align: center;
  margin-bottom: 36px;
}

.logo-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.login-logo h1 {
  font-size: 1.6rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-logo p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 4px;
}

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

.input-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input-group input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: var(--font);
  transition: var(--transition);
  outline: none;
}

.input-group input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-glow);
}

.btn-primary {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px var(--blue-glow);
}

.btn-primary:active { transform: translateY(0); }

.error-msg {
  color: var(--red);
  font-size: 0.85rem;
  text-align: center;
  margin-top: 12px;
  min-height: 20px;
}

/* ═══════════════ DASHBOARD ═══════════════ */

.dashboard {
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 10% 10%, rgba(59, 130, 246, 0.05) 0%, transparent 40%),
    radial-gradient(ellipse at 90% 90%, rgba(139, 92, 246, 0.04) 0%, transparent 40%),
    var(--bg-primary);
}

/* ── Header ── */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.logo-sm { font-size: 28px; }

.header-left h1 {
  font-size: 1.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

.select-periodo {
  padding: 8px 14px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
}

.select-periodo option { background: var(--bg-secondary); }

.user-badge {
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: 6px 14px;
  background: var(--bg-glass);
  border-radius: 20px;
  border: 1px solid var(--border);
}

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
}

.btn-ghost:hover {
  border-color: var(--red);
  color: var(--red);
}

/* ── Metrics Cards ── */

.metrics-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  padding: 24px 32px;
}

.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}

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

.card-blue::before   { background: linear-gradient(90deg, var(--blue), var(--cyan)); }
.card-purple::before { background: linear-gradient(90deg, var(--purple), var(--blue)); }
.card-green::before  { background: linear-gradient(90deg, var(--green), var(--cyan)); }
.card-orange::before { background: linear-gradient(90deg, var(--orange), var(--yellow)); }
.card-cyan::before   { background: linear-gradient(90deg, var(--cyan), var(--blue)); }
.card-yellow::before { background: linear-gradient(90deg, var(--yellow), var(--orange)); }

.card-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.card-value {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
}

.card-sub {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ═══════════════ FUNIL VISUAL ═══════════════ */

.funil-section, .gargalos-section, .leads-section {
  padding: 12px 32px 24px;
}

.funil-section h2, .gargalos-section h2, .leads-section h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.funil-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.funil-step {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  position: relative;
}

.funil-step:hover {
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.03);
}

.funil-step-num {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.funil-step-label {
  flex: 1;
  font-size: 0.92rem;
  font-weight: 500;
}

.funil-step-value {
  font-size: 1.3rem;
  font-weight: 700;
  min-width: 60px;
  text-align: right;
}

.funil-step-bar-container {
  flex: 1;
  max-width: 300px;
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  overflow: hidden;
}

.funil-step-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.funil-step-pct {
  font-size: 0.82rem;
  color: var(--text-muted);
  min-width: 50px;
  text-align: right;
}

/* ═══════════════ GARGALOS ═══════════════ */

.gargalos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.gargalo-card {
  background: var(--bg-card);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius);
  padding: 20px 24px;
  position: relative;
  overflow: hidden;
}

.gargalo-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--red), var(--orange));
}

.gargalo-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--red);
  margin-bottom: 6px;
}

.gargalo-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary);
}

.gargalo-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ═══════════════ TABELA ═══════════════ */

.leads-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.leads-filters {
  display: flex;
  gap: 10px;
}

.select-sm {
  padding: 7px 12px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.82rem;
  cursor: pointer;
  outline: none;
}

.select-sm option { background: var(--bg-secondary); }

.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead {
  background: rgba(255, 255, 255, 0.03);
}

th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

td {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  color: var(--text-primary);
  white-space: nowrap;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

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

/* Tags / Badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-pago     { background: var(--blue-glow); color: var(--blue); }
.badge-organico { background: var(--green-glow); color: var(--green); }
.badge-bot      { background: var(--purple-glow); color: var(--purple); }
.badge-comercial{ background: var(--orange-glow); color: var(--orange); }
.badge-venda    { background: var(--green-glow); color: var(--green); }
.badge-cancel   { background: var(--red-glow); color: var(--red); }
.badge-meta-ok  { background: var(--cyan-glow); color: var(--cyan); }
.badge-meta-no  { background: rgba(100, 116, 139, 0.15); color: var(--text-muted); }
.badge-monitor  { background: var(--yellow-glow); color: var(--yellow); }

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 16px 0;
}

.pagination button {
  padding: 7px 14px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.82rem;
  cursor: pointer;
  transition: var(--transition);
}

.pagination button:hover { border-color: var(--blue); color: var(--blue); }
.pagination button.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.pagination button:disabled { opacity: 0.3; cursor: not-allowed; }

/* Footer */
.footer {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: 24px;
}

/* ═══════════════ RESPONSIVO ═══════════════ */
@media (max-width: 768px) {
  .header { flex-direction: column; gap: 12px; padding: 12px 16px; }
  .header-right { flex-wrap: wrap; justify-content: center; }
  .metrics-cards { padding: 16px; gap: 12px; }
  .funil-section, .gargalos-section, .leads-section { padding: 12px 16px; }
  .funil-step { flex-wrap: wrap; gap: 8px; }
  .funil-step-bar-container { max-width: 100%; order: 10; }
  .leads-header { flex-direction: column; }
}

/* Loading spinner */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading::after {
  content: '';
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}
