// ========================================
// 🚀 DASHBOARD PRAFROTA - Estilos Enterprise
// ========================================

// 🛣️ Seção de Performance de Rotas
.routes-performance-section {
  margin: 3rem 0 2rem 0;
  
  .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-light);
    
    h2 {
      font-size: 1.8rem;
      font-weight: 700;
      color: var(--text-primary);
      margin: 0;
      display: flex;
      align-items: center;
      gap: 0.75rem;
      
      i {
        color: var(--primary);
        font-size: 1.5rem;
        filter: drop-shadow(0 0 8px rgba(var(--primary-rgb), 0.3));
      }
    }
    
    .section-subtitle {
      font-size: 0.95rem;
      color: var(--text-secondary);
      font-weight: 500;
      background: linear-gradient(135deg, var(--background-secondary) 0%, rgba(var(--primary-rgb), 0.1) 100%);
      padding: 0.5rem 1rem;
      border-radius: 20px;
      border: 1px solid var(--border-light);
      backdrop-filter: blur(10px);
    }
  }
  
  // Grid para cards de performance lado a lado
  .performance-cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 2rem;
    align-items: start;

    // Responsividade para mobile
    @media (max-width: 1200px) {
      grid-template-columns: 1fr;
      gap: 1rem;
    }
  }
  
  // Container para o card de volumes transportados
  .volumes-card-container {
    // display: flex;
    justify-content: flex-start;
    
    app-volumes-transported-card {
      width: 100%;
      max-width: 420px;
    }
  }

  // Container para o card de tipo de frota
  .fleet-type-card-container {
    display: flex;
    justify-content: flex-start;
    
    app-fleet-type-card {
      width: 100%;
      max-width: 600px;
    }
  }

  .routes-dashboard-container {
    background: transparent;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    
    // Efeito de borda sutil
    &::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.1) 0%, transparent 50%, rgba(var(--primary-rgb), 0.05) 100%);
      border-radius: 16px;
      pointer-events: none;
      z-index: 0;
    }
    
    app-routes-performance-dashboard {
      position: relative;
      z-index: 1;
      display: block;
    }
  }
}

// Responsividade para a seção de rotas
@media (max-width: 768px) {
  .routes-performance-section {
    margin: 2rem 0 1rem 0;
    
    .section-header {
      flex-direction: column;
      gap: 1rem;
      align-items: stretch;
      text-align: center;
      
      h2 {
        font-size: 1.5rem;
        justify-content: center;
        
        i {
          font-size: 1.3rem;
        }
      }
      
      .section-subtitle {
        align-self: center;
        font-size: 0.9rem;
      }
    }
    
    .routes-dashboard-container {
      border-radius: 12px;
    }
  }
}

// 📊 Seção de Despesas RFID
.expense-section {
  margin: 0.5rem 0;
  
  .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-light);
    
    h2 {
      font-size: 1.5rem;
      font-weight: 700;
      color: var(--text-primary);
      margin: 0;
      display: flex;
      align-items: center;
      gap: 0.75rem;
      
      i {
        color: var(--primary);
        font-size: 1.3rem;
      }
    }
    
    .chart-period {
      font-size: 0.9rem;
      color: var(--text-secondary);
      font-weight: 500;
      background: var(--background-secondary);
      padding: 0.5rem 1rem;
      border-radius: 20px;
      border: 1px solid var(--border-light);
    }
  }
  
  .expense-chart-container {
    background: var(--background);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-card);
  }
}

@media (max-width: 768px) {
  .expense-section {
    margin: 1rem 0;
    
    .section-header {
      flex-direction: column;
      align-items: flex-start;
      gap: 0.75rem;
      
      .chart-period {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
      }
    }
  }
}

.dashboard {
  padding: 1.5rem;
  background: var(--background);
  min-height: 100vh;
  
  &.loading {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

// ========================================
// 🔄 LOADING STATE
// ========================================

.dashboard-loading {
  text-align: center;
  padding: 4rem 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  
  .loading-content {
    max-width: 400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
  }
  
  h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
  }
  
  p {
    color: var(--text-secondary);
    margin: 0;
    font-size: 0.95rem;
  }
  
  // ✨ Spinner animado com 3 anéis
  .loading-spinner {
    position: relative;
    width: 80px;
    height: 80px;
    
    .spinner-ring {
      position: absolute;
      width: 100%;
      height: 100%;
      border: 3px solid transparent;
      border-top: 3px solid var(--primary);
      border-radius: 50%;
      animation: spin 1.2s linear infinite;
      
      &:nth-child(1) {
        animation-delay: 0s;
      }
      
      &:nth-child(2) {
        width: 60px;
        height: 60px;
        top: 10px;
        left: 10px;
        border-top-color: var(--primary-light);
        animation-delay: 0.2s;
      }
      
      &:nth-child(3) {
        width: 40px;
        height: 40px;
        top: 20px;
        left: 20px;
        border-top-color: var(--primary-lighter);
        animation-delay: 0.4s;
      }
    }
  }
  
  // ✨ Pontos animados
  .loading-dots {
    display: flex;
    gap: 0.5rem;
    
    span {
      width: 8px;
      height: 8px;
      background: var(--primary);
      border-radius: 50%;
      animation: dots 1.4s ease-in-out infinite both;
      
      &:nth-child(1) { animation-delay: 0s; }
      &:nth-child(2) { animation-delay: 0.2s; }
      &:nth-child(3) { animation-delay: 0.4s; }
    }
  }
}

// ========================================
// 🎬 ANIMAÇÕES DO LOADING
// ========================================

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes dots {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1.2);
    opacity: 1;
  }
}

// ========================================
// 📊 GRID DE KPIs
// ========================================

.kpis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  border-left: 4px solid var(--primary);
  
  &:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  }
  
  .kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
  }
  
  .kpi-icon-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    
    .kpi-label {
      font-size: 1rem;
      color: var(--text-primary);
      font-weight: 600;
      margin: 0;
    }
  }
  
  .kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0; // Evita que o ícone encolha
    
    i {
      font-size: 1.5rem;
      color: white;
    }
  }
  
  .kpi-change {
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    
    // ✨ ÍCONE (SETA) SEMPRE BRANCO
    i {
      color: white !important;
    }
    
    &.trend-up {
      color: #ef4444;
      background: rgba(34, 197, 94, 0.1);
    }
    
    &.trend-down {
      color: #22c55e;
      background: rgba(239, 68, 68, 0.1);
    }
    
    &.trend-stable {
      color: #6b7280;
      background: rgba(107, 114, 128, 0.1);
    }
  }
  
  .kpi-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 0.5rem;
  }
  
  .kpi-label {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
  }
  
  // ✨ NOVOS ESTILOS: Informações adicionais dos KPIs
  .kpi-subtitle {
    font-size: 0.875rem;
    color: var(--text-tertiary, #9ca3af);
    font-weight: 500;
    margin-top: 0.5rem;
    opacity: 0.8;
  }
  
  .kpi-details {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-light, rgba(229, 231, 235, 0.5));
    
    .detail-row {
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      gap: 0.25rem;
      font-size: 0.8rem;
      color: var(--text-secondary);
      line-height: 1.4;
    }
    
    .detail-item {
      font-weight: 500;
      
      &:first-child {
        color: var(--primary, #3b82f6);
      }
    }
    
    .detail-separator {
      color: var(--text-tertiary, #9ca3af);
      font-weight: 400;
    }
  }
  
  .kpi-total {
    font-size: 0.8rem;
    color: var(--text-tertiary, #9ca3af);
    font-weight: 500;
    margin-top: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: var(--background-secondary, rgba(248, 250, 252, 0.5));
    border-radius: 6px;
    border: 1px solid var(--border-light, rgba(229, 231, 235, 0.3));
  }
  
  // Cores específicas dos KPIs
  &.kpi-primary {
    border-left-color: #3b82f6;
    .kpi-icon { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
  }
  
  &.kpi-success {
    border-left-color: #22c55e;
    .kpi-icon { background: linear-gradient(135deg, #22c55e, #16a34a); }
  }
  
  &.kpi-warning {
    border-left-color: #f59e0b;
    .kpi-icon { background: linear-gradient(135deg, #f59e0b, #d97706); }
  }
  
  &.kpi-info {
    border-left-color: #06b6d4;
    .kpi-icon { background: linear-gradient(135deg, #06b6d4, #0891b2); }
  }
}

// ========================================
// 📱 RESPONSIVIDADE
// ========================================

@media (max-width: 768px) {
  .dashboard {
    padding: 1rem;
  }
  
  .kpis-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .kpi-card {
    padding: 1rem;
  }
  
  .kpi-value {
    font-size: 2rem;
  }
}

@media (max-width: 480px) {
  .dashboard {
    padding: 0.5rem;
  }
  
  .kpi-card {
    padding: 1rem;
  }
  
  .kpi-value {
    font-size: 1.8rem;
  }
}

// 🏢 Seção de breakdown por empresa - Design Elegante
.company-breakdown-section {
  margin-top: 2rem;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(248, 250, 252, 0.9) 100%);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 2rem;
  box-shadow: 
    0 10px 25px rgba(0, 0, 0, 0.1),
    0 4px 10px rgba(0, 0, 0, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.2);
  position: relative;
  overflow: hidden;

  // Efeito de brilho sutil
  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.6), transparent);
    animation: shimmer 3s infinite;
  }

  .section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid rgba(59, 130, 246, 0.1);
    position: relative;

    .header-content {
      h3 {
        margin: 0 0 0.5rem 0;
        font-size: 1.5rem;
        font-weight: 700;
        background: linear-gradient(135deg, #1e293b 0%, #3b82f6 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
        display: flex;
        align-items: center;
        gap: 0.75rem;

        i {
          background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
          -webkit-background-clip: text;
          -webkit-text-fill-color: transparent;
          background-clip: text;
          font-size: 1.25rem;
        }
      }

      .section-subtitle {
        font-size: 1rem;
        color: #64748b;
        font-weight: 500;
      }
    }

    .header-stats {
      .total-companies {
        background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
        color: white;
        padding: 0.5rem 1rem;
        border-radius: 25px;
        font-size: 0.9rem;
        font-weight: 600;
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
      }
    }
  }

  .company-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
  }

  .company-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(248, 250, 252, 0.95) 100%);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 
      0 8px 25px rgba(0, 0, 0, 0.08),
      0 3px 10px rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: translateY(20px);
    animation: slideInUp 0.6s ease forwards;

    &:hover {
      transform: translateY(-8px) scale(1.02);
      box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.12),
        0 8px 16px rgba(0, 0, 0, 0.06);
    }

    .company-header {
      padding: 1.5rem;
      background: linear-gradient(135deg, rgba(59, 130, 246, 0.05) 0%, rgba(147, 197, 253, 0.05) 100%);
      display: flex;
      align-items: center;
      gap: 1rem;
      border-bottom: 1px solid rgba(59, 130, 246, 0.1);

      .company-avatar {
        width: 48px;
        height: 48px;
        background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);

        i {
          color: white;
          font-size: 1.25rem;
        }
      }

      .company-info {
        flex: 1;

        .company-name {
          margin: 0 0 0.5rem 0;
          font-size: 1.1rem;
          font-weight: 700;
          color: #1e293b;
          line-height: 1.2;
        }

        .company-stats {
          display: flex;
          align-items: center;
          gap: 0.75rem;

          .company-value {
            font-size: 1.25rem;
            font-weight: 800;
            background: linear-gradient(135deg, #10b981 0%, #047857 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
          }

          .company-percentage {
            background: rgba(59, 130, 246, 0.1);
            color: #3b82f6;
            padding: 0.25rem 0.75rem;
            border-radius: 20px;
            font-size: 0.85rem;
            font-weight: 600;
          }
        }
      }

      .company-badge {
        text-align: center;
        background: rgba(255, 255, 255, 0.8);
        padding: 0.75rem;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);

        .record-count {
          display: block;
          font-size: 1.5rem;
          font-weight: 800;
          color: #3b82f6;
          line-height: 1;
        }

        .record-label {
          font-size: 0.75rem;
          color: #64748b;
          font-weight: 500;
          text-transform: uppercase;
          letter-spacing: 0.5px;
        }
      }
    }

    .company-breakdown {
      padding: 1.5rem;

      .breakdown-grid {
        display: flex;
        flex-direction: column;
        gap: 1rem;
      }

      .breakdown-item {
        background: rgba(255, 255, 255, 0.7);
        border-radius: 12px;
        padding: 1rem;
        border: 1px solid rgba(255, 255, 255, 0.3);
        transition: all 0.3s ease;
        opacity: 0;
        transform: translateX(-20px);
        animation: slideInLeft 0.6s ease forwards;

        &:hover {
          background: rgba(255, 255, 255, 0.9);
          transform: translateX(4px);
          box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
        }

        .breakdown-header {
          display: flex;
          align-items: center;
          gap: 0.75rem;
          margin-bottom: 0.75rem;

          .type-indicator {
            width: 36px;
            height: 36px;
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);

            i {
              color: white;
              font-size: 0.9rem;
            }
          }

          .breakdown-info {
            flex: 1;

            .type-name {
              display: block;
              font-size: 0.95rem;
              font-weight: 600;
              color: #1e293b;
              line-height: 1.2;
            }

            .type-count {
              font-size: 0.8rem;
              color: #64748b;
              font-weight: 500;
            }
          }
        }

        .breakdown-value {
          display: flex;
          justify-content: space-between;
          align-items: center;
          margin-bottom: 0.75rem;

          .value-amount {
            font-size: 1.1rem;
            font-weight: 700;
            color: #1e293b;
          }

          .value-percentage {
            background: rgba(59, 130, 246, 0.1);
            color: #3b82f6;
            padding: 0.2rem 0.6rem;
            border-radius: 15px;
            font-size: 0.8rem;
            font-weight: 600;
          }
        }

        .progress-container {
          height: 6px;
          background: rgba(0, 0, 0, 0.05);
          border-radius: 3px;
          overflow: hidden;
          position: relative;

          .progress-bar {
            height: 100%;
            border-radius: 3px;
            transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
            position: relative;
            overflow: hidden;

            .progress-glow {
              position: absolute;
              top: 0;
              left: -100%;
              width: 100%;
              height: 100%;
              background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
              animation: progressGlow 2s infinite;
            }
          }
        }
      }
    }
  }
}

// Animações
@keyframes slideInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInLeft {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

@keyframes progressGlow {
  0% { left: -100%; }
  100% { left: 100%; }
}

// Responsividade
@media (max-width: 768px) {
  .company-breakdown-section {
    padding: 1.5rem;
    
    .company-grid {
      grid-template-columns: 1fr;
    }
    
    .company-header {
      flex-direction: column;
      text-align: center;
      gap: 1rem;
    }
  }
} 