/* ============================================================
   SIVREC CRM — Estilos principales
   ============================================================ */

:root {
  --primary:   #2563eb;
  --primary-d: #1d4ed8;
  --sidebar-bg:#0f172a;
  --sidebar-w: 240px;
  --topbar-h:  60px;
  --body-bg:   #f1f5f9;
  --card-bg:   #ffffff;
  --text:      #1e293b;
  --muted:     #64748b;
  --border:    #e2e8f0;
  --success:   #16a34a;
  --danger:    #dc2626;
  --warning:   #d97706;
  --info:      #0284c7;
  --radius:    10px;
  --shadow:    0 1px 4px rgba(0,0,0,.08);
}

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

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--body-bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Layout ─────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ─── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  position: fixed; top: 0; left: 0; bottom: 0;
  display: flex; flex-direction: column;
  z-index: 100; overflow-y: auto;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px; color: #fff;
  font-size: 18px; font-weight: 700; letter-spacing: .5px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand span { color: var(--primary); }

.sidebar-section { padding: 8px 0; }
.sidebar-label {
  font-size: 10px; font-weight: 600; letter-spacing: 1px;
  color: rgba(255,255,255,.35); padding: 10px 18px 4px;
  text-transform: uppercase;
}

.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 18px; color: rgba(255,255,255,.7);
  font-size: 13.5px; border-left: 3px solid transparent;
  transition: all .15s;
}
.sidebar-link:hover, .sidebar-link.active {
  background: rgba(255,255,255,.06);
  color: #fff; text-decoration: none;
  border-left-color: var(--primary);
}
.sidebar-link svg { width: 17px; height: 17px; flex-shrink: 0; }

/* ─── Main content ───────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1; display: flex; flex-direction: column;
  min-height: 100vh;
}

/* ─── Topbar ─────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 90;
  height: var(--topbar-h); background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 12px;
}
.topbar-title { font-size: 16px; font-weight: 600; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ─── Page ───────────────────────────────────────────────── */
.page-content { padding: 24px; flex: 1; }

/* ─── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 15px;
}
.card-body { padding: 20px; }

/* ─── Stats grid ─────────────────────────────────────────── */
.stats-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); margin-bottom: 24px; }
.stat-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat-card .label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.stat-card .value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat-card .sub   { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat-card.primary .value { color: var(--primary); }
.stat-card.success .value { color: var(--success); }
.stat-card.warning .value { color: var(--warning); }
.stat-card.danger  .value { color: var(--danger); }

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: 7px;
  font-size: 13.5px; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; transition: all .15s;
  text-decoration: none;
}
.btn-primary   { background: var(--primary);  color: #fff; }
.btn-primary:hover   { background: var(--primary-d); text-decoration: none; color: #fff; }
.btn-success   { background: var(--success);  color: #fff; }
.btn-danger    { background: var(--danger);   color: #fff; }
.btn-warning   { background: var(--warning);  color: #fff; }
.btn-outline   { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--body-bg); text-decoration: none; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-icon { padding: 6px; border-radius: 7px; }
.btn svg { width: 15px; height: 15px; }

/* ─── Forms ──────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-weight: 500; margin-bottom: 5px; font-size: 13px; }
.form-control, .form-select {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 7px;
  font-size: 13.5px; background: #fff; color: var(--text);
  transition: border-color .15s;
}
.form-control:focus, .form-select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
textarea.form-control { min-height: 90px; resize: vertical; }
.form-row { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
.form-row-3 { display: grid; gap: 16px; grid-template-columns: 1fr 1fr 1fr; }

/* ─── Table ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; padding: 10px 14px;
  font-size: 12px; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 2px solid var(--border); background: #f8fafc;
}
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

/* ─── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 9px;
  border-radius: 50px; font-size: 11.5px; font-weight: 600;
}
.badge-primary  { background: #dbeafe; color: #1d4ed8; }
.badge-success  { background: #dcfce7; color: #15803d; }
.badge-danger   { background: #fee2e2; color: #b91c1c; }
.badge-warning  { background: #fef3c7; color: #b45309; }
.badge-info     { background: #e0f2fe; color: #0369a1; }
.badge-muted    { background: #f1f5f9; color: #64748b; }

/* ─── Alerts / Flash ─────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius);
  margin-bottom: 16px; font-size: 13.5px; border: 1px solid transparent;
  display: flex; align-items: center; gap: 10px;
}
.alert-success { background: #f0fdf4; border-color: #86efac; color: #15803d; }
.alert-error   { background: #fef2f2; border-color: #fca5a5; color: #b91c1c; }
.alert-warning { background: #fffbeb; border-color: #fcd34d; color: #92400e; }
.alert-info    { background: #eff6ff; border-color: #93c5fd; color: #1d4ed8; }

/* ─── Page header ────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.page-header h1 { font-size: 20px; font-weight: 700; }

/* ─── Kanban ─────────────────────────────────────────────── */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(220px,1fr));
  gap: 16px; overflow-x: auto; padding-bottom: 16px;
}
.kanban-col {
  background: var(--body-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  min-height: 400px;
}
.kanban-col-header {
  padding: 12px 14px; font-weight: 700;
  font-size: 13px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.kanban-items { padding: 10px; min-height: 350px; }
.kanban-card {
  background: #fff; border: 1px solid var(--border);
  border-radius: 8px; padding: 12px;
  margin-bottom: 10px; cursor: grab;
  box-shadow: var(--shadow); transition: box-shadow .15s;
}
.kanban-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.12); }
.kanban-card h4 { font-size: 13.5px; font-weight: 600; margin-bottom: 4px; }
.kanban-card .meta { font-size: 12px; color: var(--muted); }
.kanban-card .amount { font-size: 13px; font-weight: 600; color: var(--success); margin-top: 6px; }
.sortable-ghost { opacity: .4; }

/* Kanban column colors */
.kanban-col[data-etapa="prospeccion"] .kanban-col-header { border-top: 3px solid var(--muted); border-radius: var(--radius) var(--radius) 0 0; }
.kanban-col[data-etapa="propuesta"]   .kanban-col-header { border-top: 3px solid var(--info); border-radius: var(--radius) var(--radius) 0 0; }
.kanban-col[data-etapa="negociacion"] .kanban-col-header { border-top: 3px solid var(--warning); border-radius: var(--radius) var(--radius) 0 0; }
.kanban-col[data-etapa="ganado"]      .kanban-col-header { border-top: 3px solid var(--success); border-radius: var(--radius) var(--radius) 0 0; }
.kanban-col[data-etapa="perdido"]     .kanban-col-header { border-top: 3px solid var(--danger); border-radius: var(--radius) var(--radius) 0 0; }

/* ─── Notification bell ──────────────────────────────────── */
.notif-btn { position: relative; }
.notif-badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700;
  width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.notif-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  width: 320px; background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0,0,0,.12);
  z-index: 200; display: none;
}
.notif-dropdown.open { display: block; }
.notif-item {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-size: 13px; display: flex; gap: 10px; align-items: flex-start;
}
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: #f0f9ff; }
.notif-item .notif-msg { flex: 1; }
.notif-time { font-size: 11px; color: var(--muted); margin-top: 2px; }
.notif-header { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; font-weight: 600; }

/* ─── Plan semanal ───────────────────────────────────────── */
.week-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px;
}
.day-col {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.day-header {
  padding: 10px 14px; font-weight: 600; font-size: 13px;
  background: #f8fafc; border-bottom: 1px solid var(--border);
  text-align: center;
}
.day-body { padding: 10px; min-height: 200px; }
.visit-item {
  background: #eff6ff; border: 1px solid #bfdbfe;
  border-radius: 6px; padding: 8px 10px; margin-bottom: 8px;
  font-size: 12.5px; position: relative;
}
.visit-item .remove-btn {
  position: absolute; top: 4px; right: 6px;
  color: var(--danger); cursor: pointer; font-size: 14px;
  background: none; border: none; line-height: 1;
}

/* ─── Calendario ─────────────────────────────────────────── */
#calendar-container { min-height: 600px; }
.gcal-embed { width: 100%; height: 600px; border: none; border-radius: var(--radius); }

/* ─── Tareas ─────────────────────────────────────────────── */
.tarea-row.completada td { opacity: .55; text-decoration: line-through; }
.tarea-row.cancelada td  { opacity: .4; }
.prioridad-alta   { color: var(--danger); font-weight: 700; }
.prioridad-media  { color: var(--warning); font-weight: 600; }
.prioridad-baja   { color: var(--muted); }

/* ─── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 1000; display: none; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: var(--radius);
  width: 90%; max-width: 500px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  max-height: 90vh; overflow-y: auto;
}
.modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 700; font-size: 15px;
}
.modal-body   { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted); }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .kanban-board { grid-template-columns: repeat(5, 250px); }
  .week-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ─── Week Grid ─────────────────────────────────────────── */
.week-grid { display:grid; grid-template-columns:repeat(5,1fr); gap:12px; }
.day-col { background:#fff; border-radius:var(--radius); border:1px solid var(--border); overflow:hidden; }
.day-header { padding:10px 14px; font-weight:600; font-size:13.5px; background:#f8fafc; border-bottom:1px solid var(--border); }
.day-body { padding:10px; min-height:120px; }
.visit-item { position:relative; padding:8px 28px 8px 10px; margin-bottom:6px; background:#f0f9ff; border-radius:6px; font-size:12.5px; border-left:3px solid #3b82f6; }
.remove-btn { position:absolute; top:4px; right:6px; background:none; border:none; cursor:pointer; color:#94a3b8; font-size:16px; line-height:1; }
.remove-btn:hover { color:#ef4444; }

/* ─── Pipeline ───────────────────────────────────────────── */
.pipeline-card { cursor:default; }
.score-badge { display:inline-block; padding:2px 8px; border-radius:20px; font-size:11px; font-weight:700; }
.score-high { background:#dcfce7; color:#16a34a; }
.score-mid  { background:#fef9c3; color:#ca8a04; }
.score-low  { background:#fee2e2; color:#dc2626; }

/* ─── Utility ────────────────────────────────────────────── */
.hidden { display: none !important; }

@media (max-width:1100px) { .week-grid { grid-template-columns:1fr 1fr; } }
@media (max-width:680px)  { .week-grid { grid-template-columns:1fr; } }
