/**
 * MetalVision UI Components
 * Reusable component styles
 */

/* Cards */
.mv-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-fast);
}

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

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

.mv-card-title {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.mv-card-body {
  color: var(--text-primary);
}

.mv-card-footer {
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-sm);
}

/* Stat Icon */
.stat-icon {
  width: 3rem;
  height: 3rem;
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.stat-icon-sm {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

/* Stat Item */
.stat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--border);
}

.stat-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.stat-item:first-child {
  padding-top: 0;
}

.stat-item-label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

.stat-item-value {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--text-primary);
}

/* Timeline Component */
.timeline {
  position: relative;
  padding-left: 2rem;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 0.5rem;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: 1.5rem;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-marker {
  position: absolute;
  left: -1.625rem;
  top: 0.25rem;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  border: 2px solid var(--bg-1);
  z-index: 1;
}

.timeline-content {
  padding-left: 0.5rem;
}

/* Drop Zone for File Upload */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--border-radius);
  padding: var(--space-xl);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  background: var(--bg-0);
}

.drop-zone:hover {
  border-color: var(--color-primary);
  background: var(--bg-1);
}

.drop-zone.drag-over {
  border-color: var(--color-primary);
  background: rgba(var(--color-primary-rgb), 0.05);
  transform: scale(1.02);
}

/* Tables */
.mv-table {
  width: 100%;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  overflow: hidden;
}

.mv-table table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
  background: var(--bg-1);
}

.mv-table thead {
  background: var(--bg-2);
  border-bottom: 2px solid var(--border);
}

.mv-table th {
  padding: var(--space-md);
  text-align: left;
  font-weight: 600;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-2);
}

.mv-table td {
  padding: var(--space-md);
  border-top: 1px solid var(--border);
  color: var(--text-primary);
  background: var(--bg-1);
}

.mv-table tbody tr {
  transition: background-color var(--transition-fast);
  background: var(--bg-1);
}

.mv-table tbody tr:hover {
  background: var(--bg-2);
}

/* Override Bootstrap table styles for dark theme */
.table {
  --bs-table-bg: transparent;
  --bs-table-striped-bg: transparent;
  --bs-table-hover-bg: var(--bg-2);
  color: var(--text-primary);
  background-color: transparent !important;
}

.table > :not(caption) > * > * {
  background-color: transparent !important;
  color: var(--text-primary);
}

.table thead {
  background: var(--bg-2);
  border-bottom: 2px solid var(--border);
}

.table tbody tr {
  background: transparent !important;
  border-bottom: 1px solid var(--border);
}

.table tbody tr:hover {
  background: var(--bg-2) !important;
}

/* Buttons */
.btn-primary {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--bg-0);
}

.btn-primary:hover {
  background: var(--color-tertiary);
  border-color: var(--color-tertiary);
}

.btn-secondary {
  background: var(--bg-2);
  border-color: var(--border);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-1);
  border-color: var(--highlight);
}

/* Forms */
.form-control,
.form-select {
  background: var(--bg-0);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.form-control:focus,
.form-select:focus {
  background: var(--bg-0);
  border-color: var(--color-accent);
  color: var(--text-primary);
  box-shadow: 0 0 0 0.2rem rgba(192, 80, 80, 0.25);
}

.form-label {
  color: var(--text-primary);
  font-weight: 500;
  margin-bottom: var(--space-sm);
}

/* Badges */
.badge {
  padding: 0.25em 0.6em;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--border-radius-sm);
  color: oklch(0.2 0.06 258) !important; /* Dark text for contrast */
}

/* Pagination */
.pagination .page-link {
  background: var(--bg-1);
  border-color: var(--border);
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.pagination .page-link:hover {
  background: var(--bg-2);
  border-color: var(--border);
  color: var(--text-primary);
}

.pagination .page-item.active .page-link {
  background: var(--primary);
  border-color: var(--primary);
  color: oklch(0.2 0.06 258);
  font-weight: 600;
}

.pagination .page-item.disabled .page-link {
  background: var(--bg-1);
  border-color: var(--border);
  color: var(--text-muted);
  opacity: 0.5;
}

.badge-success {
  background: var(--success);
  color: var(--bg-0);
}

.badge-error {
  background: var(--error);
  color: var(--bg-0);
}

.badge-warning {
  background: var(--warning);
  color: var(--bg-0);
}

.badge-info {
  background: var(--info);
  color: var(--bg-0);
}

/* Alerts */
.alert {
  border-radius: var(--border-radius);
  border: 1px solid;
  padding: var(--space-md) var(--space-lg);
}

.alert-success {
  background: color-mix(in srgb, var(--success) 10%, var(--bg-1));
  border-color: var(--success);
  color: var(--text-primary);
}

.alert-danger {
  background: color-mix(in srgb, var(--error) 10%, var(--bg-1));
  border-color: var(--error);
  color: var(--text-primary);
}

.alert-warning {
  background: color-mix(in srgb, var(--warning) 10%, var(--bg-1));
  border-color: var(--warning);
  color: var(--text-primary);
}

.alert-info {
  background: color-mix(in srgb, var(--info) 10%, var(--bg-1));
  border-color: var(--info);
  color: var(--text-primary);
}

/* Modals */
.modal-content {
  background: var(--bg-1);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.modal-header {
  border-bottom: 1px solid var(--border);
}

.modal-footer {
  border-top: 1px solid var(--border);
}

.modal-title {
  color: var(--text-primary);
}

.btn-close {
  filter: invert(1);
}

body:not(.dark) .btn-close {
  filter: none;
}

/* Breadcrumb */
.breadcrumb {
  background: transparent;
  padding: 0;
  margin-bottom: var(--space-lg);
}

.breadcrumb-item {
  color: var(--text-secondary);
}

.breadcrumb-item.active {
  color: var(--text-primary);
}

.breadcrumb-item + .breadcrumb-item::before {
  color: var(--text-secondary);
}

/* Stats Cards */
.stat-card {
  background: linear-gradient(135deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

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

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  flex-shrink: 0;
  order: 2;
}

/* Variantes de color para stat-icon */
.stat-card:nth-child(1) .stat-icon {
  background: rgba(59, 130, 246, 0.15);
  color: rgb(59, 130, 246);
}

.stat-card:nth-child(2) .stat-icon {
  background: rgba(251, 146, 60, 0.15);
  color: rgb(251, 146, 60);
}

.stat-card:nth-child(3) .stat-icon {
  background: rgba(34, 197, 94, 0.15);
  color: rgb(34, 197, 94);
}

.stat-card:nth-child(4) .stat-icon {
  background: rgba(168, 85, 247, 0.15);
  color: rgb(168, 85, 247);
}

.stat-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  flex: 1;
  order: 1;
}

.stat-value-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.stat-value {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.stat-change {
  font-size: var(--font-size-xs);
  padding: 2px 8px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.stat-change.positive {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.stat-change.negative {
  background: rgba(239, 68, 68, 0.15);
  color: var(--error);
}

.stat-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

/* Layout para stat-cards con 3 líneas (valor + cambio en la misma línea) */
.stat-content-inline {
  flex: 1;
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.stat-content-inline .stat-value-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-top: var(--space-xs);
}

.stat-content-inline .stat-value {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.stat-content-inline .stat-change {
  font-size: var(--font-size-xs);
  margin-top: 0;
}

/* Empty State */
.mv-empty {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--text-secondary);
}

.mv-empty-icon {
  font-size: 4rem;
  margin-bottom: var(--space-lg);
  opacity: 0.5;
}

.mv-empty-title {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.mv-empty-message {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
}

/* Spinner */
.spinner-border {
  border-color: var(--color-accent);
  border-right-color: transparent;
}

/* Page Header */
.page-header {
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.page-header .row:not(.align-items-start) {
  align-items: center;
}

.page-title {
  font-size: var(--font-size-3xl);
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 var(--space-sm) 0;
}

.page-subtitle {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  margin: 0;
}

.page-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

/* Avatar */
.avatar-sm {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-accent);
  color: var(--bg-0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--font-size-sm);
}

/* Stat Icon Small */
.stat-icon-sm {
  width: 40px;
  height: 40px;
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: var(--bg-0);
}

/* Timeline */
.timeline {
  position: relative;
  padding-left: 0;
  list-style: none;
}

.timeline-item {
  position: relative;
  padding-left: 50px;
  padding-bottom: var(--space-lg);
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 30px;
  bottom: -10px;
  width: 2px;
  background: var(--border);
}

.timeline-item:last-child::before {
  display: none;
}

.timeline-marker {
  position: absolute;
  left: 0;
  top: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bg-0);
  font-size: 0.875rem;
  z-index: 1;
}

.timeline-content {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: var(--space-md);
}

.timeline-title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.timeline-description {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.timeline-date {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.timeline-item.active .timeline-marker {
  box-shadow: 0 0 0 4px var(--bg-1), 0 0 0 6px var(--color-accent);
}

/* Progress Bar */
.progress {
  background: var(--bg-2);
  border-radius: var(--border-radius);
  overflow: hidden;
}

.progress-bar {
  transition: width 0.6s ease;
  font-size: var(--font-size-xs);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* List Group */
.list-group-item {
  background: var(--bg-1);
  border-color: var(--border);
  color: var(--text-primary);
}

.list-group-item-action:hover {
  background: var(--bg-2);
  color: var(--text-primary);
}

/* Dropdown */
.dropdown-menu {
  background: var(--bg-1);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}

.dropdown-item {
  color: var(--text-primary);
}

.dropdown-item:hover {
  background: var(--bg-2);
  color: var(--text-primary);
}

.dropdown-divider {
  border-color: var(--border);
}

.dropdown-header {
  color: var(--text-secondary);
}

/* Tabs */
.nav-tabs {
  border-bottom: 2px solid var(--border);
}

.nav-tabs .nav-link {
  color: var(--text-secondary);
  border: none;
  border-bottom: 2px solid transparent;
  padding: var(--space-md) var(--space-lg);
  transition: all var(--transition-fast);
  background: transparent;
}

.nav-tabs .nav-link:hover {
  color: var(--text-primary);
  background: var(--highlight);
  border-bottom-color: var(--color-accent);
}

.nav-tabs .nav-link.active {
  color: var(--color-accent);
  background: var(--highlight);
  border-bottom-color: var(--color-accent);
  font-weight: 600;
}

.nav-tabs .nav-link i {
  margin-right: var(--space-xs);
}

/* Sortable Drag & Drop */
.sortable-ghost {
  opacity: 0.4;
  background: var(--highlight);
}

.sortable-chosen {
  background: var(--bg-2);
}

.sortable-drag {
  background: var(--bg-1);
  box-shadow: var(--shadow-lg);
}

.drag-handle {
  cursor: grab;
  opacity: 0.5;
  transition: opacity var(--transition-fast);
}

.drag-handle:hover {
  opacity: 1;
}

.sortable-item {
  transition: background-color var(--transition-fast);
}

.sortable-item:hover {
  background-color: var(--bg-2);
}
