/* =============================================================================
   Stock Recambios - Estilos
   Panel de gestión industrial
   ============================================================================= */

:root {
  --bg-dark: #1a1d23;
  --bg-card: #252830;
  --bg-input: #2d3139;
  --border: #3d424d;
  --text: #e8eaed;
  --text-muted: #9aa0a6;
  --accent: #4a9eff;
  --accent-hover: #6bb0ff;
  --success: #34a853;
  --warning: #f9ab00;
  --danger: #ea4335;
  --radius: 6px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Header */
.header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.header h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 600;
}

.subtitle {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.tab {
  padding: 0.6rem 1.2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.2s, border-color 0.2s;
}

.tab:hover {
  background: var(--bg-input);
}

.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Views */
.view {
  display: none;
}

.view.active {
  display: block;
}

.view-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  max-width: 500px;
  height: 100vh;
  background: var(--bg-card);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.4);
  padding: 1.5rem;
  overflow-y: auto;
  z-index: 100;
}

.view-panel.active {
  display: block;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.btn-close {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--bg-input);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius);
  transition: background 0.2s;
}

.btn-close:hover {
  background: var(--danger);
}

/* Filters */
.filters {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.filters select,
.filters input[type="search"] {
  padding: 0.5rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
}

.filters input[type="search"] {
  flex: 1;
  min-width: 200px;
}

.filters select:focus,
.filters input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Table */
.table-container {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  background: var(--bg-input);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.data-table tbody tr:hover {
  background: rgba(74, 158, 255, 0.08);
}

.data-table .loading {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
}

.col-cantidad {
  width: 100px;
  text-align: right;
}

.cantidad-stock-bajo {
  color: var(--warning);
  font-weight: 600;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  border-radius: 4px;
  font-weight: 500;
}

.badge-warning {
  background: rgba(249, 171, 0, 0.2);
  color: var(--warning);
}

.hidden {
  display: none !important;
}

/* Buttons in table */
.btn-cell {
  white-space: nowrap;
}

.btn-sm {
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

.btn-sm.btn-edit {
  background: var(--accent);
  color: #fff;
}

.btn-sm.btn-edit:hover {
  background: var(--accent-hover);
}

/* Forms */
.form-recambio {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.field {
  margin-bottom: 1rem;
}

.field label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.field-stock {
  position: relative;
}

.field-stock .badge {
  margin-left: 0.5rem;
  vertical-align: middle;
}

.custom-fields-section {
  margin: 1rem 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.custom-fields-section .field {
  margin-bottom: 0.75rem;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.btn {
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-muted);
}

.empty-state p {
  margin: 0 0 1rem;
}

/* Error message */
.error-msg {
  background: rgba(234, 67, 53, 0.15);
  color: var(--danger);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

/* Success feedback */
.success-msg {
  background: rgba(52, 168, 83, 0.15);
  color: var(--success);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

/* Campos adicionales */
.campos-desc {
  color: var(--text-muted);
  margin: 0 0 1.5rem;
  font-size: 0.95rem;
}

.campos-lista {
  margin-bottom: 1.5rem;
}

.campo-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.campo-item:last-child {
  border-bottom: none;
}

.campo-item input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
}

.campo-item input:focus {
  outline: none;
  border-color: var(--accent);
}

.campos-nuevo {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.campos-nuevo input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
}

.campos-nuevo input:focus {
  outline: none;
  border-color: var(--accent);
}
