/* ============================================
   SISTEMA DE INFORMES — Estilos globales
   Estética: Industrial / Técnico refinado
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@300;400;500;600&display=swap');

/* === Variables === */
:root {
  --bg:         #0e0f11;
  --bg-2:       #15171a;
  --bg-3:       #1c1e22;
  --border:     #2a2d33;
  --border-2:   #363a42;
  --text:       #e8eaed;
  --text-2:     #9aa0ab;
  --text-3:     #5c6370;
  --accent:     #3b82f6;
  --accent-dim: rgba(59,130,246,0.12);
  --success:    #22c55e;
  --danger:     #ef4444;
  --warn:       #f59e0b;

  --radius:     6px;
  --radius-lg:  10px;
  --shadow:     0 1px 3px rgba(0,0,0,.4), 0 4px 12px rgba(0,0,0,.25);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.5);

  --font-sans:  'IBM Plex Sans', sans-serif;
  --font-mono:  'IBM Plex Mono', monospace;

  --sidebar-w:  220px;
  --header-h:   56px;
}

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }
img { max-width: 100%; display: block; }

/* === Layout shell === */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  min-height: 100vh;
}

/* === Header === */
#header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-logo svg { color: var(--accent); flex-shrink: 0; }
.header-logo-text {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text);
}
.header-logo-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  letter-spacing: .06em;
  margin-top: 1px;
}
.header-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 8px;
}
#header-breadcrumb {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  flex: 1;
}
#header-breadcrumb span { color: var(--text-2); }

/* === Sidebar === */
#sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .1em;
  color: var(--text-3);
  text-transform: uppercase;
  padding: 8px 20px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  cursor: pointer;
  border-radius: 0;
  transition: background .15s, color .15s;
  font-size: 13px;
  color: var(--text-2);
  border-left: 2px solid transparent;
  user-select: none;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .7; }
.nav-item:hover {
  background: var(--bg-3);
  color: var(--text);
}
.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 500;
}
.nav-item.active svg { opacity: 1; }

/* === Main content === */
#main {
  overflow-y: auto;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* === Page header === */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.page-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}
.page-subtitle {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  margin-top: 4px;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: #2563eb; border-color: #2563eb; }
.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border-2);
}
.btn-ghost:hover { background: var(--bg-3); color: var(--text); }
.btn-icon {
  padding: 7px;
  width: 32px;
  height: 32px;
  justify-content: center;
}
.btn:disabled { opacity: .4; pointer-events: none; }

/* === Search bar === */
.search-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.search-wrap {
  position: relative;
  flex: 1;
  max-width: 360px;
}
.search-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  width: 15px;
  height: 15px;
  pointer-events: none;
}
.search-input {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px 8px 34px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.search-input::placeholder { color: var(--text-3); }
.search-input:focus { border-color: var(--accent); }

/* === Table === */
.table-wrap {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
table {
  width: 100%;
  border-collapse: collapse;
}
thead tr {
  border-bottom: 1px solid var(--border);
  background: var(--bg-3);
}
thead th {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 10px 16px;
  text-align: left;
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-3); }
tbody td {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-2);
  vertical-align: middle;
}
.td-mono {
  font-family: var(--font-mono);
  font-size: 12px;
}
.td-primary { color: var(--text); font-weight: 500; }
.td-actions { display: flex; gap: 4px; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 500;
}
.badge-blue { background: var(--accent-dim); color: var(--accent); }
.badge-green { background: rgba(34,197,94,.12); color: var(--success); }

/* === Pagination === */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-3);
}
.pagination-info {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
}
.pagination-controls { display: flex; gap: 4px; align-items: center; }
.page-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-size: 12px;
  font-family: var(--font-mono);
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  transition: background .15s, color .15s, border-color .15s;
}
.page-btn:hover:not(:disabled) { background: var(--bg-2); color: var(--text); }
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-btn:disabled { opacity: .3; cursor: not-allowed; }

/* === Section label (detail view) === */
.detail-section-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 8px;
  padding-left: 2px;
}
.detail-section-label svg { width: 13px; height: 13px; color: var(--accent); }

/* === Detail view === */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.detail-grid-3col {
  grid-template-columns: repeat(3, 1fr);
}
.detail-card {
  background: var(--bg-2);
  padding: 18px 20px;
}
.detail-card.span-2 { grid-column: span 2; }
.detail-card.span-3 { grid-column: span 3; }

/* Color-coded diagnostic cards */
.detail-card-colored { border-top: 2px solid transparent; }
.detail-card-falla   { border-top-color: var(--danger); }
.detail-card-diag    { border-top-color: var(--warn); }
.detail-card-sol     { border-top-color: var(--success); }

.detail-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 8px;
}

/* Colored dots */
.dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.dot-falla { background: var(--danger); }
.dot-diag  { background: var(--warn); }
.dot-sol   { background: var(--success); }

.detail-text {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.7;
}
.detail-value {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.5;
}
.detail-value-mono {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
}
.detail-photo {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  max-height: 320px;
  object-fit: cover;
  width: 100%;
}
.no-photo {
  width: 100%;
  height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px dashed var(--border-2);
  border-radius: var(--radius);
  color: var(--text-3);
  font-size: 12px;
}
.no-photo svg { width: 28px; height: 28px; opacity: .4; }

/* === Form === */
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.form-grid-3col {
  grid-template-columns: repeat(3, 1fr);
}
/* Colored labels for diagnostic section */
.falla-label { color: var(--danger) !important; }
.diag-label  { color: var(--warn)   !important; }
.sol-label   { color: var(--success)!important; }
.td-truncate {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.span-2 { grid-column: span 2; }
.form-group.span-3 { grid-column: span 3; }
.form-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.form-label span { color: var(--danger); margin-left: 2px; }
.form-input, .form-textarea {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.form-textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.6;
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-3); }
.form-input:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}
.form-input.error { border-color: var(--danger); }

/* File upload */
.file-drop {
  border: 1px dashed var(--border-2);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.file-drop:hover, .file-drop.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.file-drop input[type="file"] { display: none; }
.file-drop-icon { color: var(--text-3); margin: 0 auto 8px; width: 28px; height: 28px; }
.file-drop-text { font-size: 12px; color: var(--text-2); }
.file-drop-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.file-preview-name {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--success);
  margin-top: 6px;
}

/* Form card wrapper */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title svg { color: var(--accent); width: 15px; height: 15px; }

/* Form actions */
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

/* === Toast === */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  color: var(--text);
  min-width: 260px;
  animation: slideIn .2s ease;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast svg { width: 15px; height: 15px; flex-shrink: 0; }
.toast.success svg { color: var(--success); }
.toast.error   svg { color: var(--danger); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* === Loading skeleton === */
.skeleton {
  background: linear-gradient(90deg, var(--bg-3) 25%, var(--border) 50%, var(--bg-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skeleton-row td div { height: 14px; border-radius: 4px; }

/* === States === */
.empty-state {
  padding: 60px 24px;
  text-align: center;
  color: var(--text-3);
}
.empty-state svg { margin: 0 auto 12px; width: 40px; height: 40px; opacity: .3; }
.empty-state p { font-size: 13px; }

/* === Buscar SG === */
.sg-search-box {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
}
.sg-search-inner { max-width: 560px; }
.sg-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 10px;
}
.sg-label svg { width: 14px; height: 14px; color: var(--accent); }
.sg-input-row { display: flex; gap: 8px; }
.sg-input {
  flex: 1;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 16px;
  font-size: 18px;
  font-family: var(--font-mono);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  letter-spacing: .04em;
}
.sg-input::placeholder { color: var(--text-3); font-size: 15px; }
.sg-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.1); }
.sg-hint { font-size: 11px; color: var(--text-3); margin-top: 8px; }

/* SG Result */
.sg-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.sg-result-info { display: flex; align-items: center; gap: 12px; }
.sg-result-title {
  font-size: 18px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--accent);
}
.sg-result-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* Loading / not found states */
.sg-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 32px;
  color: var(--text-3);
  font-size: 13px;
}
.sg-loading svg { animation: spin .8s linear infinite; }
.sg-not-found {
  padding: 60px 24px;
  text-align: center;
  color: var(--text-3);
}
.sg-not-found-icon { margin: 0 auto 14px; color: var(--text-3); opacity: .35; }
.sg-not-found p { font-size: 14px; color: var(--text-2); margin-bottom: 6px; }
.sg-not-found p strong { color: var(--text); }
.sg-not-found span { font-size: 12px; }

/* Repuestos table within SG view */
.repuestos-table-wrap {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.repuestos-table { width: 100%; border-collapse: collapse; }
.repuestos-table thead tr { background: var(--bg-3); border-bottom: 1px solid var(--border); }
.repuestos-table thead th {
  font-family: var(--font-mono); font-size: 10px; font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase; color: var(--text-3);
  padding: 10px 16px; text-align: left;
}
.repuestos-table tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
.repuestos-table tbody tr:last-child { border-bottom: none; }
.repuestos-table tbody tr:hover { background: var(--bg-3); }
.repuestos-table tbody td { padding: 10px 16px; font-size: 13px; color: var(--text-2); }

/* PDF button */
.btn-pdf {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid #dc2626;
  background: rgba(220,38,38,.1);
  color: #f87171;
  transition: background .15s, color .15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn-pdf svg { width: 15px; height: 15px; }
.btn-pdf:hover { background: rgba(220,38,38,.2); color: #fca5a5; }

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* === Responsive === */
@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; }
  #sidebar { display: none; }
  #main { padding: 20px 16px; }
  .detail-grid, .detail-grid-3col { grid-template-columns: 1fr 1fr; }
  .form-grid, .form-grid-3col { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .detail-grid, .detail-grid-3col,
  .form-grid, .form-grid-3col { grid-template-columns: 1fr; }
  .detail-card.span-2, .detail-card.span-3 { grid-column: span 1; }
  .form-group.span-2, .form-group.span-3 { grid-column: span 1; }
  table { font-size: 12px; }
  thead th, tbody td { padding: 10px 10px; }
}
