/* ════════════════════════════════════════════════════════════════════
   Pipeline Admin · Estética dark premium (Apple-inspired)
   ════════════════════════════════════════════════════════════════════ */

:root {
  --bg: #000;
  --surface: #0a0a0a;
  --surface-2: #141414;
  --surface-3: #1c1c1e;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f5f5f7;
  --text-muted: #a1a1a6;
  --text-dim: #6e6e73;
  --accent: #2997ff;
  --accent-2: #5e5ce6;
  --accent-3: #bf5af2;
  --green: #30d158;
  --orange: #ff9f0a;
  --red: #ff453a;
  --radius: 14px;
  --radius-sm: 10px;
  --ease: cubic-bezier(0.28, 0.11, 0.32, 1);
  --sidebar-w: 240px;
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ─── LOGIN ───────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at top, rgba(41, 151, 255, 0.08), transparent 60%),
    radial-gradient(ellipse at bottom, rgba(191, 90, 242, 0.06), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 32px;
  text-align: center;
}
.login-logo {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-sub {
  color: var(--text-muted);
  margin-bottom: 32px;
  font-size: 13px;
}
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 12px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s var(--ease);
}
.login-card input:focus { border-color: var(--accent); }
.login-card button {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-weight: 600;
  font-size: 14px;
  transition: transform 0.15s var(--ease), opacity 0.15s var(--ease);
}
.login-card button:hover:not(:disabled) { transform: translateY(-1px); }
.login-card button:disabled { opacity: 0.6; cursor: wait; }
.login-msg {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 16px;
  min-height: 18px;
}
.login-msg.error { color: var(--red); }
.login-msg.success { color: var(--green); }

/* ─── APP LAYOUT ──────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  padding: 8px 12px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-brand span {
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.sidebar-link:hover { background: var(--surface-2); color: var(--text); }
.sidebar-link.active { background: var(--surface-3); color: var(--text); }
.sidebar-link svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-bottom { margin-top: auto; }
.sidebar-user {
  padding: 12px;
  border-top: 1px solid var(--border);
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-user .email { font-size: 12px; color: var(--text-dim); word-break: break-all; }
.sidebar-user button {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  transition: all 0.15s var(--ease);
}
.sidebar-user button:hover { color: var(--red); border-color: var(--red); }

/* ─── MAIN CONTENT ────────────────────────────────────────── */
.main {
  padding: 32px 40px;
  max-width: 1400px;
  width: 100%;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-title { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.page-sub { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* ─── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  transition: transform 0.15s var(--ease), opacity 0.15s var(--ease);
}
.btn:hover { transform: translateY(-1px); }
.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn-danger { background: var(--red); }

/* ─── METRIC CARDS ────────────────────────────────────────── */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
}
.metric-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.metric-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.metric-value.gradient {
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.metric-foot { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* ─── DELTA (vs mes anterior) ─────────────────────────────── */
.delta {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  margin-right: 4px;
}
.delta-up   { background: rgba(48, 209, 88, 0.15); color: var(--green); }
.delta-down { background: rgba(255, 69, 58, 0.15); color: var(--red); }

/* ─── DASHBOARD CARDS ─────────────────────────────────────── */
.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 16px;
}
.dash-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.dash-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.dash-grid-2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 1000px) {
  .dash-grid-2 { grid-template-columns: 1fr; }
}

.chart-wrap {
  position: relative;
  height: 280px;
  width: 100%;
}
.empty-chart {
  height: 200px;
  display: grid;
  place-items: center;
  color: var(--text-dim);
  font-size: 13px;
  font-style: italic;
}

/* ─── PIPELINE BARS ───────────────────────────────────────── */
.pipeline-row { margin-bottom: 14px; }
.pipeline-row:last-child { margin-bottom: 0; }
.pipeline-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.pipeline-count { color: var(--text); font-weight: 600; }
.pipeline-bar {
  height: 8px;
  background: var(--surface-2);
  border-radius: 100px;
  overflow: hidden;
}
.pipeline-fill {
  height: 100%;
  border-radius: 100px;
  transition: width 0.6s var(--ease);
}

/* ─── TABLE ───────────────────────────────────────────────── */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--surface-2);
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 0.15s var(--ease); }
tbody tr:hover { background: var(--surface-2); }
.empty-row {
  text-align: center;
  padding: 40px 20px !important;
  color: var(--text-dim);
}

/* ─── BADGES ──────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.badge-green  { background: rgba(48, 209, 88, 0.15);  color: var(--green); }
.badge-blue   { background: rgba(41, 151, 255, 0.15); color: var(--accent); }
.badge-orange { background: rgba(255, 159, 10, 0.15); color: var(--orange); }
.badge-red    { background: rgba(255, 69, 58, 0.15);  color: var(--red); }
.badge-gray   { background: rgba(255, 255, 255, 0.06); color: var(--text-muted); }

/* ─── MODAL ───────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease);
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  width: min(520px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(10px);
  transition: transform 0.25s var(--ease);
}
.modal-backdrop.open .modal { transform: translateY(0); }
.modal-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.modal-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 20px; }

/* ─── FORM ────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.3px;
}
.field input,
.field textarea,
.field select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s var(--ease);
}
.field input:focus,
.field textarea:focus,
.field select:focus { border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 80px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* ─── TOAST ───────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: 13px;
  z-index: 1000;
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.25s var(--ease);
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast-success { border-left: 3px solid var(--green); }
.toast-error { border-left: 3px solid var(--red); }
.toast-info { border-left: 3px solid var(--accent); }

/* ─── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    gap: 4px;
    overflow-x: auto;
    padding: 12px;
  }
  .sidebar-brand { display: none; }
  .sidebar-bottom { display: none; }
  .sidebar-link { flex-direction: column; gap: 4px; font-size: 11px; padding: 8px 12px; }
  .main { padding: 24px 16px; }
  .field-row { grid-template-columns: 1fr; }
}
