/* ===== UI ENHANCEMENTS v2.0 (Nexus Premium) =====
   Supplemental styles that extend the main design system.
   Compatible with both light and dark modes.
   ================================================= */

/* ===== CARD VARIANTS ===== */

/* Card with accent top border */
.card-accent-blue  { border-top: 2px solid var(--brand-blue); }
.card-accent-green { border-top: 2px solid var(--brand-green); }
.card-accent-red   { border-top: 2px solid var(--brand-red); }
.card-accent-orange{ border-top: 2px solid var(--brand-orange); }

/* Glass card variant */
.card-glass {
  background: rgba(255, 255, 255, 0.62);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.5);
}

[data-theme="dark"] .card-glass {
  background: rgba(28, 28, 30, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Hoverable card with lift */
.card-lift {
  transition: transform var(--t-normal), box-shadow var(--t-normal);
}

.card-lift:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

/* Flat card (borderless) */
.card-flat {
  background: var(--bg-surface-2);
  border: none;
  box-shadow: none;
}

/* ===== ENHANCED TABLE ===== */
.table-enhanced {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table-enhanced thead tr {
  border-bottom: 1px solid var(--border);
}

.table-enhanced th {
  padding: 9px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg-surface-2);
  white-space: nowrap;
}

.table-enhanced tbody tr {
  border-bottom: 1px solid var(--divider);
  transition: background var(--t-fast);
}

.table-enhanced tbody tr:hover { background: var(--bg-surface-2); }
.table-enhanced tbody tr:last-child { border-bottom: none; }

.table-enhanced td {
  padding: 9px 12px;
  color: var(--text-primary);
  vertical-align: middle;
}

.table-enhanced .td-muted { color: var(--text-secondary); font-size: 12px; }
.table-enhanced .td-mono  { font-family: 'SF Mono', monospace; font-size: 12px; color: var(--text-secondary); }

/* ===== ROW STATUS INDICATORS ===== */
.row-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--r-full);
}

.row-status::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

.row-status.active   { background: rgba(52,199,89,0.12); color: var(--brand-green); }
.row-status.active::before { background: var(--brand-green); }
.row-status.inactive { background: var(--bg-surface-3); color: var(--text-secondary); }
.row-status.inactive::before { background: var(--text-tertiary); }
.row-status.error    { background: rgba(255,59,48,0.12); color: var(--brand-red); }
.row-status.error::before { background: var(--brand-red); }
.row-status.pending  { background: rgba(255,149,0,0.12); color: var(--brand-orange); }
.row-status.pending::before { background: var(--brand-orange); }
.row-status.locked   { background: rgba(88,86,214,0.12); color: var(--brand-indigo); }
.row-status.locked::before  { background: var(--brand-indigo); }

[data-theme="dark"] .row-status.active   { background: rgba(52,199,89,0.18); color: #5AD67D; }
[data-theme="dark"] .row-status.error    { background: rgba(255,59,48,0.18);  color: #FF6961; }
[data-theme="dark"] .row-status.pending  { background: rgba(255,149,0,0.18);  color: #FFB340; }
[data-theme="dark"] .row-status.locked   { background: rgba(88,86,214,0.18);  color: #968EF5; }

/* ===== BUTTON LOADING STATE ===== */
.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn-loading::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 14px; height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: white;
  border-radius: 50%;
  animation: nx-spin 0.7s linear infinite;
}

/* For secondary buttons */
.btn-secondary.btn-loading::after,
.btn-ghost.btn-loading::after {
  border-color: var(--border);
  border-top-color: var(--text-secondary);
}

/* ===== PAGE SECTION ===== */
.page-section {
  margin-bottom: 20px;
}

.page-section:last-child { margin-bottom: 0; }

/* ===== INLINE TOOLBAR ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 12px;
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--divider);
  flex-shrink: 0;
}

.toolbar-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== FILE DROP ZONE ===== */
.drop-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--r-lg);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
  background: var(--bg-surface-2);
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--brand-blue);
  background: rgba(0, 122, 255, 0.04);
}

.drop-zone-icon { font-size: 28px; margin-bottom: 8px; opacity: 0.5; }
.drop-zone-title { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.drop-zone-subtitle { font-size: 12px; color: var(--text-tertiary); }

/* ===== BREADCRUMB ===== */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 14px;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.breadcrumb-item a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--t-fast);
}

.breadcrumb-item a:hover { color: var(--brand-blue); }

.breadcrumb-item.active { color: var(--text-primary); font-weight: 600; }

.breadcrumb-sep { color: var(--text-tertiary); font-size: 11px; }

/* ===== TABS ===== */
.tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg-surface-3);
  border-radius: var(--r-md);
  margin-bottom: 14px;
  width: fit-content;
}

.tab-btn {
  padding: 5px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}

.tab-btn:hover { color: var(--text-primary); }

.tab-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}

/* ===== KEY-VALUE PAIRS (Detail View) ===== */
.kv-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  align-items: start;
}

.kv-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
  padding-top: 1px;
}

.kv-value {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
}

/* ===== COPY BUTTON PATTERN ===== */
.copyable {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.copy-btn {
  font-size: 12px;
  padding: 2px 6px;
  background: var(--bg-surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  color: var(--text-tertiary);
  cursor: pointer;
  font-family: 'SF Mono', monospace;
  transition: all var(--t-fast);
}

.copy-btn:hover {
  background: var(--brand-blue-glow);
  border-color: var(--brand-blue);
  color: var(--brand-blue);
}

/* ===== SYNC/UPLOAD RESULT PANEL ===== */
.result-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.result-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  background: var(--bg-surface-2);
  border-bottom: 1px solid var(--divider);
  font-size: 13px;
  font-weight: 600;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--divider);
  border-bottom: 1px solid var(--border);
}

.result-stat {
  background: var(--bg-surface);
  padding: 10px 14px;
  text-align: center;
}

.result-stat-val {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  line-height: 1;
}

.result-stat-lbl {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  margin-top: 3px;
}

.result-stat.green .result-stat-val { color: var(--brand-green); }
.result-stat.red   .result-stat-val { color: var(--brand-red); }
.result-stat.orange.result-stat-val { color: var(--brand-orange); }

.result-errors {
  padding: 10px 14px;
  max-height: 200px;
  overflow-y: auto;
}

.result-error-row {
  display: flex;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--divider);
  font-size: 12px;
}

.result-error-row:last-child { border-bottom: none; }
.result-error-row-num { color: var(--text-tertiary); font-weight: 600; white-space: nowrap; }
.result-error-row-msg { color: var(--brand-red); }

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-top: 10px;
  justify-content: center;
}

.page-btn {
  width: 30px; height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
}

.page-btn:hover { background: var(--bg-surface-2); color: var(--text-primary); }
.page-btn.active {
  background: var(--brand-blue);
  border-color: var(--brand-blue);
  color: white;
}
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== SEARCH BAR ===== */
.search-bar {
  position: relative;
  flex: 1;
}

.search-bar-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  font-size: 14px;
  pointer-events: none;
}

.search-bar .form-control {
  padding-left: 32px;
}

/* ===== AVATAR  ===== */
.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--brand-blue);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.avatar-sm { width: 22px; height: 22px; font-size: 9px; }
.avatar-lg { width: 40px; height: 40px; font-size: 15px; }

/* ===== COLLAPSE / ACCORDION ===== */
.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  cursor: pointer;
  border-radius: var(--r-md);
  transition: background var(--t-fast);
  user-select: none;
}

.collapsible-header:hover { background: var(--bg-surface-2); }

.collapsible-arrow {
  transition: transform var(--t-fast);
  color: var(--text-tertiary);
  font-size: 12px;
}

.collapsible-header.open .collapsible-arrow {
  transform: rotate(180deg);
}

.collapsible-body {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease, padding 0.3s ease;
  padding: 0 14px;
}

.collapsible-body.open {
  max-height: 1000px;
  padding: 8px 14px 14px;
}

/* ===== ALERTS (inline, compact) ===== */
.alert-compact {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-weight: 500;
}

.alert-compact.error   { background: rgba(255,59,48,0.10); color: var(--brand-red); }
.alert-compact.success { background: rgba(52,199,89,0.10); color: var(--brand-green); }
.alert-compact.info    { background: rgba(0,122,255,0.10); color: var(--brand-blue); }
.alert-compact.warning { background: rgba(255,149,0,0.10); color: var(--brand-orange); }

/* ===== MODAL ENHANCEMENTS ===== */
.modal-backdrop-enhanced {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: nx-fade-in var(--t-fast) both;
}

.modal-enhanced {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  animation: nx-slide-up var(--t-normal) both;
}

/* ===== KEYBOARD SHORTCUT HINTS ===== */
.kbd {
  display: inline-flex;
  padding: 1px 5px;
  background: var(--bg-surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xs);
  border-bottom-width: 2px;
  font-size: 11px;
  font-family: 'SF Mono', monospace;
  color: var(--text-secondary);
  line-height: 1.4;
}
