/**
 * gre.css - Estilos Enterprise Guías Electrónicas
 * @version 4.0 Enterprise
 * Material Design + Fluent Design System
 */

/* ==========================================
   VARIABLES ESPECÍFICAS GRE
   ========================================== */
:root {
  --gre-primary: #408cbc;
  --gre-primary-dark: #2a5f7d;
  --gre-accent: #00b4d8;
  --gre-success: #28a745;
  --gre-warning: #ffc107;
  --gre-danger: #dc3545;
  --gre-shadow-sm: 0 2px 4px rgba(0,0,0,0.08);
  --gre-shadow-md: 0 4px 12px rgba(0,0,0,0.12);
  --gre-shadow-lg: 0 8px 24px rgba(0,0,0,0.15);
  --gre-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================
   FLUENT CARD PRINCIPAL
   ========================================== */
.fluent-card {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: var(--gre-shadow-md);
  margin-bottom: 24px;
  transition: var(--gre-transition);
  border: 1px solid rgba(0,0,0,0.05);
  overflow: hidden;
}

.fluent-card:hover {
  box-shadow: var(--gre-shadow-lg);
}

.fluent-card-header {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  padding: 24px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  gap: 16px;
}

.fluent-header-icon {
  width: 56px;
  height: 56px;
  background: var(--gre-primary);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
  box-shadow: 0 4px 12px rgba(64, 140, 188, 0.3);
}

.fluent-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: #2b2d42;
  letter-spacing: -0.5px;
}

.fluent-subtitle {
  margin: 4px 0 0 0;
  color: #6c757d;
  font-size: 0.95rem;
}

.fluent-card-body {
  padding: 24px;
}

.fluent-card-footer {
  background: #f8f9fa;
  padding: 20px 24px;
  border-top: 1px solid rgba(0,0,0,0.06);
}

/* ==========================================
   SECCIONES DEL FORMULARIO
   ========================================== */
.fluent-section {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid #e9ecef;
}

.fluent-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.fluent-section-highlight {
  background: linear-gradient(135deg, #f8f9ff 0%, #ffffff 100%);
  border: 2px solid #e0e7ff;
  border-radius: 8px;
  padding: 20px;
  margin-left: -12px;
  margin-right: -12px;
}

.fluent-section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gre-primary-dark);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.fluent-section-title i {
  color: var(--gre-primary);
  font-size: 1.2rem;
}

/* ==========================================
   INPUTS Y FORMULARIOS
   ========================================== */
.fluent-input-group {
  margin-bottom: 20px;
  position: relative;
}

.fluent-label {
  display: block;
  font-weight: 600;
  color: #495057;
  margin-bottom: 8px;
  font-size: 0.9rem;
  transition: var(--gre-transition);
}

.fluent-input-group:focus-within .fluent-label {
  color: var(--gre-primary);
}

.fluent-input {
  border: 2px solid #dee2e6;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.95rem;
  transition: var(--gre-transition);
  background: #fff;
  width: 100%;
}

.fluent-input:focus {
  border-color: var(--gre-primary);
  box-shadow: 0 0 0 3px rgba(64, 140, 188, 0.15);
  outline: none;
}

.fluent-input[readonly] {
  background: #f8f9fa;
  border-color: #e9ecef;
  color: #6c757d;
}

.fluent-input-number {
  font-family: 'Roboto Mono', monospace;
  font-weight: 500;
}

.fluent-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23408cbc' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

.fluent-addon {
  background: #f8f9fa;
  border: 2px solid #dee2e6;
  border-right: none;
  color: var(--gre-primary);
  font-size: 1.1rem;
}

.input-group .fluent-input {
  border-left: none;
}

.fluent-btn-check {
  background: #e9ecef;
  border: 2px solid #dee2e6;
  color: #6c757d;
  transition: var(--gre-transition);
}

.fluent-btn-check:hover {
  background: var(--gre-primary);
  border-color: var(--gre-primary);
  color: white;
}

/* Estados de validación */
.has-success .fluent-input,
.has-success .fluent-input:focus {
  border-color: var(--gre-success);
}

.has-success .fluent-label {
  color: var(--gre-success);
}

.has-error .fluent-input,
.has-error .fluent-input:focus {
  border-color: var(--gre-danger);
}

.has-error .fluent-label {
  color: var(--gre-danger);
}

/* ==========================================
   BOTONES FLUENT
   ========================================== */
.fluent-btn-primary {
  background: linear-gradient(135deg, var(--gre-primary) 0%, var(--gre-primary-dark) 100%);
  border: none;
  border-radius: 8px;
  padding: 12px 28px;
  font-weight: 600;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 12px rgba(64, 140, 188, 0.3);
  transition: var(--gre-transition);
  text-transform: uppercase;
  font-size: 0.9rem;
}

.fluent-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(64, 140, 188, 0.4);
}

.fluent-btn-secondary {
  background: #f8f9fa;
  border: 2px solid #dee2e6;
  color: #6c757d;
  border-radius: 8px;
  padding: 12px 24px;
  font-weight: 600;
  transition: var(--gre-transition);
  margin-right: 12px;
}

.fluent-btn-secondary:hover {
  background: #e9ecef;
  border-color: #ced4da;
  color: #495057;
}

/* ==========================================
   BADGES Y ETIQUETAS
   ========================================== */
.fluent-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  gap: 6px;
}

.fluent-badge-info {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

/* ==========================================
   TABLA DE LISTADO (GRL)
   ========================================== */
#tblGre {
  border-collapse: separate;
  border-spacing: 0;
}

#tblGre thead th {
  background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
  border-bottom: 2px solid var(--gre-primary);
  color: var(--gre-primary-dark);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.5px;
  padding: 16px 12px;
}

#tblGre tbody tr {
  transition: var(--gre-transition);
}

#tblGre tbody tr:hover {
  background: #f8f9ff;
  transform: scale(1.002);
  box-shadow: var(--gre-shadow-sm);
}

#tblGre tbody td {
  padding: 14px 12px;
  border-bottom: 1px solid #e9ecef;
  vertical-align: middle;
}

/* Botones de acción en tabla */
.btn-action-dropdown {
  background: var(--gre-primary);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  transition: var(--gre-transition);
}

.btn-action-dropdown:hover {
  background: var(--gre-primary-dark);
  transform: translateY(-1px);
}

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (max-width: 768px) {
  .fluent-card-header {
    flex-direction: column;
    text-align: center;
    padding: 20px;
  }
  
  .fluent-header-icon {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }
  
  .fluent-title {
    font-size: 1.25rem;
  }
  
  .fluent-section-highlight {
    margin-left: 0;
    margin-right: 0;
    padding: 16px;
  }
  
  .fluent-btn-primary,
  .fluent-btn-secondary {
    width: 100%;
    margin-bottom: 10px;
    margin-right: 0;
  }
}

/* ==========================================
   ANIMACIONES
   ========================================== */
@keyframes fluentSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fluent-card {
  animation: fluentSlideIn 0.4s ease-out;
}

/* Toast container */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
}

/* ==========================================
   LISTADO Y TRAZABILIDAD SUNAT
   ========================================== */
.gre-list-toolbar,
.gre-trace-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.gre-toolbar-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gre-primary-dark);
}

.gre-toolbar-subtitle {
  margin: 4px 0 0;
  color: #6c757d;
  font-size: 0.9rem;
}

.gre-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.gre-badge {
  border-radius: 6px;
  padding: 6px 8px;
  font-weight: 600;
}

.gre-badge-success {
  background: #198754;
}

.gre-badge-danger {
  background: #dc3545;
}

.gre-badge-warning {
  background: #ffc107;
  color: #1f2937;
}

.gre-badge-info {
  background: #0dcaf0;
  color: #1f2937;
}

.gre-trace-panel {
  border-radius: 8px;
}

.gre-trace-list {
  display: grid;
  gap: 14px;
}

.gre-trace-item {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px;
  background: #ffffff;
}

.gre-trace-highlight {
  border-color: var(--gre-primary);
  box-shadow: 0 0 0 3px rgba(64, 140, 188, 0.12);
}

.gre-trace-summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  color: #334155;
}

.gre-trace-step {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  padding: 9px 0;
  border-top: 1px dashed #e5e7eb;
}

.gre-trace-step:first-of-type {
  border-top: 0;
}

.trace-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #eef2f7;
}

.trace-success .trace-icon {
  background: #dcfce7;
  color: #15803d;
}

.trace-running .trace-icon {
  background: #e0f2fe;
  color: #0369a1;
}

.trace-pending .trace-icon {
  background: #fef3c7;
  color: #92400e;
}

.trace-error .trace-icon {
  background: #fee2e2;
  color: #b91c1c;
}

.trace-title {
  font-weight: 600;
  color: #1f2937;
}

.trace-message {
  color: #64748b;
  font-size: 0.9rem;
}

.trace-code {
  margin-top: 4px;
  padding: 5px 7px;
  background: #f8fafc;
  border-radius: 6px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.82rem;
  color: #334155;
  overflow-wrap: anywhere;
}

.gre-max-mixer {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
}

.gre-max-mixer:focus {
  outline: 2px solid var(--gre-primary);
  outline-offset: 2px;
}

.gre-swal-trace {
  text-align: left;
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.gre-swal-step {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  align-items: start;
  padding: 8px;
  border-radius: 8px;
  background: #f8fafc;
}

@media (max-width: 768px) {
  .gre-list-toolbar,
  .gre-trace-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .gre-toolbar-actions {
    width: 100%;
  }

  .gre-toolbar-actions .btn {
    flex: 1 1 auto;
  }
}
