/**
 * Estilos especificos para cada vista de la aplicacion:
 * Dashboard, Punto de Venta / Taller, Inventario, Cuentas Corrientes y Caja.
 */

/* Grid de dos columnas */
.grid-2 {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 980px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* 1. Dashboard & KPIs */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

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

.kpi-title {
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
}

.kpi-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.kpi-icon svg {
  width: 16px;
  height: 16px;
}

.kpi-icon-danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.kpi-value {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.kpi-value-danger {
  color: var(--danger);
}

.kpi-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

/* 2. Facturacion y Taller (POS) */
.service-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 0.55rem;
  margin-bottom: 1.1rem;
}

.service-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  min-height: 2.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
  font-size: 0.82rem;
  color: var(--text-main);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s ease;
}

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

.service-btn:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.service-btn:focus:not(:focus-visible) {
  outline: none;
}

.service-price {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: var(--bg-surface);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.cart-summary {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 1rem 1.15rem;
  border-radius: var(--radius-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 1rem 0;
}

.cart-summary-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.cart-total-amount {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
}

.fiado-box {
  background: var(--danger-soft);
  border: 1px solid var(--danger-border);
  padding: 0.9rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

.fiado-box-title {
  font-size: 0.78rem;
  color: var(--danger);
  margin-bottom: 0.65rem;
  font-weight: 600;
}

/* 3. Inventario y Stock */
.filter-pills {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.pill-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.35rem 0.75rem;
  min-height: 2.125rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
}

.pill-btn:hover {
  border-color: #9ca3af;
  color: var(--text-main);
}

.pill-btn:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.pill-btn:focus:not(:focus-visible) {
  outline: none;
}

.pill-btn.active {
  background: var(--text-main);
  color: #ffffff;
  border-color: var(--text-main);
}

.search-input-wrap {
  min-width: 250px;
}

.actions-cell {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* 4. Cuentas Corrientes */
.whatsapp-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.whatsapp-btn svg {
  width: 14px;
  height: 14px;
}

/* 5. Vista de Acceso y Control de Sesion (Auth) */
#view-auth {
  display: none;
  width: 100%;
}

#view-auth.active {
  display: block;
}

.auth-container {
  min-height: calc(100vh - 120px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius-md);
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

.auth-header {
  padding: 1.75rem 1.75rem 1.25rem;
  text-align: center;
  border-bottom: 1px solid #e5e7eb;
  background: #ffffff;
}

.auth-brand-mark {
  width: 42px;
  height: 42px;
  margin: 0 auto 0.75rem;
  border-radius: 8px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
}

.auth-brand-mark svg {
  width: 24px;
  height: 24px;
}

.auth-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.015em;
  margin-bottom: 0.25rem;
}

.auth-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.auth-tabs {
  display: flex;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
}

.auth-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.75rem 0.5rem;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  border-radius: 0;
}

.auth-tab-btn:hover {
  color: var(--text-main);
  background: #f3f4f6;
}

.auth-tab-btn:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: -2px;
}

.auth-tab-btn:focus:not(:focus-visible) {
  outline: none;
}

.auth-tab-btn.active,
.auth-tab-btn[aria-selected="true"] {
  color: var(--primary);
  font-weight: 600;
  border-bottom-color: var(--primary);
  background: #ffffff;
}

.auth-body {
  padding: 1.5rem 1.75rem;
}

.auth-panel {
  display: none;
}

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

.auth-panel[hidden] {
  display: none !important;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-input-wrap .auth-icon-left {
  position: absolute;
  left: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  pointer-events: none;
}

.auth-input-wrap .auth-icon-left svg {
  width: 16px;
  height: 16px;
}

.auth-input-wrap input {
  width: 100%;
  padding-left: 2.35rem;
}

.auth-input-wrap input.input-error,
.auth-input-wrap input[aria-invalid="true"] {
  padding-left: calc(2.35rem - 1px);
}

.auth-input-wrap.has-toggle input {
  padding-right: 2.5rem;
}

/* Checklist de 4 reglas de contraseña en registro */
.password-rules-list {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.85rem;
  margin-top: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.password-rule {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.76rem;
  color: #6b7280;
  transition: color 0.15s;
}

.password-rule-icon {
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #9ca3af; /* Gris pendiente */
  transition: color 0.15s;
}

.password-rule-icon svg {
  width: 14px;
  height: 14px;
}

.password-rule.cumplida {
  color: #059669; /* Verde cumplimiento */
  font-weight: 500;
}

.password-rule.cumplida .password-rule-icon {
  color: #059669;
}

.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 1.1rem 0;
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid #e5e7eb;
}

.auth-divider::before {
  margin-right: 0.75em;
}

.auth-divider::after {
  margin-left: 0.75em;
}

/* 6. Boton de impresion de orden y estado de conector en topbar */
.btn-print-last {
  margin-top: 0.65rem;
}

.status-pill-cloud {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary-border);
}

.status-pill-cloud .status-dot {
  background: var(--primary);
}

/* 7. Comprobante / Orden de Trabajo Imprimible */
.print-receipt {
  display: none;
}

@media print {
  @page {
    margin: 12mm;
  }

  body {
    background: #ffffff !important;
    color: #111827 !important;
    display: block !important;
  }

  .sidebar,
  .app-sidebar,
  .topbar,
  .app-shell,
  .modal-backdrop,
  #toast-container {
    display: none !important;
  }

  .print-receipt {
    display: block !important;
    width: 100%;
    color: #111827;
    background: #ffffff;
  }

  .print-sheet {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 1.5rem;
    max-width: 720px;
    margin: 0 auto;
  }

  .print-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2px solid #111827;
    padding-bottom: 0.85rem;
    margin-bottom: 1rem;
  }

  .print-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #111827;
    margin: 0 0 0.2rem 0;
  }

  .print-subtitle {
    font-size: 0.82rem;
    color: #4b5563;
    margin: 0;
  }

  .print-badge {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0.25rem 0.6rem;
    border: 1px solid #111827;
    border-radius: 4px;
  }

  .print-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem 1.25rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.82rem;
  }

  .print-meta-row {
    display: flex;
    gap: 0.4rem;
    align-items: baseline;
  }

  .print-meta-label {
    color: #4b5563;
    font-weight: 500;
  }

  .print-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    font-size: 0.84rem;
  }

  .print-table th,
  .print-table td {
    border-bottom: 1px solid #e5e7eb;
    padding: 0.55rem 0.5rem;
    text-align: left;
  }

  .print-table th {
    background: #f3f4f6;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #374151;
  }

  .print-totals {
    border-top: 2px solid #111827;
    padding-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
  }

  .print-total-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
  }

  .print-total-main {
    font-size: 1.1rem;
    font-weight: 700;
  }

  .print-footer {
    margin-top: 1.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e5e7eb;
    font-size: 0.75rem;
    color: #6b7280;
    text-align: center;
  }
}


