/* Enhanced Responsive Tables CSS with Premium Aesthetics */

/* Base table styling */
table {
  border: none;
  border-collapse: collapse;
  margin: 0;
  padding: 0;
  width: 100%;
  table-layout: fixed;
  background: transparent;
}

table caption {
  font-size: 1.5em;
  margin: .5em 0 .75em;
  font-weight: 600;
  color: #2c3e50;
}

table tr {
  background-color: transparent;
  border: none;
  padding: 0;
  transition: all 0.3s ease;
}

table th {
  font-size: .85em;
  letter-spacing: .05em;
  text-transform: uppercase;
  text-align: left;
  font-weight: 600;
  color: #495057;
  background: linear-gradient(135deg, #f8f9fa, #e9ecef);
}

/* Enhanced Responsive Design for Mobile */
@media screen and (max-width: 1024px) {
  table {
    border: 0;
    box-shadow: none;
    background: transparent;
  }

  table caption {
    font-size: 1.4em;
    margin-bottom: 1.5em;
    text-align: center;
    color: #2c3e50;
  }
  
  /* Hide table headers on mobile with smooth transition */
  table thead {
    position: absolute;
    top: -9999px;
    left: -9999px;
    opacity: 0;
    transition: opacity 0.3s ease;
  }
  
  /* Enhanced card styling for each row */
  table tr {
    display: block;
    margin-bottom: 24px;
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
    border-radius: 20px;
    box-shadow: 
      0 10px 40px rgba(0, 0, 0, 0.08),
      0 6px 20px rgba(0, 0, 0, 0.04),
      inset 0 1px 0 rgba(255, 255, 255, 0.9);
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    backdrop-filter: blur(20px);
    opacity: 1;
    transform: translateY(0);
    animation: slideInUp 0.6s ease-out forwards;
  }
  
  /* Staggered animation for multiple cards - applied as enhancement */
  table tr:nth-child(1) { animation-delay: 0.1s; }
  table tr:nth-child(2) { animation-delay: 0.15s; }
  table tr:nth-child(3) { animation-delay: 0.2s; }
  table tr:nth-child(4) { animation-delay: 0.25s; }
  table tr:nth-child(5) { animation-delay: 0.3s; }
  table tr:nth-child(6) { animation-delay: 0.35s; }
  table tr:nth-child(7) { animation-delay: 0.4s; }
  table tr:nth-child(8) { animation-delay: 0.45s; }
  table tr:nth-child(9) { animation-delay: 0.5s; }
  table tr:nth-child(10) { animation-delay: 0.55s; }
  
  /* Enhanced entrance animation - starts from visible state */
  @keyframes slideInUp {
    from {
      opacity: 0.8;
      transform: translateY(20px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  /* Animated gradient border */
  table tr::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(
      90deg,
      #667eea 0%,
      #764ba2 25%, 
      #f093fb 50%, 
      #f5576c 75%, 
      #4facfe 100%
    );
    background-size: 300% 100%;
    animation: gradientShift 4s ease-in-out infinite;
    border-radius: 20px 20px 0 0;
  }
  
  /* Hover effects with advanced transforms */
  table tr:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 
      0 20px 60px rgba(0, 0, 0, 0.15),
      0 10px 30px rgba(0, 0, 0, 0.1),
      inset 0 1px 0 rgba(255, 255, 255, 0.9);
  }
  
  table tr:hover::before {
    animation-duration: 2s;
  }
  
  /* Enhanced cell styling */
  table td {
    display: flex;
    align-items: center;
    text-align: left;
    border: none;
    padding: 16px 0;
    position: relative;
    min-height: 52px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 0;
  }
  
  table td:last-child {
    border-bottom: none;
    margin-bottom: 0;
  }
  
  table td:hover {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.04), rgba(118, 75, 162, 0.04));
    border-radius: 12px;
    margin: 0 -12px;
    padding: 16px 12px;
    transform: translateX(4px);
  }
  
  /* Premium labels with icons and gradients */
  table td::before {
    content: attr(data-label);
    font-weight: 700;
    color: #2c3e50;
    display: inline-flex;
    align-items: center;
    min-width: 150px;
    max-width: 150px;
    text-align: left;
    margin-right: 20px;
    font-size: 13px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    position: relative;
    line-height: 1.2;
  }
  
  /* Enhanced icons for different data types */
  table td[data-label*="Order"]::before,
  table td[data-label*="Product"]::before,
  table td[data-label*="ID"]::before {
    content: "🏷️ " attr(data-label);
  }
  
  table td[data-label*="Customer"]::before,
  table td[data-label*="Name"]::before,
  table td[data-label*="User"]::before,
  table td[data-label*="Author"]::before {
    content: "👤 " attr(data-label);
  }
  
  table td[data-label*="Total"]::before,
  table td[data-label*="Price"]::before,
  table td[data-label*="Amount"]::before,
  table td[data-label*="Fee"]::before {
    content: "💰 " attr(data-label);
  }
  
  table td[data-label*="Date"]::before,
  table td[data-label*="Time"]::before,
  table td[data-label*="Registered"]::before,
  table td[data-label*="Published"]::before {
    content: "📅 " attr(data-label);
  }
  
  table td[data-label*="Status"]::before {
    content: "📊 " attr(data-label);
  }
  
  table td[data-label*="Email"]::before,
  table td[data-label*="Contact"]::before {
    content: "📧 " attr(data-label);
  }
  
  table td[data-label*="Actions"]::before {
    content: "⚡ " attr(data-label);
  }
  
  table td[data-label*="Quantity"]::before,
  table td[data-label*="Qty"]::before,
  table td[data-label*="Stock"]::before {
    content: "📦 " attr(data-label);
  }
  
  table td[data-label*="Location"]::before,
  table td[data-label*="Address"]::before {
    content: "📍 " attr(data-label);
  }
  
  table td[data-label*="Category"]::before,
  table td[data-label*="SKU"]::before {
    content: "🏗️ " attr(data-label);
  }
  
  table td[data-label*="Featured"]::before,
  table td[data-label*="Special"]::before {
    content: "⭐ " attr(data-label);
  }
  
  /* Enhanced content styling */
  table td .content {
    flex: 1;
    font-weight: 500;
    color: #34495e;
    line-height: 1.5;
    font-size: 15px;
  }
  
  /* Premium action buttons */
  table td .btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 8px;
  }
  
  table td .btn {
    font-size: 13px;
    padding: 10px 18px;
    border-radius: 25px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: none;
    position: relative;
    overflow: hidden;
    min-width: auto;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  }
  
  /* Button shine effect */
  table td .btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  }
  
  table td .btn:hover::before {
    left: 100%;
  }
  
  table td .btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
  }
  
  table td .btn:active {
    transform: translateY(-1px) scale(1.02);
  }
  
  /* Enhanced status badges */
  .badge {
    border-radius: 25px;
    padding: 8px 16px;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
  }
  
  .badge::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.3));
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.3s ease;
  }
  
  .badge:hover::before {
    opacity: 1;
  }
  
  /* Enhanced form controls */
  table td .form-control,
  table td .form-select {
    border-radius: 15px;
    border: 2px solid #e9ecef;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-size: 14px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
  }
  
  table td .form-control:focus,
  table td .form-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.15);
    transform: scale(1.02);
    background: rgba(255, 255, 255, 0.95);
  }
  
  /* Animations */
  @keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
  }
  
  @keyframes slideInUp {
    from {
      opacity: 0.8;
      transform: translateY(20px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  @keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
  }
  
  /* Loading skeleton animation */
  .table-loading {
    animation: pulse 1.5s ease-in-out infinite;
  }
  
  /* Optional progressive enhancement class for JS-controlled animations */
  .table-animate-in tr {
    opacity: 0;
    transform: translateY(30px);
  }
  
  .table-animate-in.loaded tr {
    opacity: 1;
    transform: translateY(0);
    animation: slideInUp 0.6s ease-out forwards;
  }
}

/* Enhanced styling for very small screens */
@media screen and (max-width: 480px) {
  table tr {
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 16px;
  }
  
  table td {
    padding: 12px 0;
    font-size: 14px;
  }
  
  table td::before {
    font-size: 12px;
    min-width: 130px;
    max-width: 130px;
    margin-right: 16px;
  }
  
  table td .btn {
    font-size: 12px;
    padding: 8px 14px;
  }
  
  table td .btn-group {
    gap: 8px;
  }
  
  .badge {
    font-size: 11px;
    padding: 6px 12px;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  @media screen and (max-width: 1024px) {
    table tr {
      background: linear-gradient(145deg, #2c3e50, #34495e);
      color: #ecf0f1;
    }
    
    table td {
      color: #ecf0f1;
    }
    
    table td::before {
      background: linear-gradient(135deg, #3498db 0%, #9b59b6 100%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
    }
    
    table td:hover {
      background: linear-gradient(90deg, rgba(52, 152, 219, 0.1), rgba(155, 89, 182, 0.1));
    }
  }
}

/* Print styles */
@media print {
  @media screen and (max-width: 1024px) {
    table tr {
      box-shadow: none;
      background: white;
    }
    
    table tr::before {
      display: none;
    }
  }
}
