/* css/new-features.css - Estilos para nuevas features */

/* ========== CALCULADORA DE VIABILIDAD ========== */
.viability-section {
  margin: 2rem 0;
}

.viability-results {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border-radius: 16px;
  padding: 1.5rem;
  border: 2px solid #bbf7d0;
}

.viability-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #15803d;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.viability-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.viability-card {
  background: white;
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.viability-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.viability-card--highlight {
  background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  color: white;
}

.viability-label {
  font-size: 0.875rem;
  color: #64748b;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.viability-card--highlight .viability-label {
  color: rgba(255,255,255,0.9);
}

.viability-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 0.25rem;
}

.viability-card--highlight .viability-value {
  color: white;
}

.viability-value--roi {
  color: #16a34a;
}

.viability-hint {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 0.25rem;
}

.viability-card--highlight .viability-hint {
  color: rgba(255,255,255,0.8);
}

.viability-disclaimer {
  margin-top: 1rem;
  padding: 1rem;
  background: rgba(255,255,255,0.7);
  border-radius: 8px;
  font-size: 0.875rem;
  color: #475569;
  line-height: 1.6;
}

/* ========== HISTORIAL DE BÚSQUEDAS ========== */
#search-history-container {
  background: white;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  margin-top: 1rem;
}

.search-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e2e8f0;
}

.search-history-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

.search-history-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.search-history-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  border-radius: 8px;
  transition: background 0.2s ease;
}

.search-history-item:hover {
  background: #f8fafc;
}

.search-history-item__button {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  padding: 0;
  color: #334155;
}

.search-history-item__button:hover {
  color: #16a34a;
}

.search-history-item__label {
  font-size: 0.875rem;
  font-weight: 500;
}

.search-history-item__remove {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.search-history-item__remove:hover {
  color: #ef4444;
  background: #fee2e2;
}

/* ========== NOTIFICACIONES ========== */
/* Campana sin fondo: solo icono, integrada al header (estilo limpio) */
.notification-bell {
  position: relative;
  padding: 0.4rem !important;
  min-width: 2.25rem !important;
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color 0.2s ease, background 0.2s ease;
  margin: 0 !important;
  border: none !important;
  background: transparent !important;
  cursor: pointer !important;
  z-index: 15 !important;
  pointer-events: auto !important;
  flex-shrink: 0;
  box-shadow: none !important;
  isolation: isolate;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 768px) {
  .notification-bell {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0.5rem !important;
  }
  .notification-bell svg {
    width: 1.25rem;
    height: 1.25rem;
  }
}

.notification-bell:hover {
  background: transparent !important;
  transform: none;
  box-shadow: none;
}

.notification-bell:active {
  transform: scale(0.96);
}

/* En móvil: no mostrar campana en el header (queda solo dentro del menú, más estético) */
@media (max-width: 768px) {
  .header-notifications {
    display: none !important;
  }
}

.header-notifications {
  display: flex;
  align-items: center;
  margin-right: 0;
  background: none !important;
  border: none !important;
  box-shadow: none !important;
}
.header-notifications:empty {
  display: none;
}

/* Asegurar que el contenedor nav-user tenga flex para alinear elementos */
#nav-user,
#navUser,
.nav-user,
.nav-auth-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* El botón de notificaciones debe estar separado del dropdown */
.notification-bell {
  order: 1; /* Aparece después del botón Publicar pero antes del dropdown */
}

.nav-dropdown {
  order: 2; /* El dropdown del perfil va al final */
}

.notification-bell:hover {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none;
}

.notification-bell:active {
  transform: scale(0.95);
}

.notification-bell:focus {
  outline: 2px solid rgba(22, 163, 74, 0.3);
  outline-offset: 2px;
}

.notification-bell svg {
  width: 1.25rem;
  height: 1.25rem;
  stroke-width: 2;
  color: #64748b;
  transition: color 0.2s ease;
  pointer-events: none;
}

.notification-bell:hover svg {
  color: #16a34a;
}

.notification-badge {
  position: absolute;
  top: 0;
  right: 0;
  background: #ef4444;
  color: white;
  font-size: 0.625rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 10px;
  min-width: 16px;
  height: 16px;
  text-align: center;
  line-height: 1.2;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  animation: pulse-badge 2s ease-in-out infinite;
}

@keyframes pulse-badge {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.notification-panel {
  position: fixed !important;
  top: 70px !important;
  right: 1rem !important;
  width: 380px !important;
  max-width: calc(100vw - 2rem) !important;
  max-height: calc(100vh - 100px) !important;
  background: white !important;
  border-radius: 12px !important;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15) !important;
  z-index: 10000 !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

.notification-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid #e2e8f0;
}

.notification-panel-header h3 {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0;
}

.notification-panel-body {
  overflow-y: auto;
  max-height: calc(100vh - 180px);
}

.notification-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background 0.2s ease;
}

.notification-item:hover {
  background: #f8fafc;
}

.notification-item.unread {
  background: #f0fdf4;
  border-left: 3px solid #16a34a;
}

.notification-item-content {
  flex: 1;
}

.notification-item-title {
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
}

.notification-item-message {
  color: #64748b;
  font-size: 0.8125rem;
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.notification-item-time {
  font-size: 0.75rem;
  color: #94a3b8;
}

.notification-item-link {
  color: #16a34a;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.notification-item-link:hover {
  text-decoration: underline;
}

.notification-toast {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
  padding: 1rem;
  min-width: 300px;
  max-width: 400px;
  z-index: 10001;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
  border-left: 4px solid #16a34a;
}

.notification-toast.show {
  transform: translateY(0);
  opacity: 1;
}

.notification-toast--success {
  border-left-color: #16a34a;
}

.notification-toast--error {
  border-left-color: #ef4444;
}

.notification-toast--warning {
  border-left-color: #f59e0b;
}

.notification-toast-content {
  flex: 1;
}

.notification-toast-content strong {
  display: block;
  margin-bottom: 0.25rem;
  color: #0f172a;
}

.notification-toast-content div {
  color: #64748b;
  font-size: 0.875rem;
}

.notification-toast-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.25rem;
}

.notification-toast-close:hover {
  color: #64748b;
}

/* ========== LAZY LOADING ========== */
.lazy-image {
  opacity: 0.7;
  transition: opacity 0.3s ease;
}

.lazy-image.lazy-loaded {
  opacity: 1;
}

.lazy-placeholder {
  background: #f1f5f9;
  background-image: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ========== COMPARADOR MEJORADO ========== */
.compare-bar__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.compare-card-footer {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #e2e8f0;
}

/* ========== CALCULADORA DE CRÉDITO (colapsable, cerrada por defecto) ========== */
.credit-calculator-section {
  margin-top: 1.5rem;
  margin-bottom: 0;
  width: 100%;
  max-width: 100%;
}

.credit-calculator {
  background: #fff;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
  overflow: hidden;
  width: 100%;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.credit-calculator:hover {
  border-color: #cbd5e1;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.credit-calculator-collapsible.is-open .credit-calculator {
  border-color: #16a34a;
  box-shadow: 0 4px 14px rgba(22, 163, 74, 0.12);
}

/* Botón para desplegar: siempre visible; contenido oculto por defecto */
.credit-calculator-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: none;
  border-bottom: 1px solid #e2e8f0;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
  text-align: left;
  transition: background 0.2s ease, color 0.2s ease;
}

.credit-calculator-toggle:hover {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  color: #15803d;
}

.credit-calculator-collapsible.is-open .credit-calculator-toggle {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  color: #15803d;
  border-bottom-color: #bbf7d0;
}

.credit-calculator-toggle-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(22, 163, 74, 0.12);
  color: #16a34a;
  border-radius: 6px;
  font-size: 0.65rem;
  font-weight: 800;
  transition: transform 0.25s ease, background 0.2s ease;
}

.credit-calculator-toggle:hover .credit-calculator-toggle-icon {
  background: rgba(22, 163, 74, 0.2);
}

/* Flecha hacia abajo cuando está cerrada, hacia arriba cuando abierta */
.credit-calculator-collapsible:not(.is-open) .credit-calculator-toggle-icon {
  transform: rotate(0deg);
}

.credit-calculator-collapsible.is-open .credit-calculator-toggle-icon {
  transform: rotate(180deg);
}

.credit-calculator-body {
  padding: 1.25rem 1.25rem 1.5rem;
  background: #fafafa;
  border-top: none;
}

/* Cerrado por defecto: no mostrar el cuerpo hasta que el usuario despliegue */
.credit-calculator-body[hidden],
.credit-calculator-collapsible:not(.is-open) .credit-calculator-body {
  display: none !important;
  overflow: hidden;
  padding-top: 0;
  padding-bottom: 0;
  border-top: none;
}

.credit-calculator-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0284c7;
  margin-bottom: 0.5rem;
}

.credit-calculator-subtitle {
  color: #64748b;
  font-size: 0.875rem;
  margin-top: 0;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.credit-calculator-form {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem 1.25rem;
  margin-bottom: 1.25rem;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.credit-form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.credit-form-group {
  display: flex;
  flex-direction: column;
}

.credit-form-group label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.5rem;
}

.credit-form-group input,
.credit-form-group select {
  padding: 0.75rem 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 1rem;
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.credit-form-group select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23475569' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
}
/* Ocultar flechas del number input */
.credit-form-group input[type="number"]::-webkit-outer-spin-button,
.credit-form-group input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.credit-form-group input[type="number"] {
  -moz-appearance: textfield;
}

.credit-form-group input:focus,
.credit-form-group select:focus {
  outline: none;
  border-color: #16a34a;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12);
}

.credit-hint {
  font-weight: 400;
  color: #94a3b8;
  font-size: 0.75rem;
}

/* Botón Calcular: estilo TerreNet */
#credit-calculator-widget .btn-primary,
.credit-calculator .btn-primary {
  background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  color: #fff;
  font-weight: 700;
  padding: 0.875rem 1.25rem;
  border-radius: 10px;
  border: none;
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.3);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.credit-calculator .btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.35);
}

.credit-results {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  margin-top: 1.25rem;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.credit-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.credit-result-card {
  background: #f8fafc;
  border-radius: 12px;
  padding: 1.125rem 1rem;
  text-align: center;
  border: 1px solid #e2e8f0;
  transition: all 0.2s ease;
}

.credit-result-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.credit-result-card--highlight {
  background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  color: #fff;
  border-color: #15803d;
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.25);
}

.credit-result-card--highlight:hover {
  box-shadow: 0 6px 16px rgba(22, 163, 74, 0.3);
}

.credit-result-card--info {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border-color: #86efac;
}

.credit-result-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.credit-result-card--highlight .credit-result-label {
  color: rgba(255,255,255,0.9);
}

.credit-result-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 0.25rem;
}

.credit-result-card--highlight .credit-result-value {
  color: white;
}

.credit-result-value--large {
  font-size: 2rem;
}

.credit-result-hint {
  font-size: 0.75rem;
  color: #94a3b8;
}

.credit-result-card--highlight .credit-result-hint {
  color: rgba(255,255,255,0.8);
}

.credit-disclaimer {
  margin-top: 1.25rem;
  padding: 1.25rem 1.5rem;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border-radius: 12px;
  font-size: 0.8125rem;
  color: #78350f;
  line-height: 1.65;
  border: 1px solid #fcd34d;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.credit-disclaimer p {
  margin: 0 0 0.75rem 0;
}
.credit-disclaimer p:last-child {
  margin-bottom: 0;
}

.credit-warning {
  margin-top: 1rem;
  padding: 1rem;
  background: #fef3c7;
  border-radius: 8px;
  border-left: 4px solid #f59e0b;
  color: #92400e;
  font-size: 0.875rem;
  line-height: 1.6;
}

.credit-bank-links {
  margin-top: 0.75rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.credit-bank-links a {
  display: inline-flex;
  align-items: center;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
  color: #475569;
  text-decoration: none;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.credit-bank-links a:hover {
  border-color: #16a34a;
  color: #16a34a;
  background: #f0fdf4;
}

/* Responsive */
@media (max-width: 768px) {
  .notification-panel {
    right: 0.5rem;
    left: 0.5rem;
    width: auto;
    max-width: none;
  }

  .viability-grid,
  .credit-results-grid {
    grid-template-columns: 1fr;
  }

  .notification-toast {
    right: 0.5rem;
    left: 0.5rem;
    min-width: auto;
    max-width: none;
  }

  .credit-form-row {
    grid-template-columns: 1fr;
  }
}
