/* css/style.css - Sistema de Diseño Moderno para Cotizador SaaS */

:root {
  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  
  /* Paleta de Colores SaaS */
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --primary-dark: #3730a3;
  --primary-glow: rgba(79, 70, 229, 0.25);

  --accent: #06b6d4;
  --accent-hover: #0891b2;

  /* Estados de Cotización */
  --status-borrador: #64748b;
  --status-borrador-bg: #f1f5f9;
  --status-enviada: #0284c7;
  --status-enviada-bg: #e0f2fe;
  --status-pendiente: #d97706;
  --status-pendiente-bg: #fef3c7;
  --status-aceptada: #059669;
  --status-aceptada-bg: #d1fae5;
  --status-rechazada: #e11d48;
  --status-rechazada-bg: #ffe4e6;
  --status-facturada: #7c3aed;
  --status-facturada-bg: #ede9fe;

  /* Neutrales e Interfaz */
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-sidebar: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-text-hover: #ffffff;
  --sidebar-active-bg: rgba(255, 255, 255, 0.08);

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --border-color: #e2e8f0;
  --border-light: #f1f5f9;
  --border-focus: #818cf8;

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 0 20px var(--primary-glow);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-width: 260px;
  --header-height: 70px;
}

/* Reset y base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

input, button, select, textarea {
  font-family: inherit;
}

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

/* Scrollbar estilizada */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Layout General */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Banner de Impersonación */
.impersonation-banner {
  background: linear-gradient(90deg, #b45309, #d97706);
  color: #ffffff;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  box-shadow: var(--shadow-sm);
}

.impersonation-banner button {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: white;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: var(--transition);
}
.impersonation-banner button:hover {
  background: rgba(255, 255, 255, 0.35);
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: var(--transition);
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
}

.sidebar-header {
  height: var(--header-height);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.25rem;
  font-weight: 700;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.35);
}

.brand-details h2 {
  color: #ffffff;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-details span {
  font-size: 0.725rem;
  color: #38bdf8;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sidebar-nav {
  padding: 20px 12px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
  font-weight: 700;
  padding: 12px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.nav-item:hover {
  color: var(--sidebar-text-hover);
  background-color: var(--sidebar-active-bg);
}

.nav-item.active {
  color: #ffffff;
  background: linear-gradient(90deg, rgba(79, 70, 229, 0.85), rgba(79, 70, 229, 0.4));
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
}

/* Footer de Sidebar con Plan y Perfil */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.15);
}

.plan-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 12px;
}

.plan-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.plan-name-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: #4f46e5;
  color: #ffffff;
}

.plan-status-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.725rem;
  color: #10b981;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: currentColor;
  box-shadow: 0 0 6px currentColor;
}

.plan-quota {
  font-size: 0.75rem;
  color: #94a3b8;
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.plan-progress-bar {
  height: 5px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.plan-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #06b6d4);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.user-mini-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: #334155;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  overflow: hidden;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  color: #64748b;
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-logout {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.btn-logout:hover {
  color: #f43f5e;
  background: rgba(244, 63, 94, 0.1);
}

/* Contenido Principal */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: var(--transition);
}

.top-navbar {
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(8px);
}

.page-title h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.page-title p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.main-content {
  padding: 32px;
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* Botones Modernos */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  line-height: 1.25;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.35);
}

.btn-success {
  background: var(--status-aceptada);
  color: #ffffff;
}
.btn-success:hover {
  background: #047857;
}

.btn-outline {
  background: var(--bg-surface);
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.btn-whatsapp {
  background: #25D366;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3);
}
.btn-whatsapp:hover {
  background: #1eb956;
}

.btn-danger {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fecaca;
}
.btn-danger:hover {
  background: #fecaca;
  color: #b91c1c;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-icon-only {
  padding: 8px;
  border-radius: var(--radius-md);
}

/* Tarjetas y Contenedores */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 24px;
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-light);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Grid de Métricas / KPI Cards */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.metric-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary);
}

.metric-card.success::after { background: var(--status-aceptada); }
.metric-card.warning::after { background: var(--status-pendiente); }
.metric-card.info::after { background: var(--status-enviada); }

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.metric-label {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.metric-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 6px;
}

.metric-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.metric-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.metric-icon.indigo { background: var(--primary-light); color: var(--primary); }
.metric-icon.emerald { background: var(--status-aceptada-bg); color: var(--status-aceptada); }
.metric-icon.amber { background: var(--status-pendiente-bg); color: var(--status-pendiente); }
.metric-icon.blue { background: var(--status-enviada-bg); color: var(--status-enviada); }

/* Badges de Estado */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: capitalize;
  letter-spacing: 0.02em;
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
}

.status-borrador { background: var(--status-borrador-bg); color: var(--status-borrador); }
.status-enviada { background: var(--status-enviada-bg); color: var(--status-enviada); }
.status-pendiente { background: var(--status-pendiente-bg); color: var(--status-pendiente); }
.status-aceptada { background: var(--status-aceptada-bg); color: var(--status-aceptada); }
.status-rechazada { background: var(--status-rechazada-bg); color: var(--status-rechazada); }
.status-facturada { background: var(--status-facturada-bg); color: var(--status-facturada); }

/* Filtros y Pestañas de Estatus */
.filter-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 20px;
}

.filter-tab {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: var(--transition);
}

.filter-tab:hover {
  border-color: #cbd5e1;
  color: var(--text-main);
}

.filter-tab.active {
  background: var(--text-main);
  border-color: var(--text-main);
  color: #ffffff;
}

.filter-tab-count {
  background: rgba(0, 0, 0, 0.07);
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
}
.filter-tab.active .filter-tab-count {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

/* Tabla Estilizada */
.table-responsive {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.data-table th {
  background: #f8fafc;
  padding: 12px 16px;
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.775rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background-color: #f8fafc;
}

/* Kanban Board View */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 20px;
  align-items: start;
}

.kanban-col {
  background: #f1f5f9;
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 400px;
}

.kanban-col-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 2px solid rgba(0, 0, 0, 0.06);
}

.kanban-col-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.kanban-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: var(--transition);
}

.kanban-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

.kanban-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kanban-quote-num {
  font-weight: 700;
  font-size: 0.825rem;
  color: var(--primary);
}

.kanban-client {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.kanban-total {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
}

.kanban-actions {
  display: flex;
  gap: 6px;
  border-top: 1px solid var(--border-light);
  padding-top: 8px;
  justify-content: flex-end;
}

/* Selector Rápido de Estado */
.status-select {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.775rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background: #ffffff;
  cursor: pointer;
  outline: none;
}

/* Form Styles */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.form-control,
.form-input,
.form-textarea,
.form-select,
.public-input,
.public-textarea {
  width: 100%;
  padding: 11px 15px;
  font-size: 0.925rem;
  font-family: var(--font-main);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: #ffffff;
  color: var(--text-main);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease;
  outline: none;
  box-sizing: border-box;
}

.form-control::placeholder,
.form-input::placeholder,
.form-textarea::placeholder,
.public-input::placeholder,
.public-textarea::placeholder {
  color: #94a3b8;
  font-weight: 400;
}

.form-control:hover,
.form-input:hover,
.form-textarea:hover,
.form-select:hover,
.public-input:hover,
.public-textarea:hover {
  border-color: #94a3b8;
}

.form-control:focus,
.form-input:focus,
.form-textarea:focus,
.form-select:focus,
.public-input:focus,
.public-textarea:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
  background-color: #ffffff;
}

textarea.form-control,
textarea.form-textarea,
textarea.public-textarea {
  resize: vertical;
  min-height: 85px;
  line-height: 1.5;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

/* Constructor de Partidas / Items en Cotizador */
.quote-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  margin-bottom: 16px;
}

.quote-items-table th {
  background: #f1f5f9;
  padding: 10px 12px;
  font-size: 0.775rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.quote-items-table td {
  padding: 8px 6px;
  vertical-align: top;
}

.quote-items-table .item-desc-input {
  font-weight: 600;
}

.quote-items-table .item-details-input {
  font-size: 0.8rem;
  margin-top: 4px;
  color: var(--text-muted);
}

/* Totales en Cotizador */
.quote-totals-box {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  max-width: 380px;
  margin-left: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.totals-row.grand-total {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  border-top: 2px dashed var(--border-color);
  padding-top: 10px;
  margin-top: 4px;
}

/* Controles estilizados para Descuento e Impuesto en el Cotizador */
.totals-input-group {
  display: inline-flex;
  align-items: center;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease;
}

.totals-input-group:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.totals-select-compact {
  background: #f1f5f9;
  border: none;
  border-right: 1px solid #cbd5e1;
  color: #334155;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 8px;
  cursor: pointer;
  outline: none;
  transition: background-color 0.2s ease;
}

.totals-select-compact:hover {
  background: #e2e8f0;
}

.totals-number-input {
  border: none !important;
  background: #ffffff !important;
  color: #0f172a;
  font-size: 0.875rem !important;
  font-weight: 700 !important;
  padding: 6px 10px !important;
  width: 70px !important;
  text-align: right;
  outline: none !important;
  box-shadow: none !important;
  font-family: var(--font-main);
}

.totals-suffix-badge {
  background: #f8fafc;
  border-left: 1px solid #cbd5e1;
  color: #64748b;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 6px 10px;
  user-select: none;
}

/* Modales */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  z-index: 100;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-container {
  background: #ffffff;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 650px;
  max-height: calc(100vh - 24px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin: auto;
  transform: scale(0.95);
  transition: transform 0.2s ease;
}

.modal-container form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.modal-overlay.active .modal-container {
  transform: scale(1);
}

.modal-container.whatsapp-modal {
  max-width: 720px;
}

.modal-container.medium {
  max-width: 680px;
}

.modal-container.large {
  max-width: 900px;
}

.modal-container.full {
  max-width: 1100px;
}

.modal-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fafbfc;
  flex-shrink: 0;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.modal-close-btn:hover {
  background: #fee2e2;
  color: #dc2626;
}

.modal-body {
  padding: 18px 22px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  background: #f8fafc;
  flex-shrink: 0;
}

.modal-footer .btn {
  white-space: nowrap;
}

/* WhatsApp Bubble Simulator */
.whatsapp-preview-box {
  background: #efeae2;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 14px;
  background-image: radial-gradient(#d5cdc4 1px, transparent 1px);
  background-size: 16px 16px;
  max-height: 160px;
  overflow-y: auto;
}

.whatsapp-bubble {
  background: #ffffff;
  border-radius: 8px 8px 8px 0px;
  padding: 10px 14px;
  max-width: 92%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  position: relative;
  font-size: 0.88rem;
  line-height: 1.45;
  color: #111b21;
}

.whatsapp-bubble-time {
  font-size: 0.675rem;
  color: #667781;
  text-align: right;
  margin-top: 4px;
}

/* Plantilla PDF / Documento de Cotización Impreso */
.pdf-preview-canvas {
  background: #525659;
  padding: 30px 20px;
  display: flex;
  justify-content: center;
  overflow-y: auto;
}

.invoice-sheet {
  background: #ffffff;
  width: 100%;
  max-width: 800px;
  min-height: 1050px;
  padding: 45px 50px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  font-family: var(--font-main);
  color: #1e293b;
  position: relative;
  box-sizing: border-box;
}

.invoice-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 30px;
}

.invoice-logo-container {
  max-width: 200px;
  max-height: 80px;
  margin-bottom: 10px;
}

.invoice-logo-container img {
  max-width: 100%;
  max-height: 80px;
  object-fit: contain;
}

.invoice-business-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
}

.invoice-business-tagline {
  font-size: 0.85rem;
  color: #64748b;
  margin-bottom: 6px;
}

.invoice-business-info {
  font-size: 0.825rem;
  color: #475569;
  line-height: 1.4;
}

.invoice-badge-block {
  text-align: right;
}

.invoice-doc-type {
  font-size: 1.8rem;
  font-weight: 900;
  color: #4f46e5;
  letter-spacing: -0.03em;
  text-transform: uppercase;
  line-height: 1;
}

.invoice-num {
  font-size: 1.15rem;
  font-weight: 700;
  color: #334155;
  margin-top: 4px;
}

.invoice-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 28px;
}

.invoice-meta-col h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: #94a3b8;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.invoice-client-name {
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
}

.invoice-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}

.invoice-table th {
  background: #0f172a;
  color: #ffffff;
  padding: 10px 14px;
  font-size: 0.775rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left;
}

.invoice-table th.text-right {
  text-align: right;
}

.invoice-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.875rem;
  color: #1e293b;
}

.invoice-table td.text-right {
  text-align: right;
}

.invoice-table tr:nth-child(even) td {
  background-color: #fafbfc;
}

.invoice-bottom-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 30px;
  margin-top: 10px;
}

.invoice-terms-block {
  font-size: 0.8rem;
  color: #475569;
  line-height: 1.5;
}

.invoice-terms-block h4 {
  font-size: 0.775rem;
  text-transform: uppercase;
  color: #0f172a;
  margin-bottom: 6px;
  font-weight: 700;
}

.invoice-bank-box {
  background: #f1f5f9;
  border-radius: 6px;
  padding: 10px 14px;
  margin-top: 8px;
  font-size: 0.8rem;
  white-space: pre-line;
}

.invoice-totals-table {
  width: 100%;
  border-collapse: collapse;
}

.invoice-totals-table td {
  padding: 6px 0;
  font-size: 0.9rem;
  color: #475569;
}

.invoice-totals-table td.total-val {
  text-align: right;
  font-weight: 600;
  color: #0f172a;
}

.invoice-totals-table tr.grand-row td {
  border-top: 2px solid #0f172a;
  padding-top: 10px;
  font-size: 1.25rem;
  font-weight: 800;
  color: #4f46e5;
}

.watermark-free {
  margin-top: 35px;
  text-align: center;
  font-size: 0.75rem;
  color: #94a3b8;
  border-top: 1px dashed #e2e8f0;
  padding-top: 10px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: #0f172a;
  color: #ffffff;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
  font-weight: 500;
  animation: slideInToast 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  max-width: 380px;
}

.toast.success { background: #065f46; border-left: 4px solid #10b981; }
.toast.error { background: #881337; border-left: 4px solid #f43f5e; }
.toast.info { background: #1e293b; border-left: 4px solid #38bdf8; }

@keyframes slideInToast {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Login & Auth Screen */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 15% 15%, #312e81 0%, #0f172a 100%);
  padding: 24px;
}

.auth-card {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-xl);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  width: 100%;
  max-width: 480px;
  padding: 40px;
  position: relative;
  overflow: hidden;
}

.auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(90deg, #4f46e5, #06b6d4, #10b981);
}

.auth-tabs {
  display: flex;
  border-bottom: 2px solid var(--border-light);
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  text-align: center;
  padding: 12px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
}

.auth-tab.active {
  color: var(--primary);
  border-color: var(--primary);
}

.quick-demo-accounts {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px dashed var(--border-color);
}

.demo-account-badge {
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-top: 8px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition);
}
.demo-account-badge:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

/* Responsive */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-wrapper {
    margin-left: 0;
  }
  .top-navbar {
    padding: 0 16px;
  }
  .main-content {
    padding: 16px;
  }
  .invoice-bottom-grid {
    grid-template-columns: 1fr;
  }
}

/* Vista Pública - Barra de Decisión del Cliente */
.public-top-bar {
  max-width: 800px;
  margin: 0 auto 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ffffff;
  padding: 12px 20px;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.public-decision-card {
  max-width: 800px;
  margin: 0 auto 20px;
  background: #ffffff;
  border-radius: 14px;
  padding: 20px 24px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  transition: all 0.2s ease;
}

.public-decision-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 14px 28px -4px rgba(0, 0, 0, 0.12);
}

.public-decision-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 20px;
  background: #eff6ff;
  color: #2563eb;
  margin-bottom: 6px;
}

.public-decision-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 4px;
}

.public-decision-desc {
  font-size: 0.85rem;
  color: #64748b;
  line-height: 1.4;
  margin: 0;
}

.public-decision-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.btn-accept-quote {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border: none;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 10px 22px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
  transition: all 0.2s ease;
}

.btn-accept-quote:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.45);
}

.btn-reject-quote {
  background: #ffffff;
  color: #ef4444;
  border: 1.5px solid #fca5a5;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-reject-quote:hover {
  background: #fef2f2;
  border-color: #ef4444;
  color: #dc2626;
  transform: translateY(-1px);
}

/* Banner de Estado (Aceptada / Rechazada) */
.public-status-card {
  max-width: 800px;
  margin: 0 auto 20px;
  border-radius: 14px;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.status-card-accepted {
  background: #f0fdf4;
  border: 1.5px solid #86efac;
  color: #14532d;
}

.status-card-rejected {
  background: #fef2f2;
  border: 1.5px solid #fecaca;
  color: #7f1d1d;
}

.status-card-invoiced {
  background: #eff6ff;
  border: 1.5px solid #bfdbfe;
  color: #1e3a8a;
}

.status-card-icon {
  font-size: 2.2rem;
  line-height: 1;
}

.status-card-title {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 2px;
}

.status-card-desc {
  font-size: 0.88rem;
  opacity: 0.9;
  line-height: 1.4;
}

.btn-whatsapp-status {
  background: #25D366;
  color: white;
  border: none;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.35);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.btn-whatsapp-status:hover {
  background: #20bd5a;
  transform: translateY(-1px);
  color: white;
}

/* Panel inferior de decisión */
.public-bottom-decision {
  margin-top: 30px;
  padding-top: 24px;
  border-top: 2px dashed #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

@media (max-width: 768px) {
  .public-decision-card {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
  .public-decision-actions {
    flex-direction: column;
    width: 100%;
  }
  .public-decision-actions button {
    width: 100%;
    justify-content: center;
  }
  .public-status-card {
    flex-direction: column;
    text-align: center;
  }
  .public-bottom-decision {
    flex-direction: column;
    text-align: center;
  }
/* SweetAlert2 Diseño Moderno e Innovador */
.swal2-popup {
  font-family: var(--font-main) !important;
  border-radius: 20px !important;
  padding: 24px 28px !important;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25) !important;
  border: 1px solid rgba(226, 232, 240, 0.9) !important;
  background: #ffffff !important;
}

.swal2-title {
  font-size: 1.25rem !important;
  font-weight: 800 !important;
  color: #0f172a !important;
  letter-spacing: -0.02em !important;
  padding: 10px 0 4px !important;
}

.swal2-html-container {
  font-size: 0.92rem !important;
  color: #475569 !important;
  line-height: 1.5 !important;
  margin: 8px 0 0 !important;
}

.swal2-actions {
  gap: 10px !important;
  margin-top: 22px !important;
}

.swal2-confirm {
  font-family: var(--font-main) !important;
  font-weight: 700 !important;
  font-size: 0.9rem !important;
  border-radius: 10px !important;
  padding: 10px 22px !important;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3) !important;
  transition: all 0.2s ease !important;
}

.swal2-deny {
  font-family: var(--font-main) !important;
  font-weight: 700 !important;
  font-size: 0.9rem !important;
  border-radius: 10px !important;
  padding: 10px 22px !important;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3) !important;
  transition: all 0.2s ease !important;
}

.swal2-cancel {
  font-family: var(--font-main) !important;
  font-weight: 600 !important;
  font-size: 0.9rem !important;
  border-radius: 10px !important;
  padding: 10px 20px !important;
  background-color: #f1f5f9 !important;
  color: #475569 !important;
  border: 1px solid #cbd5e1 !important;
  transition: all 0.2s ease !important;
}

.swal2-cancel:hover {
  background-color: #e2e8f0 !important;
  color: #0f172a !important;
}

/* Toast Moderno de SweetAlert2 */
.swal2-container.swal2-top-end > .swal2-popup.swal2-toast {
  border-radius: 12px !important;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1) !important;
  padding: 12px 18px !important;
  font-family: var(--font-main) !important;
  font-size: 0.88rem !important;
  font-weight: 600 !important;
  border: 1px solid rgba(226, 232, 240, 0.8) !important;
  background: #ffffff !important;
}

/* Grupo de Búsqueda de Cliente Unificado */
.client-search-input-group {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.client-input-inner {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

.client-input-inner .client-input-icon {
  position: absolute;
  left: 14px;
  font-size: 1.05rem;
  color: #64748b;
  pointer-events: none;
  z-index: 2;
}

.client-input-inner input.form-control {
  padding-left: 40px !important;
  height: 44px;
  font-size: 0.925rem;
  width: 100%;
}

/* Botón Único de Búsqueda de Clientes (Estilo SaaS Premium) */
.btn-search-client-primary {
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  color: #ffffff !important;
  border: none;
  padding: 0 20px;
  height: 44px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-search-client-primary:hover {
  background: linear-gradient(135deg, #4338ca 0%, #4f46e5 100%);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.45);
  transform: translateY(-1.5px);
}

.btn-search-client-primary:active {
  transform: translateY(0) scale(0.98);
}

.btn-search-client-primary .btn-search-pill-counter {
  background: rgba(255, 255, 255, 0.24);
  color: #ffffff;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 800;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Tarjetas de Clientes en el Buscador */
.client-search-modal-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: all 0.2s ease;
  margin-bottom: 10px;
}

.client-search-modal-card:hover {
  border-color: #818cf8;
  background: #f8faff;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.1);
  transform: translateY(-1px);
}

/* Botón Cargar Estilizado en Verde Esmeralda Moderno */
.btn-select-client-modal {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff !important;
  border: none;
  padding: 8px 18px;
  border-radius: 9999px;
  font-size: 0.825rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 3px 10px rgba(16, 185, 129, 0.35);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}

.btn-select-client-modal:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.45);
  transform: translateY(-1.5px) scale(1.02);
}

.btn-select-client-modal:active {
  transform: translateY(0) scale(0.97);
}

.client-autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 1050;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  box-shadow: 0 12px 30px -4px rgba(15, 23, 42, 0.18), 0 4px 6px -2px rgba(15, 23, 42, 0.05);
  overflow: hidden;
  animation: fadeInDown 0.18s ease-out;
}

.client-autocomplete-header {
  padding: 8px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.client-autocomplete-list {
  max-height: 280px;
  overflow-y: auto;
}

.client-autocomplete-item {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: all 0.15s ease;
}

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

.client-autocomplete-item:hover,
.client-autocomplete-item.active {
  background: #f0f7ff;
  border-left: 3px solid #4f46e5;
  padding-left: 11px;
}

.client-avatar-badge {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #e0e7ff;
  color: #4338ca;
  font-weight: 700;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid #c7d2fe;
}

.field-highlight-success {
  animation: flashGreen 1.2s ease;
}

@keyframes flashGreen {
  0% {
    border-color: #10b981;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.35);
    background-color: #f0fdf4;
  }
  100% {
    border-color: inherit;
    box-shadow: inherit;
    background-color: inherit;
  }
}

/* Impresión */
@media print {
  body {
    background: #ffffff !important;
  }
  .sidebar, .top-navbar, .modal-overlay, .toast-container, .top-actions, .no-print {
    display: none !important;
  }
  .main-wrapper {
    margin-left: 0 !important;
  }
  .invoice-sheet {
    box-shadow: none !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
}
