---
export interface Props {
  headers?: string[];
  rows?: (string | number | boolean)[][];
  caption?: string;
  className?: string;
  striped?: boolean;
  bordered?: boolean;
}

const { 
  headers = [], 
  rows = [], 
  caption, 
  className = '', 
  striped = false, 
  bordered = true 
} = Astro.props;
---

<div class={`glass-table-container ${className}`}>
  <table class={`glass-table ${striped ? 'striped' : ''} ${bordered ? 'bordered' : ''}`}>
    {caption && (
      <caption class="table-caption">{caption}</caption>
    )}
    {headers.length > 0 && (
      <thead>
        <tr>
          {headers.map(header => (
            <th>{header}</th>
          ))}
        </tr>
      </thead>
    )}
    <tbody>
      {rows.map(row => (
        <tr>
          {row.map(cell => (
            <td>{cell}</td>
          ))}
        </tr>
      ))}
    </tbody>
  </table>
</div>

<style>
  .glass-table-container {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 1rem;
    padding: 1rem;
    margin: 1.5rem 0;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
  }
  
  .glass-table-container:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
  }
  
  .glass-table {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
    color: #374151;
    font-size: 0.95rem;
  }
  
  .table-caption {
    caption-side: top;
    text-align: center;
    font-weight: 600;
    color: #3b82f6;
    margin-bottom: 1rem;
    font-size: 1.1rem;
  }
  
  .glass-table th,
  .glass-table td {
    padding: 0.875rem 1rem;
    text-align: left;
    vertical-align: middle;
    position: relative;
  }
  
  .glass-table th {
    background: rgba(59, 130, 246, 0.1);
    color: #1e40af;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid rgba(59, 130, 246, 0.2);
  }
  
  .glass-table td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: background-color 0.2s ease;
  }
  
  .glass-table.bordered th,
  .glass-table.bordered td {
    border-right: 1px solid rgba(255, 255, 255, 0.1);
  }
  
  .glass-table.bordered th:last-child,
  .glass-table.bordered td:last-child {
    border-right: none;
  }
  
  .glass-table.striped tbody tr:nth-child(odd) {
    background: rgba(255, 255, 255, 0.05);
  }
  
  .glass-table tbody tr:hover {
    background: rgba(59, 130, 246, 0.08);
    transform: scale(1.01);
  }
  
  .glass-table tbody tr:hover td {
    color: #1e40af;
  }
  
  /* 响应式设计 */
  @media (max-width: 768px) {
    .glass-table-container {
      overflow-x: auto;
      border-radius: 0.75rem;
    }
    
    .glass-table {
      min-width: 500px;
    }
    
    .glass-table th,
    .glass-table td {
      padding: 0.5rem 0.75rem;
      font-size: 0.85rem;
    }
  }
  
  /* 特殊单元格样式 */
  .glass-table .highlight-cell {
    background: rgba(34, 197, 94, 0.1);
    color: #166534;
    font-weight: 600;
  }
  
  .glass-table .warning-cell {
    background: rgba(245, 158, 11, 0.1);
    color: #92400e;
    font-weight: 600;
  }
  
  .glass-table .error-cell {
    background: rgba(239, 68, 68, 0.1);
    color: #991b1b;
    font-weight: 600;
  }
</style>