/* You can add global styles to this file, and also import other style files */

// Importar sistema de design
@import "assets/styles/app.scss";

// ... resto dos seus estilos globais

/* ===================================================
   LAYOUT FIXES - GARANTIR COORDENAÇÃO SIDEBAR/MAIN
   =================================================== */

/* Garantir que sidebar e main-content estejam perfeitamente alinhados */
app-sidebar {
  .sidebar {
    position: fixed;
    left: 8px; /* ✅ Margem esquerda */
    top: 68px; /* ✅ Abaixo do header */
    z-index: 1000;
    height: calc(100vh - 68px); /* ✅ Descontar altura do header */
    
    /* Garantir larguras exatas */
    &:not(.collapsed) {
      width: 240px;
    }
    
    &.collapsed {
      width: 80px;
    }

    /* ✅ MOBILE: Sidebar oculta por padrão */
    @media (max-width: 768px) {
      left: 0; /* No mobile, sem margem */
      top: 68px; /* Abaixo do header */
      height: calc(100vh - 68px - 80px); /* Descontar header + footer */
      
      &:not(.force-visible) {
        transform: translateX(-100%);
        opacity: 0;
        pointer-events: none;
      }
    }
  }
}

app-main-layout {
  .main-content {
    /* Garantir margens exatas que correspondem à sidebar */
    margin-left: 80px; /* Sidebar colapsada */
    transition: margin-left 0.3s ease;
    
    &.expanded {
      margin-left: 240px; /* Sidebar expandida */
    }

    /* ✅ MOBILE: Largura total quando sidebar oculta */
    &.mobile-full {
      margin-left: 0;
    }

    /* ✅ MOBILE: Sempre largura total */
    @media (max-width: 768px) {
      margin-left: 0 !important;
    }
  }
  
  .page-content {
    /* Garantir que o conteúdo não vaze */
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
  }
}

app-header {
  .header {
    /* Garantir larguras exatas que correspondem à sidebar */
    width: calc(100% - 80px); /* Sidebar colapsada */
    
    &.header-expanded {
      width: calc(100% - 240px); /* Sidebar expandida */
    }

    /* ✅ MOBILE: Largura total */
    @media (max-width: 768px) {
      width: 100% !important;
    }
  }
}

/* Prevenir overflow horizontal globalmente */
html, body {
  overflow-x: hidden;
  width: 100%;
  max-width: 100%;
}

*, *::before, *::after {
  box-sizing: border-box;
  max-width: 100%;
}

/* Prevenir tabelas e elementos grandes de quebrar o layout */
table {
  table-layout: fixed;
  width: 100%;
}

/* Quebrar palavras longas se necessário */
.text-breakable {
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Classes utilitárias para controle de overflow */
.overflow-hidden {
  overflow: hidden !important;
}

.overflow-x-hidden {
  overflow-x: hidden !important;
}

.overflow-y-hidden {
  overflow-y: hidden !important;
}

.no-scroll {
  overflow: hidden !important;
}

/* Classes para responsividade de containers */
.container-responsive {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
  word-wrap: break-word;
  word-break: break-word;
}

/* Classe para elementos que devem se adaptar ao container pai */
.fit-container {
  width: 100%;
  max-width: 100%;
  min-width: 0; /* Permite flexbox shrink */
  box-sizing: border-box;
  overflow-x: hidden;
}

:root {
  --primary: #f1b40d;
  --background: #f8f9fa;
  --surface: #ffffff;
  --text-primary: rgba(0, 0, 0, 0.87);
  --text-secondary: rgba(0, 0, 0, 0.6);
  --divider: rgba(0, 0, 0, 0.12);
}

.dark-theme {
  --background: #121212;
  --surface: #1e1e1e;
  --text-primary: rgba(255, 255, 255, 0.87);
  --text-secondary: rgba(255, 255, 255, 0.6);
  --divider: rgba(255, 255, 255, 0.12);
  
  /* Cores primárias ajustadas para tema escuro */
  --idt-primary-color: #FFD700;
  --idt-primary-shade: #FFC82E;
  --idt-primary-tint: #FFEB3B;
}

body {
  background-color: var(--background);
  color: var(--text-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
}

.custom-popup .leaflet-popup-content-wrapper {
  background: white;
  border-radius: 8px;
  box-shadow: 0 3px 14px rgba(0,0,0,0.2);
}

.custom-popup .leaflet-popup-content {
  margin: 8px;
  min-width: 200px;
}

.custom-popup .leaflet-popup-tip {
  background: white;
}

// Estilos personalizados para o popup do mapa
.custom-popup {
  .leaflet-popup-content-wrapper {
    padding: 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  }

  .leaflet-popup-content {
    margin: 0;
    min-width: 250px;
  }

  .leaflet-popup-tip-container {
    display: none; // Remove a seta do popup
  }
}

.custom-dialog-container .mat-dialog-container {
  overflow: visible;
  pointer-events: auto;
}

.vehicle-popup {
  font-family: var(--font-primary);

  .vehicle-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;

    .status-badge {
      padding: 4px 8px;
      border-radius: 12px;
      font-size: var(--font-size-xs);
      color: white;
      font-weight: var(--font-weight-medium);
    }
  }

  .vehicle-info-section {
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
  }

  .vehicle-main-info {
    display: flex;
    align-items: center;
    gap: 12px;

    .vehicle-logo {
      width: 40px;
      height: 40px;
      object-fit: contain;
    }

    .model-name {
      font-weight: var(--font-weight-semibold);
      font-size: var(--font-size-sm);
      color: var(--text-primary);
    }

    .brand-name {
      color: var(--text-secondary);
      font-size: var(--font-size-xs);
    }
  }

  .vehicle-specs {
    display: flex;
    justify-content: space-around;
    padding: 12px;
    background: #f8f9fa;
    margin: 10px 0;
    border-radius: 8px;

    .spec-item {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 4px;

      i {
        color: var(--primary);
        font-size: var(--font-size-base);
      }

      span {
        font-size: var(--font-size-xs);
        color: var(--text-secondary);
      }
    }
  }

  .driver-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-top: 1px solid #f0f0f0;

    .driver-avatar {
      width: 40px;
      height: 40px;
      border-radius: 50%;
      object-fit: cover;
    }

    .driver-details {
      .driver-name {
        font-weight: 900;
        font-size: 13px;
      }

      .driver-status {
        font-size: 12px;
        color: #666;
        display: flex;
        align-items: center;
        gap: 4px;

        .status-dot {
          width: 8px;
          height: 8px;
          border-radius: 50%;
          
          &.active {
            background-color: #4CAF50;
          }
          
          &.inactive {
            background-color: #757575;
          }
        }
      }
    }
  }

  .vehicle-details {
    padding: 12px;
    border-top: 1px solid #f0f0f0;

    .detail-row {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-bottom: 6px;
      font-size: 12px;
      color: #666;

      i {
        color: var(--primary);
        width: 16px;
      }
    }
  }
}

// Estilo para centralizar o diálogo
.centered-dialog {
  .mat-dialog-container {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 0 !important;
    overflow: hidden !important;
  }
}

// Ajuste para o overlay
.cdk-overlay-pane.centered-dialog {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  max-width: 100vw !important;
}


// Estilo para o hover do marcador
.custom-div-icon {
  transition: transform 0.2s ease;
  
  &:hover {
    transform: scale(1.2);
    cursor: pointer;
  }
}

.highlighted-marker {
  transform: scale(1.3) !important;
  box-shadow: 0 0 15px rgba(0,0,0,0.9) !important;
  z-index: 1000 !important;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 15px rgba(0,0,0,0.9);
  }
  50% {
    box-shadow: 0 0 25px rgba(241, 180, 13, 0.9); // Usando a cor primária do seu tema
  }
  100% {
    box-shadow: 0 0 15px rgba(0,0,0,0.9);
  }
}

.vehicle-row {
  cursor: pointer;
  transition: background-color 0.2s ease;

  &:hover {
    background-color: rgba(241, 180, 13, 0.1); // Usando a cor primária com transparência
  }

  &:active {
    background-color: rgba(241, 180, 13, 0.2);
  }
}

.btn-icon {
  background: transparent;
  border: none;
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.2s ease;

  &:hover {
    background-color: rgba(241, 180, 13, 0.1);
  }

  &:active {
    background-color: rgba(241, 180, 13, 0.2);
  }

  i {
    font-size: 16px;
    color: var(--text-secondary);
  }
}

// Override global para Material Design tabs - força alinhamento à esquerda
.mat-mdc-tab-group {
  .mat-mdc-tab-header {
    .mat-mdc-tab-label-container {
      .mat-mdc-tab-list {
        .mat-mdc-tab-labels {
          justify-content: flex-start !important;
          
          .mat-mdc-tab-label {
            justify-content: flex-start !important;
            text-align: left !important;
            align-items: flex-start !important;
            
            .mat-mdc-tab-label-content {
              justify-content: flex-start !important;
              text-align: left !important;
              align-items: flex-start !important;
              width: 100% !important;
              display: flex !important;
              flex-direction: row !important;
              
              .mdc-tab__content {
                justify-content: flex-start !important;
                text-align: left !important;
                align-items: flex-start !important;
                display: flex !important;
                flex-direction: row !important;
                width: 100% !important;
                
                .mdc-tab__text-label {
                  text-align: left !important;
                  justify-content: flex-start !important;
                  align-items: flex-start !important;
                  width: 100% !important;
                  display: flex !important;
                  flex-direction: row !important;
                }
              }
            }
          }
        }
      }
    }
  }
}

// Força para qualquer elemento dentro de tabs
.mat-mdc-tab-label * {
  text-align: left !important;
  justify-content: flex-start !important;
  align-items: flex-start !important;
}

// Override específico para tab labels do Angular Material
.mat-mdc-tab-label {
  .mat-mdc-tab-label-content {
    justify-content: flex-start !important;
    text-align: left !important;
    align-items: flex-start !important;
    width: 100% !important;
  }
}

// Override para o conteúdo das abas especificamente
.mdc-tab__content,
.mdc-tab__text-label {
  justify-content: flex-start !important;
  text-align: left !important;
  align-items: flex-start !important;
  width: 100% !important;
}
