/**
 * Tramaco API Integration - Frontend Styles PROFESIONAL
 */

/* Variables de color */
:root {
  --tramaco-primary: #1e40af;
  --tramaco-primary-dark: #1e3a8a;
  --tramaco-success: #10b981;
  --tramaco-warning: #f59e0b;
  --tramaco-danger: #ef4444;
  --tramaco-info: #3b82f6;
  --tramaco-light: #f3f4f6;
  --tramaco-dark: #1f2937;
  --tramaco-border: #e5e7eb;
  --tramaco-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Contenedor principal del tracking */
.tramaco-tracking-wrapper {
  max-width: 900px;
  margin: 30px auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, sans-serif;
}

/* Header del tracking */
.tramaco-tracking-header {
  text-align: center;
  margin-bottom: 30px;
}

.tracking-title {
  font-size: 32px;
  color: var(--tramaco-dark);
  margin: 0 0 10px 0;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.tracking-icon {
  font-size: 36px;
}

.tracking-subtitle {
  color: #6b7280;
  font-size: 16px;
  margin: 0;
}

/* Formulario de tracking */
.tramaco-tracking-form {
  background: white;
  border-radius: 12px;
  padding: 30px;
  box-shadow: var(--tramaco-shadow);
  margin-bottom: 30px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

@media (min-width: 768px) {
  .form-row {
    grid-template-columns: 1fr 1fr;
  }

  .form-row .form-group-large {
    grid-column: 1 / -1;
  }
}

.form-group {
  margin-bottom: 0;
}

.form-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--tramaco-dark);
  font-size: 14px;
}

.label-icon {
  font-size: 16px;
}

.form-control,
.form-control-lg,
.form-control-select,
.form-select {
  width: 100%;
  padding: 12px 45px 12px 16px;
  border: 2px solid var(--tramaco-border);
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.4;
  transition: all 0.25s ease;
  box-sizing: border-box;
  background: linear-gradient(to bottom, #ffffff, #fafbfc);
  color: #374151 !important;
  font-weight: 500;
  white-space: normal;
  overflow: visible;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.form-control-select,
.form-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 20px;
  padding-right: 45px;
  cursor: pointer;
  font-weight: 600;
}

.form-control-select option,
.form-select option {
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.5;
  color: #374151 !important;
  background: white;
  font-weight: 500;
  white-space: normal;
}

/* Asegurar visibilidad en diferentes estados */
.form-select:focus,
.form-control-select:focus {
  outline: none;
  border-color: #3b82f6;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

select::-ms-expand {
  display: none;
}

.form-control-lg {
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 500;
}

.form-control:focus,
.form-control-lg:focus,
.form-control-select:focus {
  outline: none;
  border-color: var(--tramaco-primary);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

.form-row-verification {
  background: #f8fafc;
  padding: 20px;
  border-radius: 12px;
  border: 2px dashed var(--tramaco-border);
}

.form-text {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: #6b7280;
}

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--tramaco-primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--tramaco-primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(30, 64, 175, 0.3);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-lg {
  padding: 16px 32px;
  font-size: 17px;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  font-size: 18px;
}

.btn-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Resultado del tracking */
.tramaco-result {
  display: none;
  margin-top: 30px;
}

.tramaco-result.show {
  display: block;
  animation: fadeInUp 0.4s ease;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tramaco-result.error,
.tramaco-result.error-verification {
  background: #fef2f2;
  border: 2px solid var(--tramaco-danger);
  border-radius: 12px;
  padding: 20px;
  color: var(--tramaco-danger);
}

.tramaco-result.error-verification {
  background: #fff7ed;
  border-color: var(--tramaco-warning);
  color: #92400e;
}

/* Contenedor del resultado */
.tracking-result-container {
  background: white;
  border-radius: 12px;
  box-shadow: var(--tramaco-shadow);
  overflow: hidden;
}
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.form-group textarea {
  min-height: 100px;
  resize: vertical;
}

.form-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.form-row .form-group {
  flex: 1;
  min-width: 200px;
}

fieldset {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 25px;
}

fieldset legend {
  font-weight: 600;
  color: #007bff;
  padding: 0 10px;
  font-size: 18px;
}

.btn {
  display: inline-block;
  padding: 12px 30px;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-primary {
  background: #007bff;
  color: #fff;
}

.btn-primary:hover {
  background: #0056b3;
}

.btn-primary:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.btn-secondary {
  background: #6c757d;
  color: #fff;
}

.btn-secondary:hover {
  background: #545b62;
}

/* Resultados */
.tramaco-result {
  margin-top: 30px;
  padding: 20px;
  border-radius: 8px;
  display: none;
}

.tramaco-result.show {
  display: block;
}

.tramaco-result.success {
  background: #d4edda;
  border: 1px solid #c3e6cb;
  color: #155724;
}

.tramaco-result.error {
  background: #f8d7da;
  border: 1px solid #f5c6cb;
  color: #721c24;
}

.tramaco-result.info {
  background: #d1ecf1;
  border: 1px solid #bee5eb;
  color: #0c5460;
}

/* Tracking Timeline */
.tracking-timeline {
  position: relative;
  padding-left: 30px;
  margin-top: 20px;
}

.tracking-timeline::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #007bff;
}

.tracking-item {
  position: relative;
  padding: 15px;
  margin-bottom: 15px;
  background: #f8f9fa;
  border-radius: 8px;
  border-left: 3px solid #007bff;
}

.tracking-item::before {
  content: "";
  position: absolute;
  left: -24px;
  top: 20px;
  width: 12px;
  height: 12px;
  background: #007bff;
  border-radius: 50%;
  border: 2px solid #fff;
}

.tracking-item .tracking-date {
  font-size: 12px;
  color: #888;
  margin-bottom: 5px;
}

.tracking-item .tracking-status {
  font-weight: 600;
  color: #333;
  margin-bottom: 5px;
}

.tracking-item .tracking-description {
  color: #666;
  font-size: 14px;
}

.tracking-item .tracking-location {
  color: #888;
  font-size: 13px;
  margin-top: 5px;
}

/* Información de la guía */
.guia-info {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.guia-info h4 {
  margin: 0 0 15px 0;
  color: #333;
}

.guia-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
}

.guia-info-item {
  background: #fff;
  padding: 10px 15px;
  border-radius: 5px;
  border-left: 3px solid #007bff;
}

.guia-info-item label {
  display: block;
  font-size: 12px;
  color: #888;
  margin-bottom: 3px;
}

.guia-info-item span {
  font-weight: 600;
  color: #333;
}

/* Cotización resultado */
.cotizacion-resultado {
  text-align: center;
  padding: 30px;
}

.cotizacion-precio {
  font-size: 48px;
  font-weight: 700;
  color: #28a745;
  margin: 20px 0;
}

.cotizacion-desglose {
  text-align: left;
  background: #f8f9fa;
  padding: 20px;
  border-radius: 8px;
  margin-top: 20px;
}

.cotizacion-desglose table {
  width: 100%;
}

.cotizacion-desglose td {
  padding: 8px 0;
  border-bottom: 1px solid #e0e0e0;
}

.cotizacion-desglose td:last-child {
  text-align: right;
  font-weight: 600;
}

.cotizacion-desglose tr:last-child td {
  border-bottom: none;
  font-size: 18px;
  color: #28a745;
}

/* Guía generada */
.guia-generada {
  text-align: center;
}

.guia-generada .numero-guia {
  font-size: 32px;
  font-weight: 700;
  color: #007bff;
  background: #e7f1ff;
  padding: 20px;
  border-radius: 8px;
  margin: 20px 0;
  font-family: monospace;
}

.guia-generada .btn-descargar-pdf {
  margin-top: 20px;
}

/* Loading */
.tramaco-loading {
  text-align: center;
  padding: 30px;
}

.tramaco-loading .spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #007bff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 15px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Login required */
.tramaco-login-required {
  text-align: center;
  padding: 40px;
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 8px;
  color: #856404;
}

/* Responsive */
@media (max-width: 768px) {
  .tramaco-tracking-form,
  .tramaco-cotizacion-form,
  .tramaco-generar-guia-form {
    padding: 20px;
    margin: 10px;
  }

  .form-row {
    flex-direction: column;
  }

  .form-row .form-group {
    min-width: 100%;
  }

  .guia-info-grid {
    grid-template-columns: 1fr;
  }

  .cotizacion-precio {
    font-size: 36px;
  }

  .guia-generada .numero-guia {
    font-size: 20px;
  }
}
