/*
 * enterprise_ui.css — Application-wide design standards
 * Tables, badges, avatars, and mobile card layout.
 * Add class "et-table" to any <table> to opt in.
 * Responsive mobile cards are automatic — no extra markup needed
 * (enterprise_ui.js stamps data-label from thead on every draw).
 */

/* ═══════════════════════════════════════════════════════════════
   1. Design Tokens
   ═══════════════════════════════════════════════════════════════ */
:root {
  --et-primary:      #1a56db;
  --et-th-bg:        #1e3a5f;
  --et-th-color:     #ffffff;
  --et-th-fs:        .72rem;
  --et-th-fw:        700;
  --et-td-fs:        .82rem;
  --et-cell-py:      .55rem;
  --et-cell-px:      .75rem;
  --et-row-hover:    #f0f5ff;
  --et-border:       #e9ecef;
  --et-shadow:       0 1px 6px rgba(0,0,0,.07);
  --et-radius:       .45rem;
}

/* ═══════════════════════════════════════════════════════════════
   2. Enterprise Table — Desktop
   ═══════════════════════════════════════════════════════════════ */
table.et-table {
  width: 100%;
  font-family: inherit;
}

/* Header: override Bootstrap bg-primary / table-dark from existing templates */
table.et-table thead,
table.et-table thead tr {
  background-color: var(--et-th-bg) !important;
  color: var(--et-th-color) !important;
}

table.et-table thead th {
  background-color: var(--et-th-bg) !important;
  color: var(--et-th-color) !important;
  font-size: var(--et-th-fs);
  font-weight: var(--et-th-fw);
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
  padding: var(--et-cell-py) var(--et-cell-px);
  vertical-align: middle;
  border: none !important;
}
table.et-table thead th i,
table.et-table thead th .bi { opacity: .8; }

/* Body cells */
table.et-table tbody td {
  font-size: var(--et-td-fs);
  padding: var(--et-cell-py) var(--et-cell-px);
  vertical-align: middle;
  border-color: var(--et-border);
  color: #2d3748;
}

table.et-table tbody tr {
  transition: background-color .1s;
}
table.et-table tbody tr:hover > td {
  background-color: var(--et-row-hover) !important;
}

/* Serial # column */
table.et-table tbody td.et-serial {
  font-size: .72rem !important;
  font-weight: 700;
  color: #9aa5b4 !important;
  text-align: center;
}

/* Actions column */
table.et-table tbody td.et-actions {
  text-align: center;
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════
   3. Standardised Status Badges
   ═══════════════════════════════════════════════════════════════ */
.et-badge {
  display: inline-flex;
  align-items: center;
  gap: .22rem;
  font-size: .68rem;
  font-weight: 700;
  padding: .22rem .55rem;
  border-radius: .35rem;
  white-space: nowrap;
  letter-spacing: .02em;
  vertical-align: middle;
  line-height: 1.4;
}
.et-badge-success  { background: #d1fae5; color: #065f46; }
.et-badge-danger   { background: #fee2e2; color: #991b1b; }
.et-badge-warning  { background: #fef9c3; color: #854d0e; }
.et-badge-info     { background: #dbeafe; color: #1e40af; }
.et-badge-purple   { background: #ede9fe; color: #5b21b6; }
.et-badge-orange   { background: #ffedd5; color: #9a3412; }
.et-badge-teal     { background: #ccfbf1; color: #0f766e; }
.et-badge-gray     { background: #f1f5f9; color: #475569; }

/* ═══════════════════════════════════════════════════════════════
   4. Avatars / Thumbnails
   ═══════════════════════════════════════════════════════════════ */
.et-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  font-size: .72rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  overflow: hidden; vertical-align: middle;
}
.et-avatar img   { width: 100%; height: 100%; object-fit: cover; }
.et-avatar-sq    { border-radius: .4rem; }
.et-avatar-sm    { width: 24px; height: 24px; font-size: .62rem; }
.et-avatar-lg    { width: 44px; height: 44px; font-size: .9rem; }

/* ═══════════════════════════════════════════════════════════════
   5. Action Buttons (icon-only, 28 × 28)
   ═══════════════════════════════════════════════════════════════ */
.et-action-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: .4rem;
  font-size: .78rem;
  border: 1px solid transparent;
  transition: background-color .15s, color .15s;
  cursor: pointer; text-decoration: none; vertical-align: middle; padding: 0;
}

/* ═══════════════════════════════════════════════════════════════
   6. DataTables — Consistent Controls
   ═══════════════════════════════════════════════════════════════ */
.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label {
  font-size: .82rem;
  color: #6c757d;
}
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
  font-size: .82rem;
  border-radius: .35rem;
  border-color: #dee2e6;
}
.dataTables_wrapper .dataTables_info {
  font-size: .78rem;
  color: #6c757d;
  padding-top: .35rem;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
  border-radius: .35rem !important;
  font-size: .78rem !important;
  padding: .3rem .65rem !important;
  line-height: 1.4 !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background: var(--et-primary) !important;
  border-color: var(--et-primary) !important;
  color: #fff !important;
  font-weight: 600 !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover:not(.current):not(.disabled) {
  background: #f0f5ff !important;
  border-color: #dee2e6 !important;
  color: var(--et-primary) !important;
}

/* ═══════════════════════════════════════════════════════════════
   7. Mobile Card Layout  (max-width: 767.98 px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 767.98px) {

  /* Remove horizontal scroll — cards overflow vertically */
  .table-responsive {
    overflow-x: visible !important;
    border: none !important;
  }

  /* Block-level reflow for table, tbody, tr */
  table.et-table,
  table.et-table tbody,
  table.et-table tbody tr {
    display: block;
    width: 100%;
  }

  /* Hide desktop header row */
  table.et-table thead { display: none !important; }

  /* Each <tr> becomes a card */
  table.et-table tbody tr {
    margin-bottom: .75rem;
    border: 1px solid var(--et-border);
    border-radius: var(--et-radius);
    overflow: hidden;
    box-shadow: var(--et-shadow);
    background: #fff;
  }

  /* Kill row hover on mobile */
  table.et-table tbody tr:hover > td { background: inherit !important; }

  /* Each <td> = a label-value row */
  table.et-table tbody td {
    display: flex !important;
    justify-content: space-between;
    align-items: flex-start;
    gap: .5rem;
    padding: .45rem .9rem;
    border-top: 1px solid #f0f4f8;
    border-left: none; border-right: none; border-bottom: none;
    min-height: 38px;
    font-size: .83rem;
  }

  /* ::before = field label from data-label attribute (stamped by enterprise_ui.js) */
  table.et-table tbody td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: .64rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #6c757d;
    flex: 0 0 38%;
    max-width: 38%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-top: .05rem;
    flex-shrink: 0;
  }

  /* Serial # — hidden on mobile */
  table.et-table tbody td.et-serial { display: none !important; }

  /* First visible td = card header bar */
  table.et-table tbody tr > td:not(.et-serial):first-of-type {
    background: linear-gradient(135deg, #eef4ff 0%, #f8faff 100%);
    border-top: none;
    border-bottom: 2px solid #d4e3f7;
    font-weight: 600;
    font-size: .87rem;
    align-items: center;
    padding: .55rem .9rem;
  }
  table.et-table tbody tr > td:not(.et-serial):first-of-type::before {
    display: none;
  }

  /* Actions column — right-aligned footer of each card */
  table.et-table tbody td.et-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: .4rem;
    padding: .5rem .9rem;
    background: #f8faff;
    border-top: 2px solid #e0e9f5;
    align-items: center;
  }
  table.et-table tbody td.et-actions::before { display: none !important; }

  /* DataTables controls on mobile */
  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter {
    float: none !important;
    text-align: left !important;
    margin-bottom: .5rem;
    width: 100% !important;
  }
  .dataTables_wrapper .dataTables_filter input {
    width: 100% !important;
    display: block !important;
  }
  .dataTables_wrapper .dataTables_info,
  .dataTables_wrapper .dataTables_paginate {
    float: none !important;
    text-align: center !important;
    margin-top: .35rem;
  }
  .dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: .28rem .5rem !important;
    font-size: .74rem !important;
    margin: 1px !important;
  }
}
