/**
 * ux-flows.css — Service Flow UX Enhancements
 * Implements: OS Timeline, State Badges, Action Buttons, Client/Equipment Cards
 * Zero overrides on existing styles — all new classes with .ux- prefix
 */

/* ════════════════════════════════════════════════════════
   1. OS STATE BADGES
   ════════════════════════════════════════════════════════ */

.os-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  user-select: none;
}
.os-badge:hover       { opacity: 0.85; transform: scale(1.03); }
.os-badge:active      { transform: scale(0.97); }

.os-badge--ingresado         { background: #DBEAFE; color: #1D4ED8; }
.os-badge--en_diagnostico    { background: #FEF3C7; color: #92400E; }
.os-badge--presupuestado     { background: #FED7AA; color: #C2410C; }
.os-badge--aprobado          { background: #D1FAE5; color: #065F46; }
.os-badge--rechazado         { background: #FEE2E2; color: #991B1B; }
.os-badge--en_reparacion     { background: #E0E7FF; color: #3730A3; }
.os-badge--listo_entrega     { background: #ECFDF5; color: #047857; border: 1.5px solid #6EE7B7; }
.os-badge--entregado         { background: #F3F4F6; color: #374151; }

/* State transition dropdown */
.os-state-menu {
  position: absolute;
  z-index: 200;
  background: #fff;
  border: 1px solid var(--ds-border, #E5E7EB);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  min-width: 200px;
  animation: fadeInDown 0.15s ease;
}
.os-state-menu__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s;
}
.os-state-menu__item:hover { background: #F0F4FF; }
.os-state-menu__item--header {
  font-size: 11px;
  font-weight: 600;
  color: #9CA3AF;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 12px 4px;
  cursor: default;
}
.os-state-menu__item--header:hover { background: transparent; }

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ════════════════════════════════════════════════════════
   2. SERVICE ORDER TIMELINE
   ════════════════════════════════════════════════════════ */

.os-timeline {
  display: flex;
  align-items: flex-start;
  gap: 0;
  overflow-x: auto;
  padding: 20px 4px 8px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.os-timeline::-webkit-scrollbar { height: 4px; }
.os-timeline::-webkit-scrollbar-track { background: transparent; }
.os-timeline::-webkit-scrollbar-thumb { background: #E5E7EB; border-radius: 2px; }

.os-timeline__step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  position: relative;
  min-width: 90px;
  scroll-snap-align: center;
}

/* Connector line between steps */
.os-timeline__step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 16px;
  left: calc(50% + 16px);
  width: calc(100% - 16px);
  height: 2px;
  background: #E5E7EB;
  z-index: 0;
  transition: background 0.4s;
}
.os-timeline__step--done:not(:last-child)::after,
.os-timeline__step--active:not(:last-child)::after {
  background: linear-gradient(90deg, var(--ds-color-primary, #1B2B4B), #E5E7EB);
}
.os-timeline__step--done:not(:last-child)::after {
  background: var(--ds-color-primary, #1B2B4B);
}

/* Step circle */
.os-timeline__dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  z-index: 1;
  border: 2px solid transparent;
  transition: all 0.3s ease;
  background: #F3F4F6;
  color: #9CA3AF;
}
.os-timeline__step--done .os-timeline__dot {
  background: var(--ds-color-primary, #1B2B4B);
  color: #fff;
  border-color: var(--ds-color-primary, #1B2B4B);
  box-shadow: 0 0 0 4px rgba(27,43,75,0.12);
}
.os-timeline__step--active .os-timeline__dot {
  background: var(--ds-color-accent, #F97316);
  color: #fff;
  border-color: var(--ds-color-accent, #F97316);
  box-shadow: 0 0 0 5px rgba(249,115,22,0.18);
  animation: pulseStep 1.8s infinite;
}
.os-timeline__step--error .os-timeline__dot {
  background: #EF4444;
  color: #fff;
  border-color: #EF4444;
}

@keyframes pulseStep {
  0%, 100% { box-shadow: 0 0 0 4px rgba(249,115,22,0.18); }
  50%       { box-shadow: 0 0 0 8px rgba(249,115,22,0.08); }
}

.os-timeline__label {
  margin-top: 8px;
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  color: #9CA3AF;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  line-height: 1.3;
  max-width: 72px;
}
.os-timeline__step--done   .os-timeline__label { color: var(--ds-color-primary, #1B2B4B); }
.os-timeline__step--active .os-timeline__label { color: var(--ds-color-accent, #F97316); font-weight: 800; }

.os-timeline__date {
  font-size: 9px;
  color: #D1D5DB;
  margin-top: 2px;
  text-align: center;
}
.os-timeline__step--done .os-timeline__date { color: #9CA3AF; }

/* ════════════════════════════════════════════════════════
   3. OS HEADER CARD (sticky detail)
   ════════════════════════════════════════════════════════ */

.os-header-card {
  background: #fff;
  border: 1px solid var(--ds-border, #E5E7EB);
  border-radius: 12px;
  padding: 18px 20px 14px;
  margin-bottom: 20px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px 20px;
  align-items: start;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.os-header-card__id {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: #9CA3AF;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.os-header-card__title {
  font-size: 17px;
  font-weight: 800;
  color: var(--ds-color-primary, #1B2B4B);
  margin-bottom: 4px;
}
.os-header-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: #6B7280;
}
.os-header-card__meta span { display: flex; align-items: center; gap: 4px; }
.os-header-card__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ════════════════════════════════════════════════════════
   4. QUICK ACTION BUTTONS (contextual)
   ════════════════════════════════════════════════════════ */

.ux-action-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 0;
  border-bottom: 1px solid var(--ds-border, #E5E7EB);
  margin-bottom: 16px;
}

.ux-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.ux-btn:active { transform: scale(0.97); }

.ux-btn--primary   { background: var(--ds-color-primary, #1B2B4B); color: #fff; }
.ux-btn--success   { background: #059669; color: #fff; }
.ux-btn--warning   { background: #F59E0B; color: #fff; }
.ux-btn--danger    { background: #EF4444; color: #fff; }
.ux-btn--ghost     { background: #F9FAFB; color: #374151; border: 1px solid #E5E7EB; }
.ux-btn--whatsapp  { background: #25D366; color: #fff; }

.ux-btn--primary:hover   { background: #263D6E; }
.ux-btn--success:hover   { background: #047857; }
.ux-btn--warning:hover   { background: #D97706; }
.ux-btn--ghost:hover     { background: #F3F4F6; }
.ux-btn--whatsapp:hover  { background: #1DAA56; }

/* ════════════════════════════════════════════════════════
   5. PRIORITY BADGE (OS priority indicator)
   ════════════════════════════════════════════════════════ */

.os-priority {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}
.os-priority--alta   { background: #FEE2E2; color: #DC2626; }
.os-priority--media  { background: #FEF3C7; color: #B45309; }
.os-priority--baja   { background: #F0FDF4; color: #15803D; }

/* ════════════════════════════════════════════════════════
   6. CLIENT PROFILE CARD
   ════════════════════════════════════════════════════════ */

.client-profile-card {
  background: #fff;
  border: 1px solid var(--ds-border, #E5E7EB);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.client-profile-card__header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid #F3F4F6;
}
.client-profile-card__avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ds-color-primary,#1B2B4B), var(--ds-color-accent,#F97316));
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #fff; font-weight: 800; flex-shrink: 0;
}
.client-profile-card__name { font-weight: 700; font-size: 15px; color: var(--ds-color-primary,#1B2B4B); }
.client-profile-card__meta { font-size: 12px; color: #6B7280; margin-top: 2px; }
.client-profile-card__body { padding: 14px 20px; }
.client-profile-card__row  {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0; font-size: 13px; color: #374151;
  border-bottom: 1px solid #F9FAFB;
}
.client-profile-card__row:last-child { border-bottom: none; }
.client-profile-card__row i { font-size: 15px; }
.client-profile-card__stat {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: #F3F4F6;
  border-top: 1px solid #F3F4F6;
}
.client-profile-card__stat-item {
  background: #fff;
  padding: 12px;
  text-align: center;
}
.client-profile-card__stat-item strong { display: block; font-size: 18px; color: var(--ds-color-primary,#1B2B4B); font-weight: 800; }
.client-profile-card__stat-item span   { font-size: 11px; color: #9CA3AF; }

/* ════════════════════════════════════════════════════════
   7. SEARCH-FIRST MODAL (duplicate prevention)
   ════════════════════════════════════════════════════════ */

.search-first-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.15s ease;
}
.search-first-box {
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  width: 480px; max-width: 95vw;
  box-shadow: 0 24px 48px rgba(0,0,0,0.18);
  animation: slideUp 0.2s ease;
}
.search-first-box h3 {
  font-weight: 800; font-size: 16px; color: var(--ds-color-primary,#1B2B4B);
  margin-bottom: 4px;
}
.search-first-box p  { font-size: 13px; color: #6B7280; margin-bottom: 16px; }
.search-first-result {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid #E5E7EB; margin-bottom: 6px;
  transition: background 0.12s, border-color 0.12s;
}
.search-first-result:hover { background: #F0F4FF; border-color: var(--ds-color-primary,#1B2B4B); }
.search-first-result__name  { font-weight: 600; font-size: 13px; }
.search-first-result__meta  { font-size: 12px; color: #9CA3AF; }
.search-first-divider {
  text-align: center; font-size: 12px; color: #9CA3AF;
  margin: 14px 0 12px; position: relative;
}
.search-first-divider::before, .search-first-divider::after {
  content: ''; position: absolute; top: 50%; width: 42%; height: 1px;
  background: #E5E7EB;
}
.search-first-divider::before { left: 0; }
.search-first-divider::after  { right: 0; }

/* ════════════════════════════════════════════════════════
   8. INLINE FIELD VALIDATION
   ════════════════════════════════════════════════════════ */

.ux-field {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ux-field label {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
}
.ux-field label .required { color: #EF4444; margin-left: 2px; }
.ux-field input,
.ux-field select,
.ux-field textarea {
  border: 1.5px solid #E5E7EB;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  background: #fff;
  color: #1F2937;
}
.ux-field input:focus,
.ux-field select:focus,
.ux-field textarea:focus {
  border-color: var(--ds-color-primary, #1B2B4B);
  box-shadow: 0 0 0 3px rgba(27,43,75,0.08);
}
.ux-field.invalid input,
.ux-field.invalid select { border-color: #EF4444; }
.ux-field.valid   input,
.ux-field.valid   select { border-color: #059669; }
.ux-field__hint {
  font-size: 11px;
  color: #9CA3AF;
  line-height: 1.4;
}
.ux-field.invalid .ux-field__hint { color: #DC2626; }
.ux-field.valid   .ux-field__hint { color: #059669; }

/* ════════════════════════════════════════════════════════
   9. OS KANBAN BOARD (optional view)
   ════════════════════════════════════════════════════════ */

.os-kanban {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 4px 16px;
  align-items: flex-start;
}
.os-kanban::-webkit-scrollbar { height: 6px; }
.os-kanban::-webkit-scrollbar-thumb { background: #E5E7EB; border-radius: 3px; }

.os-kanban-col {
  flex-shrink: 0;
  width: 220px;
  background: #F9FAFB;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #F0F0F0;
}
.os-kanban-col__header {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.os-kanban-col__count {
  background: rgba(0,0,0,0.08);
  border-radius: 99px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 800;
}
.os-kanban-col__body { padding: 8px; display: flex; flex-direction: column; gap: 6px; min-height: 80px; }
.os-kanban-card {
  background: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  border: 1px solid #EBEBEB;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
}
.os-kanban-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}
.os-kanban-card__id     { font-size: 10px; color: #9CA3AF; font-weight: 700; margin-bottom: 3px; }
.os-kanban-card__client { font-size: 13px; color: #1F2937; font-weight: 600; }
.os-kanban-card__device { font-size: 11px; color: #6B7280; margin-top: 2px; }
.os-kanban-card__footer { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }

/* ════════════════════════════════════════════════════════
   10. MOBILE RESPONSIVE
   ════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
  .os-timeline { padding: 16px 0 8px; }
  .os-timeline__step { min-width: 68px; }
  .os-timeline__label { font-size: 9px; max-width: 58px; }
  .os-header-card { grid-template-columns: 1fr; }
  .os-header-card__actions { justify-content: flex-start; }
  .ux-action-bar { gap: 6px; }
  .ux-btn { font-size: 12px; padding: 7px 11px; }
}
