/* ===================================================================
   BLITZZIP MN - COMPONENTS
   Componentes reutilizables de la UI
   =================================================================== */

/* === Forms === */
label {
  display: grid;
  gap: var(--space-xs);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="file"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font: inherit;
  font-size: var(--font-size-base);
  line-height: 1.5;
  background: var(--bg-canvas);
  color: var(--text-primary);
  transition: all var(--transition-fast);
  min-height: 44px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(26, 111, 140, 0.15);
}

input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--bg-hover);
}

input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--gray-200);
  outline: none;
  -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  background: var(--brand-primary);
  cursor: pointer;
  border: 2px solid var(--bg-canvas);
  box-shadow: var(--shadow-sm);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  background: var(--brand-primary);
  cursor: pointer;
  border: 2px solid var(--bg-canvas);
  box-shadow: var(--shadow-sm);
}

.toggle {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  cursor: pointer;
}

.toggle input[type="checkbox"] {
  width: auto;
  cursor: pointer;
}

.inline-form {
  display: flex;
  gap: var(--space-md);
  align-items: stretch;
  flex-wrap: wrap;
}

.inline-form input,
.inline-form select {
  flex: 1;
  min-width: 200px;
}

.inline-form .btn {
  flex-shrink: 0;
}

.source-form {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: var(--space-md);
  align-items: start;
}

.source-form label:not(.toggle) {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.source-form .toggle {
  align-self: center;
}

.source-form .source-form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.path-picker-row {
  display: flex;
  gap: var(--space-sm);
  align-items: flex-end;
}

.path-picker-row label {
  flex: 1;
}

.path-picker-row .btn {
  flex-shrink: 0;
}

.source-form-actions {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font: inherit;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  background: var(--bg-canvas);
  color: var(--text-primary);
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
  min-height: 44px;
  line-height: 1.5;
}

.btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--brand-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-light));
  border: none;
  color: var(--text-on-brand);
  box-shadow: var(--shadow-sm);
}

.btn.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--brand-primary-dark), var(--brand-primary));
  box-shadow: var(--shadow-md);
}

.btn.secondary {
  background: linear-gradient(135deg, var(--brand-secondary), var(--brand-secondary-light));
  border: none;
  color: var(--text-on-brand);
  box-shadow: var(--shadow-sm);
}

.btn.secondary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--brand-secondary-dark), var(--brand-secondary));
  box-shadow: var(--shadow-md);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
}

.btn.ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

.btn.state-on {
  border-color: var(--color-success-border);
  background: var(--color-success-light);
  color: var(--color-success);
}

.btn.state-off {
  border-color: var(--color-error-border);
  background: var(--color-error-light);
  color: var(--color-error);
}

/* === Pills / Badges === */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  border-radius: var(--radius-full);
  padding: 6px 12px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  border: 1px solid var(--border-light);
  background: var(--bg-canvas);
  color: var(--text-secondary);
  white-space: nowrap;
}

.pill-warn {
  color: var(--color-warning-dark);
  background: var(--color-warning-light);
  border-color: var(--color-warning-border);
}

.pill-success {
  color: var(--color-success);
  background: var(--color-success-light);
  border-color: var(--color-success-border);
}

.pill-error {
  color: var(--color-error);
  background: var(--color-error-light);
  border-color: var(--color-error-border);
}

.pill-state {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-full);
  padding: 4px 10px;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  border: 1px solid;
}

.pill-state.on {
  color: var(--color-success);
  background: var(--color-success-light);
  border-color: var(--color-success-border);
}

.pill-state.off {
  color: var(--color-error);
  background: var(--color-error-light);
  border-color: var(--color-error-border);
}

/* === Tabs === */
.tabs {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

.tab {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 8px 14px;
  background: var(--bg-canvas);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tab:hover {
  background: var(--bg-hover);
  border-color: var(--brand-primary);
}

.tab.active {
  background: rgba(26, 111, 140, 0.1);
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  font-weight: var(--font-weight-semibold);
}

/* === Messages === */
.msg {
  min-height: 20px;
  margin: var(--space-sm) 0 0;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.msg.ok {
  color: var(--color-success);
  background: var(--color-success-light);
  border-left: 3px solid var(--color-success);
}

.msg.err {
  color: var(--color-error);
  background: var(--color-error-light);
  border-left: 3px solid var(--color-error);
}

.msg.warn {
  color: var(--color-warning-dark);
  background: var(--color-warning-light);
  border-left: 3px solid var(--color-warning);
}

/* === Headers === */
.result-head,
.dashboard-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

/* === Collapsible Sections === */
.collapsible-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  cursor: pointer;
  user-select: none;
  padding: var(--space-xs) 0;
  margin-bottom: var(--space-md);
}

.collapsible-header:hover {
  opacity: 0.8;
}

.collapsible-header h3 {
  margin: 0;
  flex: 1;
}

.collapse-toggle {
  background: transparent;
  border: none;
  font-size: var(--font-size-lg);
  cursor: pointer;
  padding: var(--space-xs);
  color: var(--text-secondary);
  transition: transform var(--transition-fast);
  line-height: 1;
}

.collapse-toggle[aria-expanded="true"] {
  transform: rotate(180deg);
}

.collapsible-content {
  animation: slideDown var(--transition-base);
}

.collapsible-content[hidden] {
  display: none;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* === Source Items === */
.source-list {
  margin-top: var(--space-md);
  display: grid;
  gap: var(--space-md);
}

.source-item {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  background: var(--bg-canvas);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  transition: all var(--transition-fast);
}

.user-card-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--brand-primary), var(--brand-primary-dark));
  color: white;
  font-weight: 700;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.source-item:hover {
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-sm);
}

.source-left {
  display: grid;
  gap: var(--space-xs);
  min-width: 320px;
  flex: 1;
}

.source-left > div:first-child {
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.source-badges {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.source-item .meta {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.source-actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* === Progress Bars === */
.source-progress {
  display: grid;
  gap: var(--space-xs);
  margin-top: var(--space-sm);
}

.prog {
  display: grid;
  gap: var(--space-xs);
}

.prog-head {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.prog-bar {
  height: 6px;
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid var(--border-light);
  background: var(--gray-100);
}

.prog-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--transition-base);
}

.prog-bar.scan .prog-fill {
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-primary-light));
}

.prog-bar.index .prog-fill {
  background: linear-gradient(90deg, var(--color-success), #6FDCA0);
}

.prog-bar.proc .prog-fill {
  background: linear-gradient(90deg, var(--brand-secondary), var(--brand-secondary-light));
}

.prog-fill.indeterminate {
  width: 40% !important;
  animation: progmove 1.2s linear infinite;
}

@keyframes progmove {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(280%); }
}

/* === Results Grid === */
.results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-md);
  margin-top: var(--space-md);
  max-height: 70vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: var(--space-sm);
}

/* Scrollbar personalizado para resultados */
.results::-webkit-scrollbar {
  width: 8px;
}

.results::-webkit-scrollbar-track {
  background: var(--bg-canvas);
  border-radius: var(--radius-md);
}

.results::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.results::-webkit-scrollbar-thumb:hover {
  background: var(--brand-primary);
}

.result {
  padding: var(--space-md);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-canvas);
  transition: all var(--transition-fast);
}

/* Load More Button */
.load-more-btn {
  grid-column: 1 / -1;
  margin-top: var(--space-md);
}

/* === Source Control Buttons === */
.source-controls {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.btn-control {
  min-width: 80px;
  padding: 8px 12px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  border-radius: var(--radius-md);
  border: 1px solid;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.btn-control:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-play {
  background: linear-gradient(135deg, #10B981, #059669);
  border-color: #059669;
  color: white;
}

.btn-play:hover:not(:disabled) {
  background: linear-gradient(135deg, #059669, #047857);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  transform: translateY(-1px);
}

.btn-pause {
  background: linear-gradient(135deg, #F59E0B, #D97706);
  border-color: #D97706;
  color: white;
}

.btn-pause:hover:not(:disabled) {
  background: linear-gradient(135deg, #D97706, #B45309);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
  transform: translateY(-1px);
}

.btn-stop {
  background: linear-gradient(135deg, #EF4444, #DC2626);
  border-color: #DC2626;
  color: white;
}

.btn-stop:hover:not(:disabled) {
  background: linear-gradient(135deg, #DC2626, #B91C1C);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
  transform: translateY(-1px);
}

.result:hover {
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.result img {
  width: 100%;
  aspect-ratio: 1/1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--gray-100);
  transition: transform var(--transition-fast);
}

.result img:hover {
  transform: scale(1.02);
}

.result .meta {
  margin-top: var(--space-sm);
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  word-break: break-all;
}

/* === Image Upload Area === */
.image-query-box {
  margin-top: var(--space-md);
  display: grid;
  gap: var(--space-sm);
}

.image-drop-zone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-xl);
  text-align: center;
  color: var(--text-muted);
  background: var(--bg-canvas);
  transition: all var(--transition-fast);
  cursor: pointer;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
}

.image-drop-zone:hover,
.image-drop-zone:focus {
  border-color: var(--brand-primary);
  background: rgba(26, 111, 140, 0.05);
  color: var(--brand-primary);
}

.image-drop-zone.dragover {
  border-color: var(--brand-secondary);
  background: rgba(229, 169, 53, 0.1);
  color: var(--brand-secondary-dark);
  border-style: solid;
}

#image-preview-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
}

#image-preview {
  max-width: 100%;
  max-height: 150px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

#btn-clear-image {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-size-sm);
}

/* === Search Controls Row === */
.search-controls-row {
  margin-top: var(--space-md);
  display: flex;
  gap: var(--space-xl);
  align-items: flex-start;
  flex-wrap: wrap;
}

/* === Relevance Controls === */
.relevance-controls {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--space-sm);
  align-items: center;
  flex: 1;
  min-width: 280px;
}

.relevance-controls label {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  font-weight: var(--font-weight-normal);
}

/* === Limit Controls === */
.limit-controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  min-width: 200px;
}

.limit-controls label {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  font-weight: var(--font-weight-normal);
}

.limit-controls input[type="number"] {
  width: 100px;
  padding: 8px 12px;
  font-size: var(--font-size-sm);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-canvas);
  color: var(--text-primary);
}

/* === Responsive Components === */
@media (max-width: 900px) {
  .source-form {
    grid-template-columns: 1fr;
  }

  .path-picker-row {
    flex-direction: column;
    align-items: stretch;
  }

  .source-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .source-left {
    min-width: auto;
    width: 100%;
  }

  .source-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 768px) {
  .inline-form {
    grid-template-columns: 1fr;
  }

  .search-controls-row {
    flex-direction: column;
    gap: var(--space-md);
  }

  .relevance-controls {
    grid-template-columns: 1fr;
    gap: var(--space-xs);
    width: 100%;
  }

  .limit-controls {
    width: 100%;
  }

  .limit-controls input[type="number"] {
    width: 100%;
  }

  .results {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--space-sm);
  }
}

@media (max-width: 480px) {
  .tabs {
    width: 100%;
  }

  .tab {
    flex: 1;
    text-align: center;
    padding: 6px 10px;
    font-size: var(--font-size-xs);
  }
}


/* === Indicador de fortaleza de contraseña === */
.pwd-strength-wrap {
  margin-top: var(--space-xs);
  display: grid;
  gap: var(--space-xs);
}

.pwd-strength-bar {
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--gray-200);
  overflow: hidden;
}

.pwd-strength-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--transition-base), background var(--transition-base);
}

.pwd-strength-fill.pwd-strength-weak   { background: #ef4444; }
.pwd-strength-fill.pwd-strength-medium { background: #f59e0b; }
.pwd-strength-fill.pwd-strength-good   { background: #3b82f6; }
.pwd-strength-fill.pwd-strength-strong { background: var(--color-success); }

.pwd-strength-checks {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs) var(--space-sm);
}

.pwd-check {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.pwd-check.ok { color: var(--color-success); }

/* === 2FA — Paneles === */
#panel-2fa-verify,
#panel-2fa-setup {
  max-width: 460px;
  margin: 0 auto;
  text-align: center;
}

.twofa-icon {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: var(--space-md);
}

.twofa-otp-input {
  font-size: 2rem !important;
  font-weight: var(--font-weight-bold) !important;
  letter-spacing: 0.5em;
  text-align: center !important;
  padding: var(--space-lg) !important;
  font-family: var(--font-mono) !important;
}

.twofa-backup-section {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-light);
  text-align: left;
}

.twofa-qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: var(--space-xl) 0;
  min-height: 200px;
  justify-content: center;
}

.twofa-qr {
  width: 200px;
  height: 200px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  background: white;
  display: block;
}

.twofa-qr-loading {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  animation: twofapulse 1.5s ease-in-out infinite;
}

@keyframes twofapulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.twofa-manual {
  text-align: left;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  margin-top: var(--space-md);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.twofa-manual summary {
  cursor: pointer;
  font-weight: var(--font-weight-medium);
  list-style: none;
}

.twofa-manual summary::-webkit-details-marker { display: none; }

.twofa-manual-body { padding-top: var(--space-sm); }

.twofa-secret-code {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--font-size-base);
  letter-spacing: 0.12em;
  background: var(--gray-100);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  word-break: break-all;
  user-select: all;
  margin-top: var(--space-xs);
}

.twofa-backup-codes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
  text-align: left;
}

.twofa-backup-code {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  background: var(--gray-100);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: var(--space-xs) var(--space-sm);
  text-align: center;
  letter-spacing: 0.08em;
  user-select: all;
}

@media (max-width: 480px) {
  .twofa-backup-codes { grid-template-columns: 1fr; }
  .twofa-otp-input {
    font-size: 1.5rem !important;
    letter-spacing: 0.35em;
  }
}

/* === Language Selector === */
.language-selector {
  position: relative;
}

.lang-btn {
  padding: 8px 12px !important;
  font-size: var(--font-size-sm);
  min-width: 80px;
}

.lang-btn #current-lang {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-xs);
  z-index: var(--z-dropdown);
  animation: slideDown 200ms ease;
}

.dropdown[hidden] {
  display: none;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dropdown-item {
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 8px;
}

.dropdown-item:hover {
  background: var(--bg-hover);
}

.dropdown-item:active {
  background: var(--bg-active);
}

.dropdown-item[data-current="true"] {
  background: var(--brand-primary);
  color: var(--text-on-brand);
  font-weight: var(--font-weight-medium);
}

/* === Stitch component treatment === */
button,
input,
select,
textarea {
  accent-color: var(--brand-secondary);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="file"],
select,
textarea,
#search-input {
  background: #0d1217;
  border-color: var(--border-color);
}

input:hover,
select:hover,
textarea:hover {
  border-color: #4b6173;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
.image-drop-zone:focus-visible {
  outline: 2px solid var(--brand-secondary);
  outline-offset: 2px;
  box-shadow: none;
}

.btn {
  border-radius: var(--radius-sm);
  background: #151c23;
  border-color: var(--border-color);
  font-size: 14px;
  font-weight: 600;
}

.btn:hover:not(:disabled) {
  background: #1d2731;
  border-color: var(--brand-primary-light);
  transform: none;
}

.btn.primary {
  color: #171204;
  background: linear-gradient(180deg, var(--brand-secondary-light), var(--brand-secondary));
  border: 1px solid var(--brand-secondary);
  box-shadow: 0 5px 18px rgba(242, 189, 69, 0.16);
}

.btn.primary:hover:not(:disabled) {
  color: #090704;
  background: linear-gradient(180deg, #ffe08a, #f4c34f);
  box-shadow: 0 6px 22px rgba(242, 189, 69, 0.22);
}

.btn.secondary {
  color: #edf8fc;
  background: linear-gradient(180deg, var(--brand-primary-light), var(--brand-primary));
  border: 1px solid var(--brand-primary-light);
}

.btn.secondary:hover:not(:disabled) {
  background: linear-gradient(180deg, #4badd2, #2b88ac);
}

.pill {
  background: #10161c;
  border-color: var(--border-color);
}

.tabs {
  width: fit-content;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: #0c1116;
}

.tab {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
}

.tab.active {
  color: var(--brand-secondary-light);
  background: rgba(242, 189, 69, 0.14);
  box-shadow: inset 0 0 0 1px rgba(242, 189, 69, 0.22);
}

.search-workspace {
  border-color: #325166;
}

.search-workspace h3::before,
.results-workspace h3::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 18px;
  margin-right: 9px;
  border-radius: 2px;
  background: var(--brand-secondary);
  vertical-align: -2px;
}

#form-search {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
}

#search-input {
  min-height: 50px;
  padding-left: 18px;
  font-size: 16px;
  border-color: #3a5366;
}

#form-search .btn {
  min-width: 132px;
}

.search-controls-row {
  padding: 13px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: rgba(8, 12, 16, 0.46);
}

.search-advanced {
  border: 1px dashed rgba(73, 103, 125, 0.66);
  border-radius: var(--radius-md);
  background: rgba(8, 12, 16, 0.35);
}

.search-tools {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-md);
  margin-top: var(--space-md);
  align-items: start;
}

.search-advanced summary,
.image-search-details summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 10px 14px;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  list-style: none;
}

.image-search-details {
  border: 1px dashed rgba(73, 103, 125, 0.66);
  border-radius: var(--radius-md);
  background: rgba(8, 12, 16, 0.35);
}

.search-advanced summary::after,
.image-search-details summary::after {
  content: "▾";
  margin-left: auto;
  color: var(--text-muted);
}

.search-advanced[open] summary::after,
.image-search-details[open] summary::after {
  transform: rotate(180deg);
}

.search-advanced .search-controls-row {
  margin-top: 0;
  border: 0;
  border-top: 1px solid var(--border-light);
  border-radius: 0;
}

.image-search-details .image-query-box {
  margin-top: 0;
  padding: 14px;
  border-top: 1px solid var(--border-light);
}

.image-search-details .search-pipeline-info {
  padding: 0 14px 14px;
}

.image-query-box {
  grid-template-columns: auto 1fr;
  align-items: stretch;
}

.image-query-box > .btn {
  align-self: start;
}

.image-drop-zone {
  min-height: 84px;
  padding: 14px;
  border-width: 1px;
  background: rgba(10, 15, 20, 0.65);
}

.collapsible-header {
  min-height: 42px;
  margin-bottom: 0;
}

.collapsible-header:has(+ .collapsible-content:not([hidden])) {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

.collapse-toggle {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
}

.source-form {
  padding: 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: rgba(8, 12, 16, 0.4);
}

.maintenance-card {
  margin: 16px 0;
  padding: 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: rgba(8, 12, 16, 0.4);
}

.maintenance-card .btn {
  width: 100%;
}

.maintenance-card p {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

.maintenance-card strong {
  color: var(--text-secondary);
}

.source-item {
  background: #0e141a;
  border-color: rgba(69, 88, 104, 0.48);
}

.source-item:hover {
  border-color: #3c6680;
  box-shadow: inset 3px 0 0 var(--brand-primary);
}

.source-actions .btn,
.btn-control {
  min-height: 36px;
  padding: 7px 10px;
  font-size: 12px;
}

.results {
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
  max-height: calc(100vh - 160px);
}

.result {
  padding: 9px;
  background: #0c1116;
  border-color: #294455;
  overflow: hidden;
}

.result:hover {
  border-color: var(--brand-primary-light);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.32);
  transform: translateY(-2px);
}

.result img {
  aspect-ratio: 4 / 3;
  border: 0;
}

.result .meta {
  line-height: 1.45;
}

.result-similar-btn {
  width: 100%;
  min-height: 40px;
  margin-top: 10px;
  color: #eefaff;
  background: linear-gradient(180deg, var(--brand-primary-light), var(--brand-primary));
  border-color: var(--brand-primary-light);
  box-shadow: 0 5px 16px rgba(37, 125, 160, 0.2);
}

.result-similar-btn:hover:not(:disabled) {
  color: white;
  background: linear-gradient(180deg, #4aadd2, #247fa2);
  border-color: #67bddc;
}

/* Inputs without an explicit type are native text inputs. */
input:not([type]) {
  width: 100%;
  min-height: 44px;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #0d1217;
  color: var(--text-primary);
  font: inherit;
  font-size: var(--font-size-base);
  line-height: 1.5;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.dropdown {
  background: #11171e;
}

@media (max-width: 700px) {
  #form-search {
    grid-template-columns: 1fr;
  }

  #form-search .btn {
    width: 100%;
  }

  .image-query-box {
    grid-template-columns: 1fr;
  }

  .search-tools {
    grid-template-columns: 1fr;
  }

  .results {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 65vh;
  }

  .source-form {
    padding: 12px;
  }
}

@media (max-width: 420px) {
  .results {
    grid-template-columns: 1fr;
  }

  .source-actions,
  .source-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .source-actions .btn,
  .btn-control {
    width: 100%;
  }
}

/* === Updates section === */
.settings-section {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-light, #26323e);
}
.settings-section-title {
  margin: 0 0 0.75rem;
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text-secondary, #b2bdc8);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
}
.updates-current {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}
.update-banner {
  background: var(--color-info-light, rgba(37,125,160,0.12));
  border: 1px solid var(--color-info-border, rgba(85,169,208,0.35));
  border-radius: var(--radius-md, 9px);
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.update-banner-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.update-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--brand-primary, #257da0);
  color: #fff;
}
.update-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}
.update-changelog {
  font-size: 0.82rem;
  white-space: pre-wrap;
  background: var(--bg-canvas, #11161c);
  border-radius: var(--radius-sm, 7px);
  padding: 0.6rem 0.75rem;
  margin-top: 0.4rem;
  max-height: 180px;
  overflow-y: auto;
  color: var(--text-secondary, #b2bdc8);
}
.update-progress-wrap {
  margin-bottom: 0.75rem;
}
.update-progress-bar {
  height: 6px;
  background: var(--border-light, #26323e);
  border-radius: 3px;
  margin-top: 0.35rem;
  overflow: hidden;
}
.update-progress-fill {
  height: 100%;
  background: var(--brand-primary, #257da0);
  border-radius: 3px;
  transition: width 0.3s ease;
}
.update-done-banner {
  background: var(--color-success-light, rgba(50,166,89,0.12));
  border: 1px solid var(--color-success-border, rgba(88,199,121,0.35));
  border-radius: var(--radius-md, 9px);
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color: var(--color-success, #58c779);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.update-error-banner {
  background: var(--color-error-light, rgba(225,70,70,0.1));
  border: 1px solid var(--color-error-border, rgba(239,104,104,0.35));
  border-radius: var(--radius-md, 9px);
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.88rem;
  color: var(--color-error, #ef6868);
}
.update-manual-wrap {
  margin-bottom: 0.75rem;
}
.update-dropzone {
  border: 2px dashed var(--border-color, #344352);
  border-radius: var(--radius-md, 9px);
  padding: 1.1rem;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted, #7f8b98);
  font-size: 0.88rem;
  transition: border-color 0.2s, background 0.2s;
}
.update-dropzone:hover,
.update-dropzone.dragover {
  border-color: var(--brand-primary, #257da0);
  background: var(--color-info-light, rgba(37,125,160,0.07));
  color: var(--text-primary, #f3f6f8);
}
.update-check-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ── Reference image (similar search) ── */
.result-reference {
  outline: 2px solid var(--brand-primary, #3b9edd);
  outline-offset: -2px;
}

.result-ref-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--brand-primary, #3b9edd);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  z-index: 2;
  pointer-events: none;
}

/* ── Selection mode ── */
.select-toggle-btn.active {
  background: var(--brand-primary, #3b9edd);
  color: #fff;
  border-color: var(--brand-primary, #3b9edd);
}

.result {
  position: relative;
}

.result-checkbox {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 18px;
  height: 18px;
  cursor: pointer;
  z-index: 2;
  accent-color: var(--brand-primary, #3b9edd);
}

.result.selected {
  outline: 2px solid var(--brand-primary, #3b9edd);
  outline-offset: -2px;
}

.selection-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.65rem 1rem;
  margin-top: 0.75rem;
  background: var(--bg-card, #111921);
  border: 1px solid var(--brand-primary, #3b9edd);
  border-radius: var(--radius-md, 8px);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
  z-index: 10;
}

.selection-count {
  font-weight: 600;
  color: var(--brand-primary, #3b9edd);
  flex: 1;
  min-width: 120px;
}

/* ── Collections panel ── */
.collections-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.collection-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card, #111921);
  border: 1px solid var(--border-light, #294455);
  border-radius: var(--radius-md, 8px);
  transition: border-color 0.15s;
}

.collection-card:hover {
  border-color: var(--brand-primary, #3b9edd);
}

.collection-card-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  overflow: hidden;
}

.collection-card-name {
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.collection-card-count {
  font-size: 0.8rem;
}

.collection-card-desc {
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-danger-btn {
  color: #e74c3c !important;
}

/* ── Collection picker modal ── */
.picker-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 40vh;
  overflow-y: auto;
  margin: 0.75rem 0;
}

.picker-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: var(--bg-card, #111921);
  border: 1px solid var(--border-light, #294455);
  border-radius: var(--radius-sm, 5px);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.12s, background 0.12s;
}

.picker-item:hover {
  border-color: var(--brand-primary, #3b9edd);
  background: var(--bg-hover, #161e28);
}

/* Visual trial: square search result cards. */
.results .result,
.results .result img,
.results .result-similar-btn {
  border-radius: 0;
}

/* ─── TOUR INTERACTIVO — estilo pizarra/chalk ───────────────────────────── */

#tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: transparent;
  cursor: default;
}

#tour-highlight {
  position: fixed;
  z-index: 9001;
  pointer-events: none;
  border-radius: 8px;
  box-shadow:
    0 0 0 9999px rgba(0, 0, 0, 0.72),
    0 0 0 3px rgba(255, 255, 255, 0.88),
    0 0 0 5px rgba(255, 255, 255, 0.12),
    0 0 22px 6px rgba(255, 255, 255, 0.1);
  transition: top 0.22s ease, left 0.22s ease, width 0.22s ease, height 0.22s ease;
}

#tour-tooltip {
  position: fixed;
  z-index: 9004;
  width: min(340px, calc(100vw - 32px));
  background: #1a2416;
  color: #f0ece0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 1.1rem 1.3rem 0.9rem;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.05),
    0 0 40px rgba(0, 0, 0, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  pointer-events: all;
  transition: top 0.18s ease, left 0.18s ease;
  font-family: 'Caveat', 'Segoe Script', 'Brush Script MT', cursive;
}

.tour-count {
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.45);
  margin-bottom: 0.2rem;
  font-family: 'Caveat', 'Segoe Script', cursive;
  letter-spacing: 0.06em;
}

#tour-tooltip .tour-title {
  font-family: 'Caveat', 'Segoe Script', cursive;
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0 0 0.4rem;
  color: #ffffff;
  line-height: 1.2;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.2);
}

#tour-tooltip .tour-text {
  font-family: 'Caveat', 'Segoe Script', cursive;
  font-size: 1.05rem;
  line-height: 1.5;
  margin: 0 0 0.85rem;
  color: rgba(240, 236, 224, 0.9);
}

#tour-tooltip .tour-text em {
  color: #fff;
  font-style: italic;
}

#tour-tooltip .tour-text strong {
  color: #fff;
  font-weight: 700;
}

.tour-actions {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  flex-wrap: wrap;
}

#tour-tooltip .btn {
  font-family: 'Caveat', 'Segoe Script', cursive;
  font-size: 1rem;
  font-weight: 600;
  border-color: rgba(255, 255, 255, 0.22);
  color: rgba(255, 255, 255, 0.82);
  background: rgba(255, 255, 255, 0.05);
  padding: 0.3rem 0.75rem;
  border-radius: 4px;
}
#tour-tooltip .btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.38);
}
#tour-tooltip .btn.primary {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.45);
  color: #fff;
}
#tour-tooltip .btn.primary:hover {
  background: rgba(255, 255, 255, 0.24);
}

.tour-skip-btn {
  margin-left: auto;
  font-size: 0.88rem;
  opacity: 0.55;
  padding: 0.25rem 0.55rem;
}
.tour-skip-btn:hover {
  opacity: 1;
}

/* Tutorial nav item */
#btn-tutorial .app-nav-icon {
  opacity: 0.7;
}
#btn-tutorial:hover .app-nav-icon {
  opacity: 1;
}

/* === Dropbox connect section === */
.dropbox-section { margin-top: 16px; border: 1px solid var(--border-light); border-radius: var(--radius-md); }
.dropbox-summary { display: flex; align-items: center; gap: 8px; padding: 10px 14px; cursor: pointer; font-weight: 600; font-size: var(--font-size-sm); list-style: none; }
.dropbox-summary::marker, .dropbox-summary::-webkit-details-marker { display: none; }
.dropbox-summary svg { color: #0061ff; flex-shrink: 0; }
.dropbox-body { padding: 12px 14px 14px; border-top: 1px solid var(--border-light); }
.dropbox-body label { display: flex; flex-direction: column; gap: 4px; font-size: var(--font-size-sm); margin-bottom: 6px; }
