/* ═══════════════════════════════════════════════════════════════
   ZLAB STUDIO — Dark Dashboard
   Design system: dark, minimal, professional
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg: #0a0a0a;
  --bg2: #111111;
  --bg3: #1a1a1a;
  --bg4: #222222;
  --border: #1e1e1e;
  --border2: #2a2a2a;
  --text: #d4d4d4;
  --text-muted: #666666;
  --white: #ffffff;
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.12);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.12);
  --yellow: #f59e0b;
  --yellow-dim: rgba(245, 158, 11, 0.12);
  --blue: #3b82f6;
  --blue-dim: rgba(59, 130, 246, 0.12);
  --purple: #a855f7;
  --purple-dim: rgba(168, 85, 247, 0.12);
  --orange: #f97316;
  --orange-dim: rgba(249, 115, 22, 0.12);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --sidebar-w: 176px;
  --sidebar-collapsed: 52px;
  --topbar-h: 52px;
}

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

html {
  font-size: 15px;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  color: inherit;
}

input, select, textarea {
  font-family: var(--font);
  background: var(--bg3);
  border: 1px solid #333;
  border-radius: 8px;
  color: var(--text);
  padding: 10px 14px;
  font-size: 0.875rem;
  outline: none;
  width: 100%;
  transition: border-color 0.3s;
}

input:focus, select:focus, textarea:focus {
  border-color: #555;
}

input::placeholder, textarea::placeholder {
  color: var(--text-muted);
}

select {
  cursor: pointer;
  -webkit-appearance: none;
  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='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

textarea {
  resize: vertical;
  min-height: 80px;
}

/* ═══ Topbar ═══ */
#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 200;
}

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

.topbar-logo {
  font-size: 1rem;
  font-weight: 700;
  color: var(--white);
  letter-spacing: 0.04em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color 0.2s, background 0.2s;
}

.topbar-btn:hover {
  color: var(--white);
  background: rgba(255,255,255,0.06);
}

.topbar-time {
  font-family: var(--font-mono);
  font-size: 0.688rem;
  color: var(--text-muted);
  margin-right: 4px;
}

.notif-bell {
  position: relative;
}

.notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  background: var(--red);
  color: var(--white);
  font-size: 0.563rem;
  font-weight: 700;
  border-radius: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.notif-badge:empty, .notif-badge[data-count="0"] {
  display: none;
}

/* ═══ Sidebar ═══ */
#sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--topbar-h));
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  z-index: 100;
  transition: width 0.25s var(--ease);
  overflow: hidden;
}

#sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-toggle-wrap {
  padding: 8px;
  margin-bottom: 4px;
}

.sidebar-toggle-btn {
  width: 100%;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color 0.2s, background 0.2s;
}

.sidebar-toggle-btn:hover {
  color: var(--white);
  background: rgba(255,255,255,0.06);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  overflow-y: auto;
  padding: 0 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  font-size: 0.813rem;
  font-weight: 400;
  color: var(--text-muted);
  transition: color 0.2s, background 0.2s;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
}

.nav-item:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
  color: var(--white);
  background: rgba(255, 255, 255, 0.08);
  font-weight: 500;
}

.nav-svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke-width: 1.75;
}

.nav-label {
  opacity: 1;
  transition: opacity 0.2s;
}

#sidebar.collapsed .nav-label {
  opacity: 0;
  width: 0;
}


.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 12px;
}

.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--border);
  position: relative;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-link:hover {
  color: var(--text);
  background: rgba(255,255,255,0.05);
}

/* Profile button */
.profile-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
  overflow: hidden;
}

.profile-btn:hover {
  background: rgba(255,255,255,0.06);
}

.profile-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 0.688rem;
  font-weight: 700;
  flex-shrink: 0;
}

.profile-info {
  overflow: hidden;
  white-space: nowrap;
}

.profile-name {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--white);
}

.profile-role {
  font-size: 0.625rem;
  color: var(--text-muted);
}

#sidebar.collapsed .profile-info {
  opacity: 0;
  width: 0;
}

/* Profile dropdown */
.profile-dropdown {
  position: absolute;
  bottom: 100%;
  left: 8px;
  right: 8px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.2s, visibility 0.2s, transform 0.2s;
  z-index: 200;
}

.profile-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.profile-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
  cursor: pointer;
  white-space: nowrap;
}

.profile-dropdown-item:hover {
  color: var(--white);
  background: rgba(255,255,255,0.06);
}

.profile-dropdown-item.danger:hover {
  color: var(--red);
}

/* ═══ Sidebar Overlay (mobile) ═══ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  top: var(--topbar-h);
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

.sidebar-overlay.active {
  display: block;
}

/* ═══ Mobile-specific sidebar ═══ */
#mobile-menu-btn span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--white);
  border-radius: 2px;
  transition: transform 0.3s, opacity 0.3s;
}

#mobile-menu-btn.open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

#mobile-menu-btn.open span:nth-child(2) {
  opacity: 0;
}

#mobile-menu-btn.open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ═══ Notification Panel ═══ */
.notif-panel {
  position: fixed;
  top: 60px;
  right: 16px;
  width: 360px;
  max-height: 400px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.03);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s, transform 0.25s var(--ease);
  transform: translateY(-8px);
  overflow-y: auto;
}

.notif-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.notif-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.813rem;
  font-weight: 600;
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--bg2);
}

.notif-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 12px;
  transition: background 0.2s;
  cursor: pointer;
}

.notif-item:hover {
  background: rgba(255, 255, 255, 0.02);
}

.notif-item:last-child {
  border-bottom: none;
}

.notif-item.unread {
  border-left: 3px solid var(--blue);
}

.notif-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.notif-text {
  font-size: 0.813rem;
  color: var(--text);
  line-height: 1.4;
}

.notif-time {
  font-size: 0.688rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ═══ Main ═══ */
#main {
  margin-left: var(--sidebar-w);
  padding: calc(var(--topbar-h) + 24px) 40px 40px;
  flex: 1;
  min-height: 100vh;
  transition: margin-left 0.25s var(--ease);
}

body.sidebar-collapsed #main {
  margin-left: var(--sidebar-collapsed);
}

.stat-value {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* ═══ Views ═══ */
.view {
  display: none;
}

.view.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

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

.view-header h1 {
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--white);
}

.view-date {
  font-size: 0.813rem;
  color: var(--text-muted);
}

.view-header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ═══ KPI / Stat Cards ═══ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stats-3 {
  grid-template-columns: repeat(3, 1fr);
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-left: 4px solid transparent;
  transition: border-color 0.2s, transform 0.15s var(--ease);
}

.stat-card:hover {
  transform: translateY(-1px);
}

.stat-card.green {
  border-left-color: var(--green);
}

.stat-card.blue {
  border-left-color: var(--blue);
}

.stat-card.yellow {
  border-left-color: var(--yellow);
}

.stat-card.red {
  border-left-color: var(--red);
}

.stat-card.purple {
  border-left-color: var(--purple);
}

.stat-card.orange {
  border-left-color: var(--orange);
}

.stat-card.accent {
  border-color: rgba(245, 158, 11, 0.3);
}

.stat-label {
  font-size: 0.688rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #888;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--white);
  font-variant-numeric: tabular-nums;
}

.stat-value.green { color: var(--green); }
.stat-value.red { color: var(--red); }
.stat-value.blue { color: var(--blue); }
.stat-value.yellow { color: var(--yellow); }

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

/* ═══ Funnel Visualization ═══ */
.funnel {
  margin-bottom: 28px;
}

.funnel-stage {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.funnel-stage:last-child {
  border-bottom: none;
}

.funnel-label {
  font-size: 0.813rem;
  color: var(--text-muted);
  min-width: 120px;
  flex-shrink: 0;
}

.funnel-bar-wrap {
  flex: 1;
  position: relative;
}

.funnel-bar {
  height: 36px;
  border-radius: 8px;
  min-width: 40px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  transition: width 0.6s var(--ease);
}

.funnel-count {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--white);
}

/* Funnel stage colors */
.funnel-bar.nuevo { background: var(--bg4); }
.funnel-bar.contactado { background: var(--blue-dim); border: 1px solid rgba(59, 130, 246, 0.2); }
.funnel-bar.cotizado { background: var(--yellow-dim); border: 1px solid rgba(245, 158, 11, 0.2); }
.funnel-bar.negociando { background: var(--purple-dim); border: 1px solid rgba(168, 85, 247, 0.2); }
.funnel-bar.cerrado_ganado { background: var(--green-dim); border: 1px solid rgba(34, 197, 94, 0.2); }
.funnel-bar.cerrado_perdido { background: var(--red-dim); border: 1px solid rgba(239, 68, 68, 0.2); }

/* ═══ Charts ═══ */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 28px;
}

.chart-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.chart-card h3 {
  font-size: 0.813rem;
  font-weight: 600;
  color: var(--white);
  margin-bottom: 16px;
}

/* ═══ Tables ═══ */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  font-size: 0.688rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #888;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 14px 16px;
  font-size: 0.813rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

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

.td-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.td-name {
  font-weight: 500;
  color: var(--white);
}

/* ═══ Badges ═══ */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 0.688rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-nuevo { background: var(--bg4); color: var(--text-muted); }
.badge-contactado { background: var(--blue-dim); color: var(--blue); }
.badge-cotizado { background: var(--yellow-dim); color: var(--yellow); }
.badge-negociando { background: var(--purple-dim); color: var(--purple); }
.badge-cerrado_ganado, .badge-aceptado, .badge-cobrado, .badge-pagado, .badge-publicado { background: var(--green-dim); color: var(--green); }
.badge-cerrado_perdido { background: var(--red-dim); color: var(--red); }
.badge-en_desarrollo { background: var(--blue-dim); color: var(--blue); }
.badge-entregado { background: var(--yellow-dim); color: var(--yellow); }
.badge-pendiente { background: var(--yellow-dim); color: var(--yellow); }
.badge-idea { background: rgba(255, 255, 255, 0.06); color: var(--text-muted); }
.badge-planeado { background: var(--blue-dim); color: var(--blue); }
.badge-creado { background: var(--yellow-dim); color: var(--yellow); }

/* ═══ Buttons ═══ */
.btn-primary {
  padding: 10px 20px;
  background: var(--white);
  color: var(--bg);
  font-size: 0.813rem;
  font-weight: 600;
  border-radius: 8px;
  transition: opacity 0.2s;
  border: none;
  cursor: pointer;
}

.btn-primary:hover {
  opacity: 0.85;
}

.btn-secondary {
  padding: 10px 20px;
  background: transparent;
  color: var(--text);
  font-size: 0.813rem;
  font-weight: 500;
  border: 1px solid #444;
  border-radius: 8px;
  transition: border-color 0.2s, color 0.2s;
  cursor: pointer;
}

.btn-secondary:hover {
  border-color: #666;
  color: var(--white);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.75rem;
  border-radius: 6px;
  border: 1px solid #333;
  color: var(--text);
  transition: color 0.2s, border-color 0.2s;
  cursor: pointer;
  background: transparent;
}

.btn-sm:hover {
  color: var(--white);
  border-color: #555;
}

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

.btn-text {
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: color 0.2s;
  padding: 0;
}

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

.btn-success {
  padding: 10px 20px;
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, 0.2);
  border-radius: 8px;
  font-size: 0.813rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-success:hover {
  background: rgba(34, 197, 94, 0.18);
}

.btn-danger {
  padding: 10px 20px;
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 8px;
  font-size: 0.813rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.18);
}

/* ═══ Search & Filters ═══ */
.search-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 200px;
}

.filters {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filters select {
  width: auto;
  min-width: 180px;
  background: var(--bg3);
  border-color: #333;
}

/* ═══ Section Card ═══ */
.section-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.section-card h3 {
  font-size: 0.813rem;
  font-weight: 600;
  color: var(--white);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ═══ Modals ═══ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.modal.open {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 16px;
  padding: 32px;
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.96) translateY(8px);
  transition: transform 0.3s var(--ease);
}

.modal.open .modal-content {
  transform: scale(1) translateY(0);
}

.modal-large .modal-content,
.modal-content.modal-large {
  max-width: 700px;
}

.modal-small .modal-content,
.modal-content.modal-small {
  max-width: 380px;
}

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

.modal-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--white);
}

.modal-close {
  font-size: 1.5rem;
  color: var(--text-muted);
  padding: 4px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s;
}

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

.form-group {
  margin-bottom: 16px;
}

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

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

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ═══ Lead Detail Modal ═══ */
.lead-header {
  display: flex;
  gap: 16px;
  align-items: center;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

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

.lead-name {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--white);
}

.lead-company {
  font-size: 0.813rem;
  color: var(--text-muted);
}

.lead-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin: 20px 0;
}

.lead-tab {
  padding: 10px 20px;
  font-size: 0.813rem;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.lead-tab:hover {
  color: var(--text);
}

.lead-tab.active {
  color: var(--white);
  border-bottom-color: var(--white);
}

.tab-content {
  display: none;
}

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

/* ═══ Chat ═══ */
.chat-area {
  display: flex;
  flex-direction: column;
}

.chat-messages {
  max-height: 400px;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.813rem;
  line-height: 1.5;
}

.chat-msg.bot {
  background: var(--bg3);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-msg.user {
  background: var(--blue-dim);
  color: var(--blue);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-msg.human {
  background: var(--green-dim);
  color: var(--green);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-time {
  font-size: 0.625rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.chat-input-row input {
  flex: 1;
}

/* ═══ Content Calendar — Monthly ═══ */
.calendar-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}
.calendar-month {
  font-size: 1rem;
  font-weight: 600;
  color: var(--white);
  min-width: 160px;
  text-align: center;
}
.calendar-grid {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 24px;
}
.cal-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
}
.cal-header span {
  padding: 10px;
  text-align: center;
  font-size: 0.688rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.cal-body {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.cal-day {
  min-height: 90px;
  padding: 8px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s;
}
.cal-day:nth-child(7n) { border-right: none; }
.cal-day:hover { background: rgba(255,255,255,0.03); }
.cal-day.today { background: rgba(34, 197, 94, 0.06); }
.cal-day.other-month { opacity: 0.3; }
.cal-day-num {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.cal-day.today .cal-day-num { color: var(--green); font-weight: 700; }
.cal-event {
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 0.625rem;
  font-weight: 500;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.cal-event.ct-reel { background: rgba(254,108,123,0.15); color: #fe6c7b; }
.cal-event.ct-post { background: var(--blue-dim); color: var(--blue); }
.cal-event.ct-story { background: var(--yellow-dim); color: var(--yellow); }
.cal-event.ct-ad { background: var(--green-dim); color: var(--green); }
.cal-event.ct-tip { background: var(--purple-dim); color: var(--purple); }
.cal-event.ct-testimonial { background: var(--orange-dim); color: var(--orange); }
.cal-event.ct-producto { background: var(--yellow-dim); color: var(--yellow); }
.cal-event.ct-live { background: var(--red-dim); color: var(--red); }
.cal-event.ct-interactivo { background: var(--blue-dim); color: var(--blue); }

/* Legacy content calendar (kept for compat) */
.content-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.content-day {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  min-height: 160px;
  transition: border-color 0.2s;
}

.content-day.today {
  border-color: var(--green);
}

.content-day-header {
  font-size: 0.688rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.content-day-number {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 12px;
}

.content-day.today .content-day-number {
  color: var(--green);
}

.content-entry {
  padding: 8px;
  background: var(--bg3);
  border-radius: 6px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.content-entry:hover {
  background: rgba(255, 255, 255, 0.06);
}

.content-entry-title {
  font-size: 0.688rem;
  font-weight: 500;
  color: var(--white);
  margin-bottom: 2px;
}

.content-entry-meta {
  font-size: 0.625rem;
  color: var(--text-muted);
}

/* Content type left-border colors */
.ct-reel { border-left: 3px solid #fe6c7b; }
.ct-post { border-left: 3px solid var(--blue); }
.ct-story { border-left: 3px solid var(--yellow); }
.ct-ad { border-left: 3px solid var(--green); }
.ct-tip { border-left: 3px solid var(--purple); }
.ct-testimonial { border-left: 3px solid var(--orange); }

.content-ideas-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.idea-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg3);
  border-radius: 8px;
}

.idea-title {
  font-size: 0.813rem;
  color: var(--text);
}

/* ═══ Attention Banner ═══ */
.attention-banner {
  margin-bottom: 16px;
}
.attention-banner:empty { display: none; }
.attention-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: 10px;
  margin-bottom: 8px;
}
.attention-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.attention-item-name {
  font-size: 0.813rem;
  font-weight: 600;
  color: var(--white);
}
.attention-item-meta {
  font-size: 0.688rem;
  color: var(--text-muted);
}

/* ═══ Accounting Grid ═══ */
.accounting-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

/* ═══ Collapsible Sections ═══ */
.collapsible {
  margin-bottom: 8px;
}

.collapsible-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  cursor: pointer;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: background 0.2s;
  user-select: none;
}

.collapsible-header:hover {
  background: var(--bg3);
}

.collapsible-header h3 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--white);
}

.collapsible-count {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 0.688rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg4);
}

.collapsible-chevron {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: transform 0.3s;
}

.collapsible.open .collapsible-chevron {
  transform: rotate(180deg);
}

.collapsible-body {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s var(--ease);
}

.collapsible.open .collapsible-body {
  max-height: 2000px;
}

.collapsible.open .collapsible-header {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.collapsible-item {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.collapsible-item:last-child {
  border-bottom: 1px solid var(--border);
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
}

/* ═══ Observations ═══ */
.obs-item {
  padding: 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
  transition: opacity 0.3s;
}

.obs-item.resolved {
  opacity: 0.5;
}

.obs-text {
  font-size: 0.813rem;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.5;
}

.obs-meta {
  display: flex;
  gap: 8px;
  align-items: center;
}

.obs-tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 100px;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.obs-tag.error { background: var(--red-dim); color: var(--red); }
.obs-tag.mejora { background: var(--blue-dim); color: var(--blue); }
.obs-tag.urgente { background: var(--yellow-dim); color: var(--yellow); }

/* ═══ Pipeline ═══ */
.pipeline {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  min-height: 400px;
}

.pipeline-col {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.pipeline-col h4 {
  font-size: 0.688rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.pipeline-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pipeline-card {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s var(--ease);
}

.pipeline-card:hover {
  border-color: #444;
  transform: translateY(-1px);
}

.pipeline-card-name {
  font-size: 0.813rem;
  font-weight: 600;
  color: var(--white);
  margin-bottom: 4px;
}

.pipeline-card-service {
  font-size: 0.688rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.pipeline-card-amount {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--green);
}

/* ═══ Reminders ═══ */
.reminder-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reminder-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg3);
  border-radius: 8px;
  border-left: 3px solid var(--border2);
  transition: background 0.2s;
}

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

.reminder-item.today { border-left-color: var(--green); }
.reminder-item.overdue { border-left-color: var(--red); }

.reminder-date {
  font-size: 0.688rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 60px;
}

.reminder-title {
  font-size: 0.813rem;
  color: var(--white);
  flex: 1;
}

.reminder-platform {
  font-size: 0.688rem;
  padding: 3px 8px;
  border-radius: 100px;
  background: var(--blue-dim);
  color: var(--blue);
}

/* ═══ Config ═══ */
.config-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.config-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.813rem;
  color: var(--text);
  cursor: pointer;
}

.config-field {
  margin-top: 8px;
}

.config-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

/* ═══ Empty State ═══ */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.empty-state-icon {
  font-size: 2rem;
  margin-bottom: 12px;
  opacity: 0.4;
}

/* ═══ Alerts ═══ */
.alert {
  padding: 14px 18px;
  border-radius: 10px;
  border-left: 4px solid;
  margin-bottom: 16px;
  font-size: 0.813rem;
  line-height: 1.5;
}

.alert-warning {
  background: var(--yellow-dim);
  border-left-color: var(--yellow);
  color: var(--yellow);
}

.alert-danger {
  background: var(--red-dim);
  border-left-color: var(--red);
  color: var(--red);
}

.alert-info {
  background: var(--blue-dim);
  border-left-color: var(--blue);
  color: var(--blue);
}

.alert-success {
  background: var(--green-dim);
  border-left-color: var(--green);
  color: var(--green);
}

/* ═══ Animations ═══ */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-in {
  animation: fadeIn 0.4s ease both;
}

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

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

::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #444;
}

/* ═══ Utilities ═══ */
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-blue { color: var(--blue); }
.text-yellow { color: var(--yellow); }
.text-purple { color: var(--purple); }
.text-muted { color: var(--text-muted); }
.text-white { color: var(--white); }
.font-mono { font-family: 'SF Mono', 'Fira Code', monospace; }
.font-tabular { font-variant-numeric: tabular-nums; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-16 { margin-bottom: 16px; }
.mb-28 { margin-bottom: 28px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }
.hidden { display: none; }

/* ═══ Responsive ═══ */
@media (max-width: 1024px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }

  .pipeline {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
    width: 260px;
    top: var(--topbar-h);
  }

  #sidebar.open {
    transform: translateX(0);
  }

  #main {
    margin-left: 0;
    padding: calc(var(--topbar-h) + 16px) 16px 24px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats-3 {
    grid-template-columns: 1fr;
  }

  .pipeline {
    grid-template-columns: 1fr;
  }

  .filters {
    flex-direction: column;
  }

  .filters select {
    min-width: 100%;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .view-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .modal-content.modal-large,
  .modal-large .modal-content {
    max-width: 95%;
  }

  table {
    font-size: 0.75rem;
  }

  th, td {
    padding: 10px 12px;
  }

  .notif-panel {
    width: calc(100vw - 32px);
    right: 16px;
    left: 16px;
  }

  .search-bar {
    flex-direction: column;
  }

  .search-input {
    min-width: 100%;
  }

  .accounting-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  #main {
    padding: 68px 12px 20px;
  }

  .modal-content {
    padding: 24px 20px;
    border-radius: 12px;
  }

  .lead-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .lead-tab {
    white-space: nowrap;
    padding: 10px 14px;
  }
}
