// Design moderne pour le tableau contextuel
.loading-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
}

.table-container {
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  overflow-x: auto;
  overflow-y: hidden;
  margin: 16px 0;
  
  // Style de la scrollbar horizontale
  &::-webkit-scrollbar {
    height: 8px;
  }
  
  &::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 4px;
  }
  
  &::-webkit-scrollbar-thumb {
    background: #ced4da;
    border-radius: 4px;
    
    &:hover {
      background: #adb5bd;
    }
  }
  
  .contextual-table {
    min-width: 800px; // Largeur minimale pour forcer le scroll
    width: max-content; // S'adapte au contenu
    background: transparent;
    
    .table-header {
      background-color: #f8f9fa;
      color: #495057;
      font-weight: 600;
      font-size: 0.875rem;
      padding: 16px 12px;
      border-bottom: 1px solid #e9ecef;
      text-transform: uppercase;
      letter-spacing: 0.025em;
      
      &:hover {
        background-color: #e9ecef;
      }
      
      .mat-sort-header-arrow {
        color: #6c757d;
      }
    }
    
    .table-cell {
      padding: 12px;
      border-bottom: 1px solid #f1f3f4;
      color: #212529;
      font-size: 0.875rem;
      line-height: 1.4;
      vertical-align: top;
      cursor: pointer;
      transition: background-color 0.15s ease;
      
      .cell-wrapper {
        display: flex;
        align-items: center;
        width: 100%;
        height: 100%;
        cursor: pointer;
        border-radius: 4px;
        padding: 2px;
        transition: background-color 0.15s ease;
        
        &:hover {
          background-color: rgba(25, 118, 210, 0.08);
        }
      }
      
      .cell-content {
        display: block;
        max-width: 100%;
        flex: 1;
        
        &.text-ellipsis {
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
        }
        
        &.amount-cell {
          text-align: right;
          font-weight: 500;
          color: #28a745;
          font-family: 'Courier New', monospace;
        }
        
        &.date-cell {
          color: #6c757d;
          font-family: 'Courier New', monospace;
          font-size: 0.8rem;
        }
        
        &.status-cell {
          display: inline-flex;
          align-items: center;
          padding: 4px 8px;
          border-radius: 12px;
          font-size: 0.75rem;
          font-weight: 500;
          text-transform: capitalize;
          background-color: #f8f9fa;
          border: 1px solid #e9ecef;
          
          &.status-success {
            background-color: #d4edda;
            color: #155724;
            border-color: #c3e6cb;
          }
          
          &.status-danger {
            background-color: #f8d7da;
            color: #721c24;
            border-color: #f5c6cb;
          }
          
          &.status-warning {
            background-color: #fff3cd;
            color: #856404;
            border-color: #ffeaa7;
          }
          
          &.status-info {
            background-color: #d1ecf1;
            color: #0c5460;
            border-color: #bee5eb;
          }
          
          &::before {
            content: '';
            display: inline-block;
            width: 6px;
            height: 6px;
            border-radius: 50%;
            margin-right: 6px;
            background-color: currentColor;
            opacity: 0.8;
          }
        }
        
        &.email-cell {
          color: #1976d2;
          font-family: 'Courier New', monospace;
          font-size: 0.8rem;
          
          &:hover {
            text-decoration: underline;
          }
        }
        
        &.phone-cell {
          color: #2e7d32;
          font-family: 'Courier New', monospace;
          font-size: 0.8rem;
          font-weight: 500;
        }
      }
    }
    
    .header-row {
      .mat-header-cell {
        border-bottom: 2px solid #dee2e6;
      }
    }
    
    .data-row {
      transition: background-color 0.15s ease;
      
      &:hover {
        background-color: #f8f9fa;
      }
      
      &.clickable {
        cursor: pointer;
        
        &:hover {
          background-color: #e3f2fd;
          transform: translateY(-1px);
          box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }
      }
      
      &:nth-child(even) {
        background-color: #fafbfc;
        
        &:hover {
          background-color: #e3f2fd;
        }
      }
    }
  }
}

.table-paginator {
  background: #ffffff;
  border-top: 1px solid #e9ecef;
  border-radius: 0 0 8px 8px;
  
  ::ng-deep {
    .mat-paginator-container {
      padding: 8px 16px;
      min-height: 48px;
    }
    
    .mat-paginator-page-size {
      color: #6c757d;
      font-size: 0.875rem;
    }
    
    .mat-paginator-range-label {
      color: #6c757d;
      font-size: 0.875rem;
      margin: 0 16px;
    }
    
    .mat-icon-button {
      color: #6c757d;
      
      &:disabled {
        color: #ced4da;
      }
      
      &:hover:not([disabled]) {
        background-color: #e9ecef;
        color: #495057;
      }
    }
  }
}

// Responsive design
@media (max-width: 768px) {
  .table-container {
    margin: 8px 0;
    border-radius: 4px;
    
    .contextual-table {
      .table-header {
        padding: 12px 8px;
        font-size: 0.75rem;
      }
      
      .table-cell {
        padding: 8px;
        font-size: 0.8rem;
        
        .cell-content {
          &.text-ellipsis {
            max-width: 120px;
          }
        }
      }
    }
  }
}

// Correction du chevauchement avec la tabbar
::ng-deep .mat-tab-body-content {
  padding-top: 8px;
}

::ng-deep .mat-table-sticky {
  z-index: 90 !important;
}

::ng-deep .mat-tab-header {
  z-index: 100 !important;
  position: relative;
}

// Styles pour les cellules référence cliquables
.reference-cell-link {
  color: #2563eb !important;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  transition: color 0.15s ease, text-decoration-style 0.15s ease;

  &:hover {
    color: #1d4ed8 !important;
    text-decoration-style: solid;
  }
}