/* 
  Mobile Table Redesign - Premium Card-based UI
  Transforms standard responsive tables into beautiful, high-end mobile cards.
*/

@media (max-width: 640px) {
  /* Reset table structure */
  .responsive-table table,
  .responsive-table thead,
  .responsive-table tbody,
  .responsive-table th,
  .responsive-table td,
  .responsive-table tr {
    display: block !important;
    width: 100% !important;
  }

  /* Hide original table headers */
  .responsive-table thead {
    display: none !important;
  }

  /* Each row becomes a premium card */
  .responsive-table tr {
    background: #ffffff !important;
    border-radius: 1.25rem !important;
    padding: 1.25rem !important;
    margin-bottom: 1.25rem !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03) !important;
    border: 1px solid #f0f0f0 !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
  }

  .dark .responsive-table tr {
    background: #1f2937 !important;
    border-color: #374151 !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2) !important;
  }

  /* Card Header Style (First Column) */
  .responsive-table td:first-child {
    font-size: 1.125rem !important;
    font-weight: 800 !important;
    color: #111827 !important;
    padding: 0 0 1rem 0 !important;
    margin-bottom: 0.75rem !important;
    border-bottom: 1.5px solid #f3f4f6 !important;
    grid-template-columns: 1fr !important; /* No label split for header */
    display: block !important;
  }

  .dark .responsive-table td:first-child {
    color: #f9fafb !important;
    border-bottom-color: #374151 !important;
  }

  /* Details Columns (Label + Value) */
  .responsive-table td:not(:first-child):not(:last-child) {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 0.625rem 0 !important;
    border: none !important;
    font-size: 0.875rem !important;
    gap: 1rem;
  }

  /* Labels from data-label attribute */
  .responsive-table td:not(:first-child):not(:last-child)::before {
    content: attr(data-label);
    font-size: 0.6875rem !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    color: #9ca3af !important; /* gray-400 */
    flex-shrink: 0;
  }

  .dark .responsive-table td:not(:first-child):not(:last-child)::before {
    color: #6b7280 !important; /* gray-500 */
  }

  /* Value styling */
  .responsive-table td span.font-medium,
  .responsive-table td div.font-medium {
    font-weight: 700 !important;
    color: #374151 !important;
  }

  .dark .responsive-table td span.font-medium,
  .dark .responsive-table td div.font-medium {
    color: #d1d5db !important;
  }

  /* Action Buttons Column (Last Column) */
  .responsive-table td:last-child {
    margin-top: 1rem !important;
    padding-top: 1rem !important;
    border-top: 1.5px dashed #e5e7eb !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 0.75rem !important;
  }

  .dark .responsive-table td:last-child {
    border-top-color: #374151 !important;
  }

  /* Make action buttons look like real buttons on mobile */
  .responsive-table td:last-child .flex,
  .responsive-table td:last-child div {
    display: flex !important;
    width: 100% !important;
    justify-content: space-around !important;
    gap: 0.5rem !important;
  }

  .responsive-table td:last-child button {
    flex: 1;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0.75rem 0.5rem !important;
    background: #f9fafb !important;
    border-radius: 0.75rem !important;
    font-size: 0.625rem !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    color: #4b5563 !important;
    gap: 0.375rem !important;
    border: 1px solid #f3f4f6 !important;
    min-width: 0 !important;
  }

  .dark .responsive-table td:last-child button {
    background: #374151 !important;
    border-color: #4b5563 !important;
    color: #d1d5db !important;
  }

  /* Specific Button Colors & Labels */
  .responsive-table td:last-child button i {
    font-size: 1.125rem !important;
  }

  .responsive-table td:last-child button.view-btn { color: #10b981 !important; }
  .responsive-table td:last-child button.view-btn::after { content: 'View'; }
  
  .responsive-table td:last-child button.edit-btn { color: #4361ee !important; }
  .responsive-table td:last-child button.edit-btn::after { content: 'Edit'; }
  
  .responsive-table td:last-child button.history-btn { color: #f59e0b !important; }
  .responsive-table td:last-child button.history-btn::after { content: 'History'; }
  
  .responsive-table td:last-child button.delete-btn { color: #ef4444 !important; }
  .responsive-table td:last-child button.delete-btn::after { content: 'Delete'; }

  /* Ensure text doesn't overflow */
  .responsive-table td {
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
