/* ============================================================
   CRM imlabs — assets/css/style.css
   ============================================================ */

:root {
  --crm-primary:    #2563eb;
  --crm-primary-dk: #1d4ed8;
  --crm-secondary:  #64748b;
  --crm-success:    #16a34a;
  --crm-danger:     #dc2626;
  --crm-warning:    #d97706;
  --crm-info:       #0891b2;
  --crm-sidebar-w:  250px;
  --crm-topbar-h:   56px;
  --crm-bg:         #f1f5f9;
  --crm-sidebar-bg: #0f172a;
  --crm-sidebar-text: #cbd5e1;
  --crm-sidebar-hover: rgba(255,255,255,.07);
  --crm-sidebar-active: rgba(37,99,235,.35);
  --crm-card-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --crm-radius: .5rem;
  --crm-font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ── Reset base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body.crm-body {
  font-family: var(--crm-font);
  background: var(--crm-bg);
  color: #1e293b;
  margin: 0;
  overflow-x: hidden;
}

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

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
  min-height: var(--crm-topbar-h);
}

.brand-link {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
}
.brand-link i { font-size: 1.4rem; color: var(--crm-primary); }

.sidebar-nav { flex: 1; padding: .5rem 0; }

.nav-section-title {
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #475569;
  padding: 1rem 1.25rem .35rem;
}

.sidebar-nav .nav-link {
  color: var(--crm-sidebar-text);
  padding: .55rem 1.25rem;
  border-radius: .35rem;
  margin: .1rem .5rem;
  display: flex;
  align-items: center;
  gap: .65rem;
  font-size: .88rem;
  transition: background .15s, color .15s;
}
.sidebar-nav .nav-link i { font-size: 1rem; flex-shrink: 0; }
.sidebar-nav .nav-link:hover { background: var(--crm-sidebar-hover); color: #fff; }
.sidebar-nav .nav-link.active {
  background: var(--crm-sidebar-active);
  color: #93c5fd;
  font-weight: 600;
}

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,.07);
  padding: .75rem 1rem;
}
.user-info { display: flex; align-items: center; gap: .6rem; }
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--crm-primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem;
  flex-shrink: 0;
}
.user-details { flex: 1; min-width: 0; }
.user-name { color: #f1f5f9; font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: #64748b; font-size: .72rem; text-transform: capitalize; }
.logout-btn { color: #64748b !important; padding: .2rem .4rem !important; }
.logout-btn:hover { color: #ef4444 !important; }

/* ── Overlay móvil ───────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1039;
}
.sidebar-overlay.show { display: block; }

/* ── Main content ────────────────────────────────────────── */
.crm-main {
  margin-left: var(--crm-sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin .25s ease;
}

/* ── Topbar ──────────────────────────────────────────────── */
.crm-topbar {
  height: var(--crm-topbar-h);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 1020;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.crm-topbar .breadcrumb { font-size: .82rem; }
.sidebar-toggle { color: #475569 !important; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  border: 1px solid #e2e8f0;
  border-radius: var(--crm-radius);
  box-shadow: var(--crm-card-shadow);
}
.card-header {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: .9rem 1.25rem;
  font-weight: 600;
}

/* ── Stat cards ──────────────────────────────────────────── */
.stat-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: var(--crm-radius);
  padding: 1.25rem;
  box-shadow: var(--crm-card-shadow);
  display: flex;
  align-items: center;
  gap: 1rem;
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: .5rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-icon.primary  { background: #dbeafe; color: var(--crm-primary); }
.stat-icon.success  { background: #dcfce7; color: var(--crm-success); }
.stat-icon.warning  { background: #fef3c7; color: var(--crm-warning); }
.stat-icon.info     { background: #cffafe; color: var(--crm-info); }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; color: #0f172a; }
.stat-label { font-size: .78rem; color: #64748b; margin-top: .2rem; }

/* ── Tablas ──────────────────────────────────────────────── */
.table { font-size: .88rem; }
.table th {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #64748b;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}
.table td { vertical-align: middle; }
.table-hover tbody tr:hover { background: #f8fafc; }

/* ── Badges de estado ────────────────────────────────────── */
.badge-stage {
  font-size: .72rem;
  padding: .25em .6em;
  border-radius: 2rem;
  font-weight: 600;
}
.badge-nuevo        { background: #e0f2fe; color: #0369a1; }
.badge-contactado   { background: #fef9c3; color: #854d0e; }
.badge-calificado   { background: #fce7f3; color: #9d174d; }
.badge-propuesta    { background: #ede9fe; color: #5b21b6; }
.badge-negociacion  { background: #ffedd5; color: #9a3412; }
.badge-cerrado_ganado  { background: #dcfce7; color: #14532d; }
.badge-cerrado_perdido { background: #fee2e2; color: #7f1d1d; }

/* ── Pipeline kanban ─────────────────────────────────────── */
.pipeline-board {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 1rem;
}
.pipeline-column {
  min-width: 240px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--crm-radius);
  padding: .75rem;
}
.pipeline-column-header {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .75rem;
  padding-bottom: .5rem;
  border-bottom: 2px solid currentColor;
}
.pipeline-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: .35rem;
  padding: .75rem;
  margin-bottom: .5rem;
  font-size: .82rem;
  cursor: pointer;
  transition: box-shadow .15s;
}
.pipeline-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.1); }
.pipeline-card-title { font-weight: 600; color: #1e293b; }
.pipeline-card-amount { color: var(--crm-primary); font-weight: 600; }

/* ── Formularios ─────────────────────────────────────────── */
.form-label { font-size: .82rem; font-weight: 600; color: #374151; margin-bottom: .3rem; }
.form-control, .form-select {
  font-size: .875rem;
  border-color: #d1d5db;
  border-radius: .375rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--crm-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

/* ── Botones ─────────────────────────────────────────────── */
.btn-primary { background: var(--crm-primary); border-color: var(--crm-primary); }
.btn-primary:hover { background: var(--crm-primary-dk); border-color: var(--crm-primary-dk); }
.btn-sm { font-size: .78rem; }

/* ── Página de login ─────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 1rem;
  padding: 2.5rem;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo {
  text-align: center;
  margin-bottom: 1.75rem;
}
.login-logo i { font-size: 2.5rem; color: var(--crm-primary); }
.login-logo h1 { font-size: 1.5rem; font-weight: 700; margin: .5rem 0 .25rem; color: #0f172a; }
.login-logo p { font-size: .82rem; color: #64748b; margin: 0; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 767px) {
  .crm-sidebar {
    transform: translateX(-100%);
  }
  .crm-sidebar.open {
    transform: translateX(0);
  }
  .crm-main {
    margin-left: 0;
  }
  .pipeline-board { padding: 0 .5rem 1rem; }
}

/* ── Utilidades extra ────────────────────────────────────── */
.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cursor-pointer { cursor: pointer; }
.border-left-primary { border-left: 4px solid var(--crm-primary) !important; }
.border-left-success { border-left: 4px solid var(--crm-success) !important; }
.border-left-warning { border-left: 4px solid var(--crm-warning) !important; }

#crm-chat-btn {
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: transparent !important;
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: none !important;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .2s, box-shadow .2s;
    overflow: hidden;
    padding: 0;
}
