/* ═══════════════════════════════════════════════════════════════
   Iconnect CRM — styles.css
   Tema claro y profesional con acentos teal (marca Iconnect-Telecom).
═══════════════════════════════════════════════════════════════ */

:root {
  --teal: #00a89e;
  --teal-dark: #007a72;
  --teal-light: #e6f7f5;
  --bg: #f4f7f7;
  --surface: #ffffff;
  --border: #e2e8e7;
  --text: #16302c;
  --text-dim: #5f7975;
  --green: #1e9e5a;
  --green-bg: #e8f8ee;
  --red: #d1453b;
  --red-bg: #fbeae9;
  --yellow: #c98a12;
  --yellow-bg: #fdf3e2;
  --sidebar-w: 230px;
  font-size: 15px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, sans-serif;
}
button { font-family: inherit; }
h1, h2, h3 { margin: 0; }
[hidden] { display: none !important; }

/* ── Login ─────────────────────────────────────────────────────── */
.view-login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #0a1f1c, #103833);
}
.login-box { width: 100%; max-width: 360px; padding: 20px; }
.brand { text-align: center; margin-bottom: 28px; color: #eafaf7; }
.brand-dot {
  width: 48px; height: 48px; margin: 0 auto 12px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--teal), var(--teal-dark));
  box-shadow: 0 0 24px rgba(0, 212, 200, 0.4);
}
.brand-dot.small { width: 30px; height: 30px; margin: 0; }
.brand-sub { color: #9fc7c0; font-size: 0.85rem; margin-top: 6px; }

#login-form { display: flex; flex-direction: column; gap: 6px; background: var(--surface); padding: 26px; border-radius: 14px; }
#login-form label { font-size: 0.78rem; color: var(--text-dim); margin-top: 8px; }
#login-form input {
  border: 1px solid var(--border); border-radius: 8px; padding: 11px 12px; font-size: 0.95rem;
}
#login-form input:focus { outline: 2px solid var(--teal); }
#login-btn {
  margin-top: 16px; background: linear-gradient(135deg, var(--teal), var(--teal-dark));
  color: white; font-weight: 700; border: none; border-radius: 8px; padding: 12px; cursor: pointer;
}
.error { color: var(--red); font-size: 0.82rem; margin-top: 6px; }

/* ── Layout general de la app ──────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: #0e2a26; color: #cfe9e4;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px; padding: 18px 16px;
  font-weight: 700; color: white; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-nav { flex: 1; padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; background: none; border: none; color: #b8d8d2;
  padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 0.9rem; text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,0.06); }
.nav-item.active { background: var(--teal); color: #04211d; font-weight: 700; }
.nav-icon { width: 18px; text-align: center; }

.sidebar-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-user { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--teal); color: #04211d;
  display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0;
}
.user-name { font-size: 0.85rem; font-weight: 600; color: white; }
.user-role { font-size: 0.72rem; color: #8fb8b1; text-transform: capitalize; }
.link-btn { background: none; border: none; color: #8fb8b1; font-size: 0.8rem; cursor: pointer; padding: 0; }
.link-btn:hover { color: white; text-decoration: underline; }

.main-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 28px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.content-header h1 { font-size: 1.3rem; }
.view-actions { display: flex; gap: 8px; }
.view-body { padding: 24px 28px; flex: 1; overflow-y: auto; }

.btn {
  background: var(--teal); color: white; border: none; border-radius: 8px;
  padding: 9px 16px; font-size: 0.85rem; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--teal-dark); }
.btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--red); }
.btn:disabled { opacity: 0.6; cursor: default; }

.icon-btn {
  background: none; border: none; font-size: 1rem; cursor: pointer; color: var(--text-dim);
  width: 32px; height: 32px; border-radius: 8px;
}
.icon-btn:hover { background: var(--bg); }

/* ── Tarjetas / KPIs ───────────────────────────────────────────── */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 24px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.kpi-value { font-size: 1.6rem; font-weight: 700; }
.kpi-label { font-size: 0.78rem; color: var(--text-dim); margin-top: 2px; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; margin-bottom: 20px; }
.panel h3 { font-size: 0.95rem; margin-bottom: 12px; }

/* ── Tablas ────────────────────────────────────────────────────── */
table.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--text-dim); padding: 8px 10px; border-bottom: 2px solid var(--border);
}
.data-table td { padding: 10px 10px; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.data-table tr:hover td { background: var(--teal-light); cursor: pointer; }
.data-table tr.no-hover:hover td { background: none; cursor: default; }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; }
.toolbar input[type="search"], .toolbar select {
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; font-size: 0.88rem;
}
.toolbar input[type="search"] { flex: 1; max-width: 320px; }

.empty-state { text-align: center; color: var(--text-dim); padding: 40px 0; font-size: 0.9rem; }

/* ── Badges de estado ──────────────────────────────────────────── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; }
.badge.stage-Prospecto { background: #ececec; color: #555; }
.badge.stage-Calificado { background: var(--yellow-bg); color: var(--yellow); }
.badge.stage-Propuesta { background: #e6ecfb; color: #3457c9; }
.badge.stage-Negociación { background: #f3e6fb; color: #8a3fc9; }
.badge.stage-Ganado { background: var(--green-bg); color: var(--green); }
.badge.stage-Perdido { background: var(--red-bg); color: var(--red); }

/* ── Kanban de oportunidades ───────────────────────────────────── */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.kanban-column {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  min-width: 240px; max-width: 240px; flex-shrink: 0; display: flex; flex-direction: column;
  max-height: calc(100vh - 220px);
}
.kanban-column.drag-over { outline: 2px dashed var(--teal); outline-offset: -2px; }
.kanban-column-header {
  padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 0.82rem; font-weight: 700;
  display: flex; justify-content: space-between; align-items: center;
}
.kanban-column-total { font-size: 0.72rem; color: var(--text-dim); font-weight: 500; }
.kanban-cards { padding: 10px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; flex: 1; }
.kanban-card {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  cursor: grab; font-size: 0.83rem;
}
.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging { opacity: 0.4; }
.kanban-card-title { font-weight: 600; margin-bottom: 4px; }
.kanban-card-meta { font-size: 0.72rem; color: var(--text-dim); }
.kanban-card-amount { font-weight: 700; color: var(--teal-dark); margin-top: 4px; }

/* ── Tareas ────────────────────────────────────────────────────── */
.task-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.task-row:last-child { border-bottom: none; }
.task-row.overdue .task-title { color: var(--red); }
.task-checkbox { margin-top: 3px; width: 17px; height: 17px; accent-color: var(--teal); cursor: pointer; }
.task-title { font-size: 0.88rem; font-weight: 600; }
.task-title.done { text-decoration: line-through; color: var(--text-dim); font-weight: 400; }
.task-meta { font-size: 0.75rem; color: var(--text-dim); }

/* ── Modal ─────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(10, 30, 27, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 480px; max-height: 90vh; display: flex; flex-direction: column; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px; overflow-y: auto; }

.form-grid { display: flex; flex-direction: column; gap: 12px; }
.form-grid label { font-size: 0.78rem; color: var(--text-dim); display: block; margin-bottom: 4px; }
.form-grid input, .form-grid select, .form-grid textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; font-size: 0.88rem;
}
.form-grid textarea { min-height: 70px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.form-error { color: var(--red); font-size: 0.82rem; }
.form-grid select:disabled { background: var(--bg); color: var(--text-dim); cursor: not-allowed; }
.muted { color: var(--text-dim); font-size: 0.78rem; }

/* ── Toast ─────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #0e2a26; color: white; padding: 12px 20px; border-radius: 10px; font-size: 0.85rem;
  z-index: 100; box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}
.toast.error { background: var(--red); }

/* ── Detalle de cuenta ─────────────────────────────────────────── */
.detail-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 24px; font-size: 0.85rem; margin-bottom: 4px; }
.detail-grid dt { color: var(--text-dim); }
.detail-grid dd { margin: 0; }
.back-link { background: none; border: none; color: var(--teal-dark); cursor: pointer; font-size: 0.85rem; padding: 0; margin-bottom: 12px; }
.banner-pendiente {
  background: var(--yellow-bg); color: var(--yellow); border: 1px solid var(--yellow);
  border-radius: 8px; padding: 10px 14px; font-size: 0.85rem; margin-bottom: 14px;
}

canvas.chart { width: 100%; height: 160px; }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: 8px; }
  .sidebar-brand { display: none; }
  .sidebar-nav { flex-direction: row; overflow-x: auto; flex: 1; }
  .nav-item span:last-child { display: none; }
  .sidebar-footer { display: none; }
  .content-header { padding: 14px 16px; }
  .view-body { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
}
