/* File: frontend/public/css/components.css */

/* ---- Botones ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  transition: opacity var(--transition), background var(--transition);
  text-decoration: none;
  line-height: 1.4;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:hover:not(:disabled) { opacity: .88; }

.btn-primary  { background: var(--color-primary); color: #fff; }
.btn-success  { background: var(--color-success); color: #fff; }
.btn-warning  { background: var(--color-warning); color: #333; }
.btn-danger   { background: var(--color-danger);  color: #fff; }
.btn-info     { background: var(--color-info);    color: #fff; }
.btn-ghost    { background: transparent; color: var(--color-muted); border: 1px solid var(--color-border); }
.btn-sm       { padding: 5px 12px; font-size: .8rem; }
.btn-icon     { padding: 7px 10px; }

/* ---- Formularios ---- */
.form-group { margin-bottom: 16px; }
.form-row    { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3  { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: 5px;
}

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="time"],
input[type="tel"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-white);
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(230,57,70,.12);
}

textarea { resize: vertical; min-height: 80px; }

/* ---- Tarjetas ---- */
.card {
  background: var(--color-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.card-title { font-size: 1rem; font-weight: 600; color: var(--color-dark); }

/* ---- Stats / KPI cards ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--color-white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--color-primary);
}
.stat-card.warning  { border-left-color: var(--color-warning); }
.stat-card.success  { border-left-color: var(--color-success); }
.stat-card.info     { border-left-color: var(--color-info); }
.stat-card.danger   { border-left-color: var(--color-danger); }

.stat-label { font-size: .78rem; color: var(--color-muted); text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--color-dark); line-height: 1.1; margin: 4px 0; }
.stat-sub   { font-size: .8rem; color: var(--color-muted); }

/* ---- Tabla ---- */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

thead th {
  background: #f8f9fa;
  padding: 11px 14px;
  text-align: left;
  font-weight: 600;
  font-size: .78rem;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 1px solid var(--color-border);
}

tbody tr:hover { background: #f8f9fa; }

td {
  padding: 11px 14px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

/* ---- Badges ---- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}

.badge-operativo   { background: #d1f5ef; color: #155f54; }
.badge-degradado   { background: #fef9e7; color: #856404; }
.badge-fuera_servicio { background: #fde8ea; color: #c1121f; }
.badge-planificado { background: #d6eaf8; color: #1a5276; }
.badge-confirmado  { background: #d4efdf; color: #145a32; }
.badge-en_curso    { background: #d5f5e3; color: #0d6b3a; }
.badge-completado  { background: #eaecee; color: #566573; }
.badge-cancelado   { background: #fde8ea; color: #c1121f; }
.badge-pendiente   { background: #fef9e7; color: #856404; }
.badge-preparado   { background: #d6eaf8; color: #1a5276; }
.badge-salido      { background: #d4efdf; color: #145a32; }
.badge-devuelto    { background: #eaecee; color: #566573; }
.badge-incompleto  { background: #fde8ea; color: #c1121f; }
.badge-admin       { background: #fde8ea; color: #c1121f; }
.badge-tecnico     { background: #d6eaf8; color: #1a5276; }
.badge-disponible  { background: #d1f5ef; color: #155f54; }
.badge-en_uso      { background: #d4efdf; color: #145a32; }
.badge-mantenimiento { background: #fef9e7; color: #856404; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn .15s ease;
}

@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

.modal {
  background: var(--color-white);
  border-radius: 10px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  animation: slideUp .2s ease;
}

@keyframes slideUp { from { transform:translateY(20px); opacity:0; } to { transform:translateY(0); opacity:1; } }

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: var(--color-white);
  z-index: 1;
}
.modal-header h2 { font-size: 1rem; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--color-muted);
  padding: 4px 8px;
  border-radius: 4px;
}
.modal-close:hover { background: var(--color-bg); color: var(--color-text); }

.modal-body   { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ---- Filtros ---- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
  background: var(--color-white);
  padding: 14px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  align-items: flex-end;
}

.filter-bar .form-group { margin-bottom: 0; min-width: 140px; flex: 1; }

/* ---- Pestañas ---- */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--color-border); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 18px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  color: var(--color-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition), border-color var(--transition);
}
.tab-btn.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---- Timeline ---- */
.timeline-bar {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 12px 0;
  overflow-x: auto;
}
.timeline-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 90px;
  position: relative;
}
.timeline-item:not(:last-child)::after {
  content: '→';
  position: absolute;
  right: -10px;
  top: 14px;
  color: var(--color-muted);
  font-size: .8rem;
}
.timeline-time  { font-size: .75rem; color: var(--color-primary); font-weight: 700; }
.timeline-label { font-size: .7rem; color: var(--color-muted); text-align: center; }

/* ---- Disponibilidad barra ---- */
.avail-bar {
  height: 6px;
  background: #eee;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}
.avail-bar-fill { height: 100%; border-radius: 3px; transition: width .4s ease; }
.avail-high  { background: var(--color-success); }
.avail-mid   { background: var(--color-warning); }
.avail-low   { background: var(--color-danger); }

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--color-muted);
}
.empty-state p { font-size: 1rem; }
.empty-state small { font-size: .82rem; display: block; margin-top: 6px; }

/* ---- QR scan panel ---- */
.qr-panel {
  max-width: 500px;
  margin: 0 auto;
}
.qr-input-group {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}
.qr-input-group input { flex: 1; font-size: 1.1rem; letter-spacing: 2px; }

.scan-result {
  background: var(--color-white);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-top: 16px;
}
.scan-result.success { border-left: 4px solid var(--color-success); }
.scan-result.error   { border-left: 4px solid var(--color-danger); }

.history-list { list-style: none; margin-top: 16px; }
.history-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: .85rem;
  display: flex;
  justify-content: space-between;
}

/* ---- Spinner ---- */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 3px solid rgba(230,57,70,.2);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Paginación / Scroll to top ---- */
.actions-col { white-space: nowrap; }
