/**
 * Smart Import - Document Type Selector Styles
 * Versión: 2.1.0 (FREE/PRO Mode Selector)
 */

/* ===== Contenedor Principal ===== */
.smart-import-selector {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ===== Header ===== */
.selector-header {
  text-align: center;
  margin-bottom: 24px;
}

.selector-header h3 {
  font-size: 24px;
  color: #1a202c;
  margin: 0 0 8px 0;
}

.selector-subtitle {
  color: #718096;
  font-size: 14px;
  margin: 0;
}

/* ===== Indicador FREE ===== */
.free-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 14px;
}

.free-indicator.success {
  background: #f0fff4;
  color: #22543d;
  border: 1px solid #9ae6b4;
}

.free-indicator.info {
  background: #ebf8ff;
  color: #2c5282;
  border: 1px solid #90cdf4;
}

.free-indicator .icon {
  font-size: 20px;
}

/* ===== Grid de Tipos ===== */
.type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.type-card {
  background: white;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

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

.type-card.selected {
  border-color: #3182ce;
  box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}

.type-card.free {
  border-left: 4px solid #48bb78;
}

.type-card.pro {
  border-left: 4px solid #ed8936;
}

.type-card.variable {
  border-left: 4px solid #805ad5;
}

.type-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.type-name {
  font-weight: 600;
  font-size: 14px;
  color: #2d3748;
  margin-bottom: 4px;
}

.type-description {
  font-size: 12px;
  color: #718096;
  line-height: 1.4;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.type-tier-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
  margin-bottom: 8px;
}

.type-card.free .type-tier-badge {
  background: #c6f6d5;
  color: #22543d;
}

.type-card.pro .type-tier-badge {
  background: #feebc8;
  color: #7c2d12;
}

.type-card.variable .type-tier-badge {
  background: #e9d8fd;
  color: #44337a;
}

.type-accuracy {
  font-size: 11px;
  color: #a0aec0;
  margin-bottom: 8px;
}

.type-extracts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.extract-tag {
  font-size: 10px;
  padding: 2px 6px;
  background: #edf2f7;
  color: #4a5568;
  border-radius: 4px;
}

.extract-tag.more {
  background: #cbd5e0;
}

/* ===== Detalles Seleccionados ===== */
.selected-details {
  background: #f7fafc;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.selected-details h4 {
  margin: 0 0 16px 0;
  color: #2d3748;
  font-size: 16px;
}

.extracts-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.extract-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #4a5568;
}

.extract-item .check {
  color: #48bb78;
  font-weight: bold;
}

.tier-info {
  padding: 16px;
  border-radius: 8px;
  margin-top: 16px;
}

.tier-free {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #f0fff4;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #9ae6b4;
}

.tier-pro {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #fffaf0;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #fbd38d;
}

.tier-info .icon {
  font-size: 24px;
}

.tier-info strong {
  display: block;
  color: #2d3748;
  margin-bottom: 4px;
}

.tier-info p {
  margin: 0;
  font-size: 13px;
  color: #718096;
}

.tier-info .cost {
  margin-top: 8px;
  color: #c05621;
}

/* ===== Botón de Analizar ===== */
.analyze-section {
  text-align: center;
  padding: 20px;
}

.btn-analyze {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-analyze.free {
  background: #48bb78;
  color: white;
}

.btn-analyze.free:hover {
  background: #38a169;
}

.btn-analyze.pro {
  background: #ed8936;
  color: white;
}

.btn-analyze.pro:hover {
  background: #dd6b20;
}

.btn-analyze:disabled {
  background: #cbd5e0;
  cursor: not-allowed;
}

.btn-analyze.loading {
  opacity: 0.7;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.analyze-note {
  font-size: 13px;
  color: #718096;
  margin-top: 12px;
}

/* ===== Modales ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: white;
  border-radius: 16px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #e2e8f0;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  color: #2d3748;
}

.btn-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #a0aec0;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

.btn-close:hover {
  background: #edf2f7;
  color: #4a5568;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid #e2e8f0;
  background: #f7fafc;
}

/* ===== Modal de Upgrade ===== */
.upgrade-offer {
  background: #fffaf0;
  border: 1px solid #fbd38d;
  border-radius: 8px;
  padding: 16px;
  margin: 16px 0;
}

.upgrade-offer h4 {
  margin: 0 0 12px 0;
  color: #7c2d12;
}

.upgrade-offer .benefits {
  list-style: none;
  padding: 0;
  margin: 0 0 12px 0;
}

.upgrade-offer .benefits li {
  padding: 4px 0;
  font-size: 13px;
  color: #744210;
}

.upgrade-offer .cost {
  font-size: 18px;
  color: #c05621;
}

.partial-data {
  margin-top: 16px;
}

.partial-data h5 {
  margin: 0 0 8px 0;
  color: #4a5568;
}

.partial-data pre {
  background: #f7fafc;
  padding: 12px;
  border-radius: 6px;
  font-size: 12px;
  overflow-x: auto;
  max-height: 200px;
  overflow-y: auto;
}

/* ===== Modal de Resultados ===== */
.result-tier {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px;
  border-radius: 8px;
}

.result-tier.free {
  background: #f0fff4;
}

.result-tier.pro {
  background: #fffaf0;
}

.tier-badge {
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 4px;
}

.result-tier.free .tier-badge {
  background: #9ae6b4;
  color: #22543d;
}

.result-tier.pro .tier-badge {
  background: #fbd38d;
  color: #7c2d12;
}

.confidence {
  font-size: 13px;
  color: #718096;
}

.result-data pre {
  background: #f7fafc;
  padding: 16px;
  border-radius: 8px;
  font-size: 12px;
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
}

/* ===== Botones Generales ===== */
.btn-primary, .btn-secondary, .btn-pro {
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.btn-primary {
  background: #3182ce;
  color: white;
}

.btn-primary:hover {
  background: #2c5282;
}

.btn-pro {
  background: #ed8936;
  color: white;
}

.btn-pro:hover {
  background: #dd6b20;
}

.btn-secondary {
  background: white;
  color: #4a5568;
  border: 1px solid #e2e8f0;
}

.btn-secondary:hover {
  background: #f7fafc;
}

/* ===== Loading ===== */
.loading {
  text-align: center;
  padding: 40px;
  color: #718096;
}

/* ===== ESTILOS PARA SELECTOR DE MODO EN smart-import-ui.js ===== */

/* Selector de modo de análisis */
.smart-import-doc__mode-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  padding: 10px;
  background: #f7fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.smart-import-doc__select-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.smart-import-doc__select-group label {
  font-size: 12px;
  font-weight: 600;
  color: #4a5568;
  min-width: 45px;
}

.smart-import-doc__mode-select,
.smart-import-doc__type-select {
  padding: 6px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
  background: white;
  color: #2d3748;
  cursor: pointer;
  flex: 1;
  min-width: 140px;
  transition: border-color 0.2s;
}

.smart-import-doc__mode-select:hover,
.smart-import-doc__type-select:hover {
  border-color: #cbd5e0;
}

.smart-import-doc__mode-select:focus,
.smart-import-doc__type-select:focus {
  outline: none;
  border-color: #3182ce;
  box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}

/* Badges de tier */
.smart-import-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.smart-import-badge--free {
  background: #c6f6d5;
  color: #22543d;
}

.smart-import-badge--pro {
  background: #feebc8;
  color: #7c2d12;
}

/* Info box de tier en preview */
.smart-import-tier-info {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}

.smart-import-tier-info--free {
  background: #f0fff4;
  border: 1px solid #9ae6b4;
  color: #22543d;
}

.smart-import-tier-info--pro {
  background: #fffaf0;
  border: 1px solid #fbd38d;
  color: #7c2d12;
}

.smart-import-tier-icon {
  font-size: 24px;
}

.smart-import-tier-info strong {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
}

.smart-import-tier-info p {
  margin: 0;
  font-size: 13px;
  opacity: 0.9;
}

/* Ajustes para la fila de documento */
.smart-import-doc {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 8px;
  background: #fafafa;
}

.smart-import-doc__meta {
  flex: 1;
  min-width: 0;
}

.smart-import-doc__meta strong {
  display: block;
  margin-bottom: 4px;
  color: #2d3748;
  font-size: 14px;
}

.smart-import-doc__meta > span:not(.smart-import-doc__tag):not(.smart-import-badge) {
  color: #718096;
  font-size: 12px;
}

.smart-import-doc__tag {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 10px;
  background: #edf2f7;
  border-radius: 4px;
  font-size: 11px;
  color: #4a5568;
}

.smart-import-doc__actions {
  display: flex;
  gap: 8px;
  margin-left: 12px;
  flex-shrink: 0;
}

/* Responsive para móviles */
@media (max-width: 640px) {
  .type-grid {
    grid-template-columns: 1fr;
  }

  .extracts-list {
    grid-template-columns: 1fr;
  }

  .modal-content {
    margin: 10px;
    max-height: calc(100vh - 20px);
  }

  .smart-import-doc {
    flex-direction: column;
    gap: 12px;
  }

  .smart-import-doc__actions {
    margin-left: 0;
    width: 100%;
    justify-content: flex-end;
  }

  .smart-import-doc__mode-selector {
    width: 100%;
  }

  .smart-import-doc__select-group {
    flex-wrap: wrap;
  }

  .smart-import-doc__mode-select,
  .smart-import-doc__type-select {
    min-width: 0;
    width: 100%;
  }
}

/* =============================================================================
   NORMA CODE DARK THEME OVERRIDES
   Adaptación al tema oscuro de NORMA CODE
   ============================================================================= */

.smart-import-selector {
  font-family: 'JetBrains Mono', 'Inter', monospace;
}

/* Contenedor documento - Dark theme */
.smart-import-doc {
  background: rgba(18, 18, 20, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.smart-import-doc__meta strong {
  color: #e4e4e7;
}

.smart-import-doc__meta > span:not(.smart-import-doc__tag):not(.smart-import-badge) {
  color: rgba(255, 255, 255, 0.5);
}

/* Selector de modo - Dark theme */
.smart-import-doc__mode-selector {
  background: rgba(18, 18, 20, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.smart-import-doc__select-group label {
  color: rgba(255, 255, 255, 0.6);
}

.smart-import-doc__mode-select,
.smart-import-doc__type-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  color-scheme: dark;
  background: #1a1a1c;
  border: 1px solid rgba(74, 222, 128, 0.3);
  border-radius: 6px;
  color: #e4e4e7;
  padding: 8px 32px 8px 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234ade80' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  min-width: 160px;
}

.smart-import-doc__mode-select:hover,
.smart-import-doc__type-select:hover {
  border-color: #4ade80;
  background-color: #222224;
}

.smart-import-doc__mode-select:focus,
.smart-import-doc__type-select:focus {
  outline: none;
  border-color: #4ade80;
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.2);
}

/* Options dentro de los selects - Dark theme */
.smart-import-doc__mode-select option,
.smart-import-doc__type-select option {
  background: #1a1a1c;
  color: #e4e4e7;
  padding: 8px 12px;
}

.smart-import-doc__mode-select option:hover,
.smart-import-doc__type-select option:hover,
.smart-import-doc__mode-select option:checked,
.smart-import-doc__type-select option:checked {
  background: #4ade80;
  color: #050505;
}

/* Badges - Dark theme compatible */
.smart-import-badge--free {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
}

.smart-import-badge--pro {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
}

/* Tags */
.smart-import-doc__tag {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.7);
}

/* Tier info box - Dark theme */
.smart-import-tier-info--free {
  background: rgba(74, 222, 128, 0.08);
  border: 1px solid rgba(74, 222, 128, 0.2);
  color: #4ade80;
}

.smart-import-tier-info--pro {
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.2);
  color: #fbbf24;
}

.smart-import-tier-info p {
  color: rgba(255, 255, 255, 0.6);
}

/* Botones - NORMA CODE style */
.btn-primary {
  background: #4ade80;
  color: #050505;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
}

.btn-primary:hover {
  background: #22c55e;
}

.btn-pro {
  background: #fbbf24;
  color: #050505;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
}

.btn-pro:hover {
  background: #f59e0b;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: #e4e4e7;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* =========================================
   ASSEMBLIES PREVIEW - Visualización de capas
   ========================================= */

.smart-import-preview-item--assemblies {
  flex-direction: column;
  align-items: flex-start;
  padding: 12px;
}

.smart-import-preview-item--assemblies > input[type="checkbox"] {
  position: absolute;
  top: 12px;
  left: 12px;
}

.smart-import-preview-item__content {
  width: 100%;
  padding-left: 24px;
}

.smart-import-preview-item__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.smart-import-preview-item__label {
  font-weight: 600;
  color: #e4e4e7;
}

.smart-import-preview-item__meta {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
}

.smart-import-assemblies-preview {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.smart-import-assembly {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.smart-import-assembly__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.smart-import-assembly__name {
  font-weight: 600;
  font-size: 12px;
  color: #4ade80;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.smart-import-assembly__uvalue {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
}

.smart-import-assembly__layers {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.smart-import-layer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 4px;
  font-size: 11px;
}

.smart-import-layer__name {
  color: #e4e4e7;
  font-weight: 500;
}

.smart-import-layer__props {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.5);
}

/* Colores de categoría como indicador visual */
.smart-import-layer[style*="border-left: 3px solid #4ade80"] .smart-import-layer__name::before {
  content: "🧱 ";
}

/* Responsive para pantallas pequeñas */
@media (max-width: 600px) {
  .smart-import-assembly__header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .smart-import-layer {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
}
