/* Global minimalistic enterprise table styles
   - Applied broadly to all tables and form controls inside tables
   - Minimal color palette, subtle borders, better spacing and typography
   - Does NOT change any IDs or class names; only visual styles
*/

:root {
  /* User-provided design tokens */
  --color-primary: #72308F;
  /* Tetherfi Purple / Eminence */
  --color-bg: #FFFFFF;
  --color-text: #1A1A1A;
  --color-text-secondary: #6B7280;
  --color-border: #E5E7EB;
  --color-accent-light: #BFA4D9;
  --color-accent-dark: #4B226A;
  --color-success: #10B981;
  --color-warning: #F59E0B;
  --color-danger: #EF4444;

  /* Backwards-compatible table variables mapped to tokens */
  --tbl-border: var(--color-border);
  --tbl-bg-muted: #F8F7FA;
  /* subtle neutral (keeps minimal look) */
  --tbl-head-bg: rgba(191, 164, 217, 0.16);
  /* light tint of accent */
  --tbl-text: var(--color-text);
  --tbl-muted-text: var(--color-text-secondary);
  --input-border: #E9E6EA;
}

/* Make containers with tables handle overflow on narrow screens */
.po-entry-container,
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

/* Base table reset */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  color: var(--tbl-text);
  background: transparent;
  table-layout: auto;
}

body table {
  width: max-content !important;
  min-width: 100% !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
  font-size: 13px !important;
  color: var(--tbl-text) !important;
  background: transparent !important;
  table-layout: auto !important;
}

/* Header */
table thead th {
  text-align: left;
  font-weight: 600;
  padding: 10px 12px;
  background: var(--tbl-head-bg);
  border-bottom: 1px solid var(--tbl-border);
  color: var(--tbl-text);
  letter-spacing: 0.2px;
}

body table thead th {
  text-align: left !important;
  font-weight: 600 !important;
  padding: 10px 12px !important;
  background: var(--tbl-head-bg) !important;
  border-bottom: 1px solid var(--tbl-border) !important;
  color: var(--tbl-text) !important;
  letter-spacing: 0.2px !important;
  white-space: nowrap !important;
}

/* Body cells */
table tbody td {
  padding: 10px 12px;
  vertical-align: middle;
  border-bottom: 1px solid #efedf0;
  background: #ffffff;
}

body table tbody td {
  padding: 10px 12px !important;
  vertical-align: middle !important;
  border-bottom: 1px solid #efedf0 !important;
  background: #ffffff !important;
}

/* Subtle row hover for readability */
table tbody tr:hover td {
  background: var(--tbl-bg-muted);
}

body table tbody tr:hover td {
  background: var(--tbl-bg-muted) !important;
}

/* Make the first row's left cells slightly rounded when table has a visible border */
table thead th:first-child {
  border-top-left-radius: 8px;
}

table thead th:last-child {
  border-top-right-radius: 8px;
}

table tbody tr:last-child td:first-child {
  border-bottom-left-radius: 6px;
}

table tbody tr:last-child td:last-child {
  border-bottom-right-radius: 6px;
}

body table thead th:first-child {
  border-top-left-radius: 8px !important;
}

body table thead th:last-child {
  border-top-right-radius: 8px !important;
}

body table tbody tr:last-child td:first-child {
  border-bottom-left-radius: 6px !important;
}

body table tbody tr:last-child td:last-child {
  border-bottom-right-radius: 6px !important;
}

/* Inputs, selects and textareas inside tables — neutral, compact styling */
table input,
table select,
table textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  background: transparent;
  font-size: 13px;
  color: var(--tbl-text);
  outline: none;
}

body table input,
body table select,
body table textarea {
  width: 100% !important;
  box-sizing: border-box !important;
  padding: 6px 8px !important;
  border: 1px solid var(--input-border) !important;
  border-radius: 6px !important;
  background: transparent !important;
  font-size: 13px !important;
  color: var(--tbl-text) !important;
  outline: none !important;
}

table textarea {
  min-height: 40px;
  resize: vertical;
}

table input[type="date"],
table input[type="month"] {
  padding: 6px 8px;
}

body table textarea {
  min-height: 40px !important;
  resize: vertical !important;
}

body table input[type="date"],
body table input[type="month"] {
  padding: 6px 8px !important;
}

/* Readonly/disabled look for computed fields */
table input[readonly],
table input[disabled],
table textarea[readonly],
table select[disabled] {
  background: #f8f7f8;
  color: var(--tbl-muted-text);
  border-color: #efedf0;
}

body table input[readonly],
body table input[disabled],
body table textarea[readonly],
body table select[disabled] {
  background: transparent !important;
  color: var(--tbl-muted-text) !important;
  border-color: transparent !important;
}

/* Action buttons (icon-btn) — minimal, clear affordance */
.icon-btn,
.add-row-btn,
.delete-row-btn {
  background: transparent;
  border: 1px solid transparent;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.icon-btn,
.add-row-btn,
.delete-row-btn {
  background: transparent !important;
  border: 1px solid transparent !important;
  padding: 6px 8px !important;
  border-radius: 6px !important;
  cursor: pointer !important;
  font-size: 16px !important;
  line-height: 1 !important;
  color: var(--color-primary) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-width: 34px !important;
  height: 34px !important;
}

.icon-btn:hover,
.add-row-btn:hover,
.delete-row-btn:hover {
  background: #f3f3f4;
  border-color: var(--tbl-border);
}

.icon-btn:hover,
.add-row-btn:hover,
.delete-row-btn:hover {
  background: #f3f3f4 !important;
  border-color: var(--tbl-border) !important;
  color: var(--color-accent-dark) !important;
}

/* Make action column content centered and compact */
table td.text-center {
  text-align: center;
  min-width: 90px;
}

/* Small screens: reduce padding slightly */
@media (max-width: 640px) {

  table thead th,
  table tbody td {
    padding: 8px 10px;
  }

  .icon-btn,
  .add-row-btn,
  .delete-row-btn {
    padding: 4px 6px;
  }
}

/* Utility: subtle shadow and border on table containers for enterprise feel */
.po-entry-container table,
.table-card {
  border: 1px solid var(--tbl-border);
  border-radius: 8px;
  overflow: visible;
}

/* Keep form controls visually consistent in other places too */
input,
select,
textarea {
  font-family: inherit;
}

/* Compatibility: absorb common page-specific table rules into global file
   These rules replicate the neutral, minimal look many pages used inline.
*/
/* Scroll container used across pages */
.overflow-x-auto {
  border-radius: 16px !important;
  overflow-x: auto !important;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

.overflow-x-auto::-webkit-scrollbar {
  display: none !important;
}

/* Neutral table card appearance used by multiple pages */
body table {
  background: #ffffff !important;
  border: 1px solid var(--tbl-border) !important;
  border-radius: 12px !important;
  overflow: visible !important;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .04) !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
}

/* Borders for cells */
body table thead th,
body table tbody td {
  border: 1px solid #efedf0 !important;
}

/* Header look (neutral) */
body table thead th {
  background: var(--tbl-head-bg) !important;
  color: var(--tbl-text) !important;
  font-weight: 700 !important;
  font-size: 12px !important;
  letter-spacing: 0.05em !important;
  text-transform: uppercase !important;
  padding: 8px 14px !important;
  height: 40px !important;
  line-height: 1.2 !important;
  position: relative !important;
}

/* Enforce uniform header background/text across all tables (overrides utility classes) */
body table thead,
body table thead tr,
body table thead th,
body table thead th * {
  background: var(--color-primary) !important;
  color: #ffffff !important;
  font-weight: 700 !important;
}

/* 🧊 STICKY HEADERS: Keep headers visible when scrolling 🧊 */
body table thead th,
.ac-table th {
  position: sticky !important;
  top: 0 !important;
  z-index: 20 !important;
  /* Ensure background is solid so rows don't show through */
  background: var(--color-primary) !important;
  /* Add a subtle shadow at the bottom for a "floating" effect */
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1) !important;
}

/* For Access Control specific table - Updated to PRIMARY PURPLE with white text */
.ac-table thead th {
  position: sticky !important;
  top: 0 !important;
  z-index: 20 !important;
  background: var(--color-primary) !important;
  color: #ffffff !important;
  text-transform: uppercase !important;
  font-size: 11px !important;
  letter-spacing: 0.1em !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
}

body table thead th::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 0;
  height: 1px;
  background: rgba(0, 0, 0, 0.04) !important;
}

/* Body cells */
body table tbody td {
  background: #ffffff !important;
  color: var(--tbl-text) !important;
  font-size: 13.5px !important;
  padding: 8px 14px !important;
  height: 40px !important;
  line-height: 1.3 !important;
  vertical-align: middle !important;
}

/* Hover and inset indicator */
body table tbody tr:hover td {
  background: var(--tbl-bg-muted) !important;
  transition: background .18s ease !important;
}

body table tbody tr:hover {
  box-shadow: inset 3px 0 0 rgba(0, 0, 0, 0.02) !important;
}

/* Clean edges used by pages */
body table tr td:first-child,
body table tr th:first-child {
  border-left: none !important;
}

body table thead tr th {
  border-top: none !important;
}

body table tbody tr:last-child td {
  border-bottom: none !important;
}

/* ===== STANDARDIZE BLUE BUTTONS ===== */
/* Ensure all blue buttons have consistent height - no scaling/transform issues */
button[class*="bg-blue"] {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  height: 44px !important;
  line-height: 1 !important;
  transition: background-color 0.2s ease !important;
  transform: none !important;
}

button[class*="bg-blue"]:hover {
  transform: none !important;
}

/* Normalize .tab-btn specifically */
.tab-btn {
  transform: none !important;
}

.tab-btn:hover {
  transform: none !important;
}