/* ===================================
   CRM PHP - ESTILOS GLOBALES
   Responsive + Sidebar + Componentes
   =================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  background: #f0f2f8;
  color: #2d3a4a;
  font-family: 'Segoe UI', 'Roboto', Arial, sans-serif;
  font-size: 0.97rem;
}

/* ===================================
   PAGE TITLE
   =================================== */
.page-title {
  color: #1e40af;
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0;
  letter-spacing: -0.3px;
}

.page-subtitle {
  font-size: 0.82rem;
  color: #64748b;
  margin-top: 2px;
  display: block;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-radius: 10px;
  padding: 14px 20px;
  margin-bottom: 18px;
  box-shadow: 0 1px 4px rgba(44, 62, 80, 0.07);
  border: 1px solid #e4e8f0;
}

/* ===================================
   BADGES POR ETAPA DE VENTA
   =================================== */
.badge-etapa {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.badge-prospectado {
  background: #e2e8f0;
  color: #475569;
}

.badge-contactado {
  background: #fef9c3;
  color: #854d0e;
}

.badge-negociacion {
  background: #ffedd5;
  color: #c2410c;
}

.badge-ganado {
  background: #dcfce7;
  color: #15803d;
}

.badge-perdido {
  background: #fee2e2;
  color: #b91c1c;
}

/* Helpers */
.badge-info {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge-success {
  background: #dcfce7;
  color: #15803d;
}

.badge-warning {
  background: #fef9c3;
  color: #854d0e;
}

.badge-danger {
  background: #fee2e2;
  color: #b91c1c;
}

/* Toggle Button (visible solo en móviles) */
.sidebar-toggle {
  position: fixed;
  top: 15px;
  left: 15px;
  z-index: 1050;
  display: none;
  border-radius: 4px;
  padding: 8px 12px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.sidebar-toggle .mdi {
  font-size: 1.5rem;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 250px;
  background: linear-gradient(180deg, #e3eaf2 0%, #f4f6fb 100%);
  color: #2d3a4a;
  z-index: 1040;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.3s ease;
  box-shadow: 2px 0 8px rgba(44, 62, 80, 0.08);
  display: flex;
  flex-direction: column;
  border-right: 1px solid #dbe2ef;
}

/* Header del Sidebar */
.sidebar-header {
  padding: 24px 18px 16px 18px;
  border-bottom: 1px solid #dbe2ef;
  text-align: center;
  background: #e3eaf2;
}

.sidebar-header h4 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: #2563eb;
  letter-spacing: 0.5px;
}

.sidebar-header small {
  font-size: 0.8rem;
  color: #6b7280;
}

/* Menú del Sidebar */
.sidebar-menu {
  list-style: none;
  padding: 0;
  margin: 24px 0 0 0;
  flex: 1;
}

.sidebar-item {
  margin: 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  padding: 14px 22px;
  color: #4b5563;
  /* Gris más oscuro */
  text-decoration: none;
  transition: all 0.2s ease;
  border-left: 4px solid transparent;
  font-size: 1.02rem;
  font-weight: 600;
  border-radius: 0 12px 12px 0;
  margin-right: 12px;
}

.sidebar-link:hover {
  background: rgba(37, 99, 235, 0.08);
  color: #2563eb;
  text-decoration: none;
  padding-left: 26px;
}

.sidebar-link.active {
  background: #e0e7ff;
}

/* Dashboard KPI Cards */
.border-left-primary {
  border-left: .25rem solid #4e73df !important;
}

.border-left-success {
  border-left: .25rem solid #1cc88a !important;
}

.border-left-info {
  border-left: .25rem solid #36b9cc !important;
}

.border-left-warning {
  border-left: .25rem solid #f6c23e !important;
}

.text-xs {
  font-size: .7rem;
}

.font-weight-bold {
  font-weight: 700 !important;
}

.text-gray-300 {
  color: #dddfeb !important;
}

.text-gray-800 {
  color: #5a5c69 !important;
}

.shadow {
  box-shadow: 0 .15rem 1.75rem 0 rgba(58, 59, 69, .15) !important;
}

border-left-color: #2563eb;
color: #1e40af;
font-weight: 700;
}

.sidebar-link .mdi {
  font-size: 1.4rem;
  margin-right: 14px;
  width: 24px;
  text-align: center;
  color: #64748b;
  /* Iconos más tenues por defecto */
  transition: color 0.2s;
}

.sidebar-link:hover .mdi,
.sidebar-link.active .mdi {
  color: #2563eb;
}

.sidebar-link span:last-child {
  flex: 1;
}

/* Footer del Sidebar */
.sidebar-footer {
  padding: 16px 18px;
  border-top: 1px solid #dbe2ef;
  background: #e3eaf2;
  text-align: center;
}

.sidebar-footer .sidebar-link {
  padding: 10px 0;
  justify-content: center;
  flex-direction: column;
  color: #ff9800;
  font-weight: 600;
  font-size: 1rem;
  border-left: none;
  background: none;
  border-radius: 0;
}

.sidebar-footer .sidebar-link:hover {
  color: #2563eb;
  background: none;
  padding-left: 0;
}

.sidebar-footer small {
  display: block;
  margin-top: 4px;
  font-size: 0.85rem;
  color: #6b7280;
}

/* Overlay (visible solo en móviles cuando sidebar está abierto) */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(44, 62, 80, 0.18);
  z-index: 1030;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

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

/* Contenido Principal */
/* Wrapper para login (sin sidebar) */
.login-wrapper {
  min-height: 100vh;
  background: #f4f6fb;
  display: flex;
  align-items: center;
  justify-content: center;
}

.content-wrapper {
  margin-left: 250px;
  padding: 24px 30px 40px 30px;
  min-height: 100vh;
  transition: margin-left 0.3s ease;
  background: #f0f2f8;
  color: #2d3a4a;
}

/* ===================================
   TOP NAVBAR
   =================================== */
.top-navbar {
  background: #fff;
  border-radius: 12px;
  padding: 12px 24px;
  margin-bottom: 24px;
  box-shadow: 0 1px 4px rgba(44, 62, 80, 0.06);
  border: 1px solid #e4e8f0;
  position: relative;
  z-index: 100;
}

.user-name-top {
  font-weight: 700;
  color: #1e40af;
  font-size: 0.95rem;
  line-height: 1.2;
}

.user-role-top {
  font-size: 0.68rem;
  color: #94a3b8;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.user-avatar-top {
  width: 42px;
  height: 42px;
  background: #2563eb;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  font-weight: 700;
  font-size: 1.1rem;
}

/* Footer */
.footer {
  background: #fff;
  border-top: 1px solid #e4e8f0;
  padding: 10px 30px;
  margin-left: 250px;
  text-align: center;
  color: #6b7280;
  font-size: 0.88rem;
  transition: margin-left 0.3s ease;
}

/* ===================================
   FORMULARIOS - SELECTS E INPUTS
   =================================== */
select,
select option,
select.form-control,
select.form-control-sm,
select.form-control option,
select.form-control-sm option {
  color: #2d3a4a !important;
  background-color: #ffffff !important;
}

input.form-control,
input.form-control-sm,
textarea.form-control,
textarea.form-control-sm {
  color: #2d3a4a !important;
  background-color: #ffffff !important;
}

/* Forzar texto visible en Chrome/Edge donde -webkit-text-fill-color pisa a color */
select:not([multiple]) {
  color: #2d3a4a !important;
  -webkit-text-fill-color: #2d3a4a !important;
}

/* ===================================
   CARDS Y TABLAS
   =================================== */
.card {
  border-radius: 10px;
  border: 1px solid #e4e8f0;
  box-shadow: 0 1px 4px rgba(44, 62, 80, 0.06);
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
}

.table td,
.table th {
  vertical-align: middle;
  padding: 0.6rem 0.75rem;
}

.table thead th {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #64748b;
  background: #f8fafc;
  border-bottom: 2px solid #e4e8f0;
}

/* ===================================
   PIPELINE KANBAN
   =================================== */
.pipeline-board {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 16px;
  align-items: flex-start;
}

.pipeline-col {
  flex: 0 0 220px;
  min-width: 200px;
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e4e8f0;
  box-shadow: 0 1px 4px rgba(44, 62, 80, 0.06);
  display: flex;
  flex-direction: column;
}

.pipeline-header {
  padding: 12px 14px;
  border-radius: 10px 10px 0 0;
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e4e8f0;
}

.pipeline-header .badge-count {
  background: rgba(0, 0, 0, 0.12);
  color: inherit;
  border-radius: 20px;
  padding: 1px 9px;
  font-size: 0.82rem;
  font-weight: 700;
}

.pipeline-body {
  padding: 10px;
  flex: 1;
  min-height: 100px;
}

.pipeline-card {
  background: #f8fafc;
  border-radius: 8px;
  padding: 11px 13px;
  margin-bottom: 9px;
  border: 1px solid #e4e8f0;
  transition: box-shadow 0.2s, transform 0.15s;
  font-size: 0.9rem;
}

.pipeline-card:last-child {
  margin-bottom: 0;
}

.pipeline-card:hover {
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.12);
  transform: translateY(-1px);
}

.pipeline-card .empresa-name {
  font-weight: 600;
  color: #1e40af;
  font-size: 0.92rem;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pipeline-card .empresa-meta {
  color: #64748b;
  font-size: 0.82rem;
}

/* Colores de cabecera por etapa */
.ph-prospectado {
  background: #f1f5f9;
  color: #475569;
}

.ph-contactado {
  background: #fefce8;
  color: #854d0e;
}

.ph-negociacion {
  background: #fff7ed;
  color: #c2410c;
}

.ph-ganado {
  background: #f0fdf4;
  color: #15803d;
}

.ph-perdido {
  background: #fef2f2;
  color: #b91c1c;
}

/* ===================================
   RESPONSIVE - Móviles y Tablets
   =================================== */

@media (max-width: 768px) {

  /* Mostrar toggle button */
  .sidebar-toggle {
    display: none;
    /* Ocultamos el viejo botón flotante */
  }

  .sidebar {
    transform: translateX(-100%);
    background: #fff;
    border-right: 1px solid #dbe2ef;
    z-index: 2000;
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .content-wrapper {
    margin-left: 0 !important;
    padding: 15px 14px 30px 14px;
    background: #f0f2f8;
  }

  .top-navbar {
    padding: 10px 15px;
    margin-bottom: 20px;
  }

  .footer {
    margin-left: 0 !important;
    padding: 10px 14px;
  }
}

/* Tablets */
@media (min-width: 769px) and (max-width: 991px) {
  .sidebar {
    width: 200px;
  }

  .content-wrapper {
    margin-left: 200px;
    padding: 22px 20px 30px 20px;
  }

  .footer {
    margin-left: 200px;
  }

  .sidebar-link {
    padding: 12px 16px;
  }

  .sidebar-link .mdi {
    font-size: 1.2rem;
    color: #2563eb;
  }
}

/* Desktop Grande */
@media (min-width: 1400px) {
  .sidebar {
    width: 280px;
  }

  .content-wrapper {
    margin-left: 280px;
    padding: 32px 36px 40px 36px;
  }

  .footer {
    margin-left: 280px;
  }
}

/* Scroll personalizado para el sidebar */
.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(44, 62, 80, 0.22);
  border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(44, 62, 80, 0.4);
}

/* ==========================================================================
   SOLUCIÓN DEFINITIVA PARA SELECTS (Chrome/Edge/Safari fix)
   Fuerza la visualización del texto en elementos select ignorando estilos
   heredados o del navegador que causen invisibilidad.
   ========================================================================== */
select.form-control,
select.form-control-sm,
select:not([multiple]) {
  color: #2d3a4a !important;
  /* Texto oscuro casi negro */
  -webkit-text-fill-color: #2d3a4a !important;
  /* Fix específico para Webkit */
  background-color: #ffffff !important;
  /* Fondo blanco puro */
  opacity: 1 !important;
  /* Opacidad total */

  /* Restaurar apariencia nativa para garantizar visibilidad */
  appearance: menulist !important;
  -webkit-appearance: menulist !important;
  -moz-appearance: menulist !important;

  /* Ajustes de caja para evitar recorte de texto */
  height: auto !important;
  min-height: 34px !important;
  /* Altura mínima razonable */
  padding-top: 4px !important;
  padding-bottom: 4px !important;
  padding-left: 8px !important;

  /* Asegurar que se sobrepone a cualquier capa */
  background-image: none !important;
}

select option {
  color: #2d3a4a !important;
  background-color: #ffffff !important;
}