/* ═══════════════════════════════════════════════════
   CRM Core — Frontend styles
   ═══════════════════════════════════════════════════ */

/* ── Layout base ── */
.crm-core-app .crm-core-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 20px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: #1f2937;
}

.crm-core-app .crm-core-container h1 {
  font-size: 22px;
  font-weight: 700;
  color: #111827;
  margin: 0 0 16px;
  letter-spacing: -.3px;
}

/* ── Navegación ── */
.crm-core-app .crm-core-container .crm-core-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 28px;
  padding: 0 0 16px;
  border-bottom: 1px solid #e5e7eb;
}

.crm-core-app .crm-core-container .crm-core-nav .crm-core-nav-link {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 6px;
  text-decoration: none !important;
  color: #374151 !important;
  font-size: 13px;
  font-weight: 500;
  transition: background .12s, color .12s;
}

.crm-core-app .crm-core-container .crm-core-nav .crm-core-nav-link:hover {
  background: #f3f4f6;
  color: #111827 !important;
}

.crm-core-app .crm-core-container .crm-core-nav .crm-core-nav-link.is-active,
.crm-core-app .crm-core-container .crm-core-nav .crm-core-nav-link.is-active:visited,
.crm-core-app .crm-core-container .crm-core-nav .crm-core-nav-link.is-active:hover {
  background: #1d4ed8 !important;
  color: #ffffff !important;
  font-weight: 600 !important;
  border-bottom: none !important;
  text-decoration: none !important;
}

/* ── Sección contenido ── */
.crm-core-section {
  margin-top: 4px;
}

/* ── Formularios ── */
.crm-core-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 20px;
}

.crm-core-form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.crm-core-label {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.crm-core-input,
.crm-core-select {
  padding: 7px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  color: #1f2937;
  background: #fff;
  min-width: 150px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.crm-core-input:focus,
.crm-core-select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

/* ── Botones ── */
.crm-core-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 16px;
  background: #1d4ed8;
  color: #fff !important;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none !important;
  transition: background .12s;
  white-space: nowrap;
}

.crm-core-button:hover {
  background: #1e40af;
}

.crm-core-button-danger {
  background: #dc2626 !important;
}

.crm-core-button-danger:hover {
  background: #b91c1c !important;
}

.crm-core-button-secondary {
  background: #6b7280 !important;
}

.crm-core-button-secondary:hover {
  background: #4b5563 !important;
}

/* ── Tablas ── */
.crm-core-table-wrapper {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  margin-bottom: 8px;
}

.crm-core-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.crm-core-th {
  text-align: left;
  padding: 10px 14px;
  background: #f9fafb;
  border-bottom: 2px solid #e5e7eb;
  font-weight: 600;
  color: #374151;
  white-space: nowrap;
}

.crm-core-td {
  padding: 10px 14px;
  border-bottom: 1px solid #f3f4f6;
  color: #374151;
  vertical-align: top;
}

.crm-core-tr:last-child .crm-core-td {
  border-bottom: none;
}

.crm-core-tr:hover .crm-core-td {
  background: #f9fafb;
}

/* ── Formularios inline en celdas ── */
.crm-core-inline-form {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 5px;
  margin-bottom: 5px;
}

.crm-core-inline-form:last-child {
  margin-bottom: 0;
}

.crm-core-inline-form .crm-core-input {
  min-width: 0;
  width: 120px;
  flex-shrink: 1;
}

.crm-core-inline-form .crm-core-select {
  min-width: 0;
  width: 110px;
  flex-shrink: 1;
}

.crm-core-inline-form .crm-core-button {
  padding: 5px 10px;
  font-size: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── UUID truncado ── */
.crm-uuid {
  display: inline-block;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
  font-size: 12px;
  font-family: monospace;
  color: #6b7280;
}

/* ── Links ── */
.crm-core-link {
  color: #2563eb;
  text-decoration: none;
  font-weight: 500;
}

.crm-core-link:hover {
  text-decoration: underline;
}

/* ── Total + paginación ── */
.crm-core-total {
  font-size: 13px;
  color: #6b7280;
  padding: 10px 14px 2px;
}

.crm-core-pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 14px 10px;
  font-size: 13px;
  color: #6b7280;
  border-top: 1px solid #f3f4f6;
}

.crm-core-pagination .crm-core-link {
  padding: 4px 10px;
  background: #f3f4f6;
  border-radius: 5px;
  color: #374151 !important;
  font-weight: 500;
}

.crm-core-pagination .crm-core-link:hover {
  background: #e5e7eb;
  text-decoration: none;
}

/* ── Panel de detalle ── */
.crm-core-panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 20px 24px;
  margin-bottom: 24px;
}

.crm-core-panel-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e5e7eb;
  color: #111827;
}

.crm-core-panel-subtitle {
  font-size: 14px;
  font-weight: 600;
  margin: 16px 0 10px;
  color: #374151;
}

.crm-core-panel-row {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  margin-bottom: 16px;
}

.crm-core-panel-col {
  flex: 1;
  min-width: 200px;
}

.crm-core-text {
  margin-bottom: 6px;
  font-size: 13px;
  color: #374151;
}

.crm-core-list {
  margin: 4px 0 0 16px;
  padding: 0;
  font-size: 13px;
  color: #374151;
}

.crm-core-list-item {
  margin-bottom: 3px;
}

/* ── Mensajes vacíos / sin permisos ── */
.crm-core-empty {
  color: #9ca3af;
  font-style: italic;
  padding: 12px 0;
}

/* ── Acciones (barra sobre tabla) ── */
.crm-core-actions {
  margin-bottom: 14px;
}

/* ═══════════════════════════════════════════════════
   Dashboard frontend
   ═══════════════════════════════════════════════════ */
.crm-fe-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 8px 0 32px;
}

.crm-fe-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 22px 30px;
  min-width: 130px;
  text-decoration: none !important;
  color: inherit !important;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
  transition: box-shadow .15s, transform .15s;
}

.crm-fe-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
  transform: translateY(-2px);
}

.crm-fe-card-icon {
  font-size: 26px;
  margin-bottom: 8px;
  line-height: 1;
}

.crm-fe-card-icon.crm-icon-users::before    { content: "👥"; }
.crm-fe-card-icon.crm-icon-records::before  { content: "📋"; }
.crm-fe-card-icon.crm-icon-active::before   { content: "🟢"; }
.crm-fe-card-icon.crm-icon-segments::before { content: "🏷️"; }

.crm-fe-card-value {
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  color: #111827;
}

.crm-fe-card-label {
  font-size: 12px;
  color: #6b7280;
  margin-top: 5px;
  text-align: center;
}

.crm-fe-section-title {
  font-size: 15px;
  font-weight: 600;
  margin: 28px 0 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid #e5e7eb;
  color: #111827;
}

.crm-fe-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}

.crm-fe-shortcut {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  text-decoration: none !important;
  color: #0369a1 !important;
  font-size: 13px;
  font-weight: 500;
  transition: background .12s;
}

.crm-fe-shortcut:hover {
  background: #e0f2fe;
}

.crm-fe-table-wrap {
  overflow-x: auto;
}

.crm-fe-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.crm-fe-table th {
  text-align: left;
  padding: 8px 12px;
  background: #f9fafb;
  border-bottom: 2px solid #e5e7eb;
  font-weight: 600;
  color: #374151;
}

.crm-fe-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #f3f4f6;
  color: #374151;
}

.crm-fe-table tbody tr:hover td {
  background: #f9fafb;
}

.crm-fe-table a {
  color: #2563eb;
  text-decoration: none;
}

.crm-fe-table a:hover {
  text-decoration: underline;
}

.crm-fe-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  background: #f3f4f6;
  color: #374151;
}

.crm-fe-empty {
  color: #9ca3af;
  font-style: italic;
  margin: 8px 0;
}

/* ═══════════════════════════════════════════════════
   Dashboard admin (wp-admin)
   ═══════════════════════════════════════════════════ */
.crm-core-version-badge {
  font-size: 13px;
  font-weight: normal;
  color: #888;
}

.crm-core-dash-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 20px 0 28px;
}

.crm-core-dash-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 20px 28px;
  min-width: 140px;
  text-decoration: none !important;
  color: inherit !important;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  transition: box-shadow .15s;
}

.crm-core-dash-card:hover {
  box-shadow: 0 3px 8px rgba(0,0,0,.12);
}

.crm-core-card-icon {
  font-size: 28px;
  width: 28px;
  height: 28px;
  color: #2271b1;
  margin-bottom: 8px;
}

.crm-core-card-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  color: #1d2327;
}

.crm-core-card-label {
  font-size: 12px;
  color: #888;
  margin-top: 4px;
  text-align: center;
}

.crm-core-dash-section {
  font-size: 14px;
  font-weight: 600;
  margin: 24px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #eee;
}

.crm-core-dash-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}

.crm-core-shortcut {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #f0f6fc;
  border: 1px solid #c3d9f0;
  border-radius: 6px;
  text-decoration: none !important;
  color: #2271b1 !important;
  font-size: 13px;
}

.crm-core-shortcut:hover {
  background: #dbeafe;
}

.crm-core-dash-table {
  margin-bottom: 4px;
}

.crm-core-dash-empty {
  color: #888;
  font-style: italic;
}

.crm-core-status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  background: #f0f0f0;
  color: #444;
}

.crm-core-badge-ok {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  background: #d1fae5;
  color: #065f46;
}

.crm-core-badge-off {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  background: #f3f4f6;
  color: #6b7280;
}

.crm-core-sysinfo th {
  font-weight: 600;
}

/* ═══════════════════════════════════════════════════
   Footer
   ═══════════════════════════════════════════════════ */
.crm-core-footer {
  margin-top: 40px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
  font-size: 12px;
  color: #9ca3af;
  text-align: right;
}

.crm-core-footer a {
  color: #6b7280;
}

.crm-core-footer a:hover {
  color: #111827;
}
