/* Telegram-inspired theme tokens */
:root {
  /* Fragment dark theme tokens per STYLEGUIDE.md */
  --tg-bg: rgb(26, 32, 38);         /* Page background */
  --tg-surface: rgb(33, 42, 51);    /* Table/card surface */
  --tg-surface-2: #293440;          /* Header/section/hover surface */
  --tg-text: #8794A1;               /* Base text */
  --tg-text-secondary: #8C9AA9;     /* Secondary text */
  --tg-border: #212A33;             /* Subtle borders */
  --tg-accent: #4DB2FF;             /* Accent */
  --tg-hover: #293440;              /* Row/menu hover */
  --tg-radius: 8px;                 /* Default radius */
  --tg-shadow: none;                /* No drop shadows */
  /* Header (translucent) */
  --header-bg-rgb: 33, 42, 51;
  --header-bg-color: rgba(33, 42, 51, 0.9);
  --header-divider: #293440;
  /* Footer */
  --footer-bg: #111417;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Keep same Fragment dark palette in dark mode */
    --tg-bg: #111417;
    --tg-surface: rgb(33, 42, 51);
    --tg-surface-2: #293440;
    --tg-text: #8794A1;
    --tg-text-secondary: #8C9AA9;
    --tg-border: #212A33;
    --tg-accent: #4DB2FF;
    --tg-hover: #293440;
    --tg-shadow: none;
  }
  
  /* Sorting icons in dark mode */
  .gridjs-sort,
  .gridjs-sort-asc,
  .gridjs-sort-desc {
    filter: invert(1) grayscale(1) brightness(2); /* Light gray/white invert */
  }
}

/* Keep styles minimal and modern */
body {
  background-color: var(--footer-bg);
  color: var(--tg-text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Inter, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color-scheme: light dark;
}

/* Sticky footer layout */
html, body {
  height: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1 0 auto;
  background-color: var(--tg-bg);
}

footer {
  flex-shrink: 0;
  background-color: var(--header-bg-color) !important; /* Match header */
  border-top: 1px solid var(--header-divider) !important;
  /* Ensure Bootstrap utilities pick the themed border color */
  --bs-border-color: var(--header-divider);
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}

footer .text-secondary,
footer .small {
  color: #6D8394 !important; /* Footer text */
}

.card {
  border-radius: var(--tg-radius);
  background-color: var(--tg-surface);
  border: 1px solid var(--tg-border);
  box-shadow: none; /* Fragment avoids elevated shadows */
}

.gridjs-container {
  font-size: 0.90rem;
  overflow-x: hidden;
  background-color: var(--tg-surface);
}

.table.table-fixed {
  table-layout: fixed;
}

.table.table-fixed th,
.table.table-fixed td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0.35rem 0.5rem;
  line-height: 1.2;
  vertical-align: middle;
}

.truncate-link {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

/* Navbar and menus */
.navbar {
  background-color: var(--header-bg-color) !important;
  border-bottom: 1px solid var(--header-divider) !important;
}
.navbar .navbar-brand,
.navbar .nav-link {
  color: #ffffff; /* Header text */
}
.navbar .nav-link:hover {
  background-color: var(--tg-hover);
  border-radius: 8px;
  color: #ffffff !important;
}
.dropdown-menu {
  background-color: #2E3A47; /* Dropdown bg */
  border: 1px solid #2E3A47;
}
.dropdown-item {
  color: #ffffff; /* Dropdown item text */
}
.dropdown-item:hover {
  background-color: #384553; /* Dropdown hover */
  color: #ffffff !important;
}

/* Headings per guide */
h1, h2, h3, h4,
.display-6 {
  color: #ffffff;
}

/* Mobile cards: emphasize primary title */
.card-list .service-card .fw-semibold {
  color: #ffffff !important;
}

/* Links */
a { color: var(--tg-accent); }
a:hover { opacity: 0.9; }

/* Table theming (Grid.js + Bootstrap table) */
.gridjs-table,
.table.table-fixed {
  background-color: var(--tg-surface);
  color: var(--tg-text);
}

/* Header section visuals */
.bg-white { background-color: var(--tg-surface-2) !important; }
.border-bottom { border-bottom: 1px solid #293440 !important; }

/* Headline spacing */
.display-6 { 
  margin-top: 2rem;
  margin-bottom: 2rem; 
}

.gridjs-thead .gridjs-th,
.table.table-fixed thead th {
  background-color: var(--tg-surface-2);
  color: var(--tg-text);
}

.gridjs-table td,
.gridjs-table th,
.table.table-fixed td,
.table.table-fixed th {
  border-color: var(--tg-border) !important;
}

/* Force cell backgrounds to follow theme (override Grid.js mermaid theme) */
.gridjs-table td,
.gridjs-table th {
  background-color: var(--tg-surface) !important;
  color: var(--tg-text) !important;
}

.gridjs-thead .gridjs-th {
  background-color: var(--tg-surface-2) !important;
}

/* Bootstrap table CSS variables to ensure dark mode cells */
.table.table-fixed {
  --bs-table-bg: var(--tg-surface);
  --bs-table-color: var(--tg-text);
  --bs-table-hover-bg: var(--tg-hover);
  --bs-border-color: var(--tg-border);
}

.table-hover tbody tr:hover td,
.table-hover tbody tr:hover th,
.gridjs-tr:hover td {
  background-color: var(--tg-hover) !important;
}

/* Row hover: ensure readable colors in dark mode */
.table-hover tbody tr:hover,
.gridjs-tr:hover {
  background-color: var(--tg-hover) !important;
}

.table-hover tbody tr:hover td,
.table-hover tbody tr:hover th,
.gridjs-tr:hover td,
.gridjs-tr:hover th {
  background-color: var(--tg-hover) !important;
  color: var(--tg-text) !important;
}

.table-hover tbody tr:hover .text-secondary,
.gridjs-tr:hover .text-secondary {
  color: var(--tg-text-secondary) !important;
}

.table-hover tbody tr:hover a,
.gridjs-tr:hover a {
  color: var(--tg-accent) !important;
}

/* Mobile card list */
.card-list .service-card .badge {
  font-weight: 500;
}

.card-list .service-card .fw-semibold,
.card-list .service-card .small:not(.text-secondary) {
  color: var(--tg-text) !important;
}

/* Warning text */
.text-warning {
  color: #FFCC00; /* Yellow */
  font-style: italic;
}

/* Desktop column widths aligned with 11-column order */
@media (min-width: 992px) {
  /* 1: Service */
  .table.table-fixed th:nth-child(1),
  .table.table-fixed td:nth-child(1) { width: 12%; }
  /* 2: URL */
  .table.table-fixed th:nth-child(2),
  .table.table-fixed td:nth-child(2) { width: 14%; }
  /* 3: No KYC */
  .table.table-fixed th:nth-child(3),
  .table.table-fixed td:nth-child(3) { width: 5%; }
  /* 4: Stars API */
  .table.table-fixed th:nth-child(4),
  .table.table-fixed td:nth-child(4) { width: 5%; }
  /* 5: Premium API */
  .table.table-fixed th:nth-child(5),
  .table.table-fixed td:nth-child(5) { width: 5%; }
  /* 6: Gift API */
  .table.table-fixed th:nth-child(6),
  .table.table-fixed td:nth-child(6) { width: 5%; }
  /* 7: Username Auctions */
  .table.table-fixed th:nth-child(7),
  .table.table-fixed td:nth-child(7) { width: 7%; }
  /* 8: Fee */
  .table.table-fixed th:nth-child(8),
  .table.table-fixed td:nth-child(8) { width: 5%; }
  /* 9: Git */
  .table.table-fixed th:nth-child(9),
  .table.table-fixed td:nth-child(9) { width: 12%; }
  /* 10: Creator */
  .table.table-fixed th:nth-child(10),
  .table.table-fixed td:nth-child(10) { width: 12%; }
  /* 11: Contact */
  .table.table-fixed th:nth-child(11),
  .table.table-fixed td:nth-child(11) { width: 10%; }
}

/* Keep mobile usable with horizontal scroll if needed */
@media (max-width: 991.98px) {
  .gridjs-container {
    overflow-x: auto;
  }
  .service-card {
    border: 1px solid #293440; /* Lighter border for visibility */
    box-shadow: 0 3px 6px rgba(0,0,0,0.25); /* Reduced shadow */
  }
}

.gridjs-wrapper {
  padding-bottom: 0 !important;
  margin-bottom: 0 !important;
}

.gridjs-th {
  white-space: nowrap;
}

.gridjs-td a {
  text-decoration: none;
}

.gridjs-td a:hover {
  text-decoration: underline;
}

.gridjs-footer {
  display: none;
}

/* Desktop table cell padding for row spacing */
@media (min-width: 992px) {
  .gridjs-td {
    padding: 1rem 1rem !important; /* Increased vertical padding */
    border: 1px solid var(--tg-text-secondary) !important;
  }
}

/* Tooltip styling per STYLEGUIDE */
.tooltip-inner {
  background-color: #2D3C4C;
  color: #FFFFFF;
  border-radius: 4px; /* small radius */
  max-width: 200px;
  padding: 6px 12px;
  font-size: 13px;
}

.bs-tooltip-top .tooltip-arrow::before {
  border-top-color: #2D3C4C;
}

.bs-tooltip-bottom .tooltip-arrow::before {
  border-bottom-color: #2D3C4C;
}

.bs-tooltip-start .tooltip-arrow::before {
  border-left-color: #2D3C4C;
}

.bs-tooltip-end .tooltip-arrow::before {
  border-right-color: #2D3C4C;
}


