/* =============================================================
   GIS Catalog – Public Styles
   CSS custom properties are set inline by PHP from Settings.
   ============================================================= */

/* ── Variables (defaults – overridden by inline <style> from settings) ── */
.gisc-wrap {
  --gisc-font-family:    inherit;
  --gisc-font-size:      13px;
  --gisc-header-bg:      #1d2327;
  --gisc-header-color:   #ffffff;
  --gisc-accent:         #0073aa;
  --gisc-accent-hover:   #005a87;
  --gisc-row-hover:      #f7f9fc;
  --gisc-border-color:   #dee2e6;
  --gisc-note-color:     #555555;
  --gisc-btn-radius:     4px;
  --gisc-btn-padding:    5px 13px;

  font-family:  var(--gisc-font-family);
  font-size:    var(--gisc-font-size);
  /* prevent the table from bleeding outside the page column */
  width:        100%;
  max-width:    100%;
  overflow-x:   auto;
  box-sizing:   border-box;
}

/* ── Filters bar ─────────────────────────────────────────────── */
.gisc-filters {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 14px; padding: 10px 14px;
  background: #f8f9fa; border: 1px solid var(--gisc-border-color); border-radius: 5px;
}
.gisc-filters select {
  padding: 5px 9px; border: 1px solid var(--gisc-border-color); border-radius: 4px;
  font-size: var(--gisc-font-size); background: #fff; cursor: pointer; min-width: 140px;
}
.gisc-filters select:focus { outline: 2px solid var(--gisc-accent); border-color: var(--gisc-accent); }
.gisc-stats { margin-left: auto; font-size: 13px; color: #666; white-space: nowrap; }

/* ── Loading ─────────────────────────────────────────────────── */
.gisc-loading { text-align: center; padding: 40px; color: #666; font-style: italic; }
.gisc-loading::before { content: '⏳ '; }

/* ── Wrapper ensures no overflow into sidebars ───────────────── */
.dataTables_wrapper {
  width: 100% !important;
  overflow-x: auto;
}

/* ── Table ───────────────────────────────────────────────────── */
.gisc-table {
  width: 100% !important;
  max-width: 100vw;
  border-collapse: collapse;
  font-size: var(--gisc-font-size);
  font-family: var(--gisc-font-family);
  table-layout: fixed !important;
}

.gisc-table thead th {
  background: var(--gisc-header-bg);
  color: var(--gisc-header-color);
  padding: 9px 11px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  border: none;
}
.gisc-table tbody tr { border-bottom: 1px solid #e0e0e0; }
.gisc-table tbody tr:hover { background: var(--gisc-row-hover); }
.gisc-table tbody tr.gisc-row--broken { background: #fff8f8; }
.gisc-table tbody tr.gisc-row--broken:hover { background: #ffeeed; }
.gisc-table td {
  padding: 8px 11px;
  vertical-align: top;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
}

.gisc-download-meta {
  margin-top: 6px;
  font-size: 12px;
  color: #444;
}

/* fixed widths */
.gisc-table th.gisc-col-source   { width: 10% !important; min-width: 60px; }
.gisc-table th.gisc-col-name     { width: 40% !important; min-width: 180px; }
.gisc-table th.gisc-col-note     { width: 15% !important; min-width: 80px; }
.gisc-table th.gisc-col-format   { width: 10% !important; min-width: 60px; }
.gisc-table th.gisc-col-download { width: 15% !important; min-width: 100px; }
.gisc-table th.gisc-col-status   { width: 10% !important; min-width: 70px; }
.gisc-table th.gisc-col-year     { width: 8% !important; min-width: 40px; }

/* ── Source text (no longer a badge) ────────────────────────── */
.gisc-source-text {
  font-size: calc(var(--gisc-font-size) - 1px);
  font-weight: 600;
  color: #333;
  display: block;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ── Note text ───────────────────────────────────────────────── */
.gisc-note {
  font-size: calc(var(--gisc-font-size) - 1px);
  color: var(--gisc-note-color);
  margin-top: 3px;
  line-height: 1.45;
}

/* ── Format pills ────────────────────────────────────────────── */
.gisc-format-pills { display: flex; flex-wrap: wrap; gap: 3px; }
.gisc-format-pill {
  display: inline-block; padding: 1px 6px; border-radius: 10px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
  background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9;
}
.gisc-format-pill--kml      { background:#fff3e0; color:#e65100; border-color:#ffe0b2; }
.gisc-format-pill--kmz      { background:#fff3e0; color:#e65100; border-color:#ffe0b2; }
.gisc-format-pill--geojson  { background:#e3f2fd; color:#0d47a1; border-color:#bbdefb; }
.gisc-format-pill--csv      { background:#f3e5f5; color:#6a1b9a; border-color:#e1bee7; }
.gisc-format-pill--wms      { background:#e0f7fa; color:#006064; border-color:#b2ebf2; }
.gisc-format-pill--wfs      { background:#e0f7fa; color:#006064; border-color:#b2ebf2; }
.gisc-format-pill--pdf      { background:#fce4ec; color:#880e4f; border-color:#f8bbd0; }
.gisc-format-pill--geodatabase { background:#ede7f6; color:#4527a0; border-color:#d1c4e9; }
.gisc-format-pill--raster   { background:#fafafa; color:#424242; border-color:#bdbdbd; }
.gisc-format-pill--tiff     { background:#fafafa; color:#424242; border-color:#bdbdbd; }
.gisc-format-pill--geopackage { background:#e8eaf6; color:#283593; border-color:#c5cae9; }

/* ── Download button ─────────────────────────────────────────── */
.gisc-dl-btn {
  display: inline-block;
  padding: var(--gisc-btn-padding);
  border-radius: var(--gisc-btn-radius);
  background: #e7f3ff;
  color: #0d47a1 !important;
  text-decoration: none !important;
  border: 1px solid #90caf9;
  font-size: calc(var(--gisc-font-size) - 1px);
  font-weight: 600; white-space: nowrap;
  transition: background .15s, border-color .15s;
  cursor: pointer;
}
.gisc-dl-btn:hover { background: #d0e7ff; text-decoration: underline !important; }
.gisc-dl-btn--ok { background: #e7f3ff; color: #0d47a1 !important; border-color: #90caf9; }
.gisc-dl-btn--broken {
  background: #ffebe7;
  color: #b71c1c !important;
  border-color: #ef9a9a;
  cursor: pointer;
}
.gisc-dl-btn--broken:hover { background: #ffe0e0; text-decoration: underline !important; }
/* "Acessar" style link – no button fill */
.gisc-dl-link {
  color: var(--gisc-accent) !important;
  text-decoration: none !important;
  font-size: calc(var(--gisc-font-size) - 1px);
  font-weight: 600;
}
.gisc-dl-link:hover { text-decoration: underline !important; }

/* ── Status badges ───────────────────────────────────────────── */
.gisc-status { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; white-space: nowrap; }
.gisc-status--ok            { color: #1a8a3a; }
.gisc-status--broken        { color: #c0392b; }
.gisc-status--redirect      { color: #856404; }
.gisc-status--unchecked     { color: #666; }
.gisc-status--auth_required { color: #0c5460; }

/* ── Footer note ─────────────────────────────────────────────── */
.gisc-footer-note { font-size: 12px; color: #888; margin-top: 12px; }
.gisc-footer-legend { font-size: 12px; color: #666; margin-top: 4px; }
/* ── DataTables overrides ────────────────────────────────────── */
.dataTables_wrapper .dataTables_filter label { font-size: var(--gisc-font-size); }
.dataTables_wrapper .dataTables_filter input {
  border: 1px solid var(--gisc-border-color); border-radius: 4px; padding: 4px 9px;
  font-size: var(--gisc-font-size);
}
.dataTables_wrapper .dataTables_length label { font-size: var(--gisc-font-size); }
.dataTables_wrapper .dataTables_info  { font-size: 13px; color: #666; }
.dataTables_wrapper .dataTables_paginate .paginate_button { border-radius: 4px !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--gisc-accent) !important;
  color: #fff !important;
  border-color: var(--gisc-accent) !important;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .gisc-filters { flex-direction: column; align-items: stretch; }
  .gisc-filters select { min-width: 0; width: 100%; }

  /* Table hidden on mobile; cards shown */
  .gisc-table { display: none !important; }
  .gisc-cards { display: block; }

  .gisc-cards { margin: 0; padding: 0; }
  .gisc-card {
    border: 1px solid #e6e6e6;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 12px;
    background: #fff;
    box-shadow: 0 1px 0 rgba(0,0,0,0.02);
  }

  .gisc-card-row { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 6px; }
  .gisc-card-label { flex: 0 0 36%; font-weight: 600; color: #555; }
  .gisc-card-value { flex: 1 1 64%; }

  .gisc-card .gisc-note { margin-top: 4px; }

  /* Make sure interactive elements are readable */
  .gisc-card .gisc-dl-btn { display: inline-block; margin-top: 4px; }

  /* Reduce font-size slightly on very small screens */
  @media (max-width: 420px) {
    .gisc-card-row { gap: 6px; }
    .gisc-card-label { flex-basis: 40%; font-size: 13px; }
    .gisc-card-value { font-size: 13px; }
  }
}

/* Force wrap and prevent overlap in all table cells and headers */
.gisc-table td, .gisc-table th {
  word-break: break-word !important;
  overflow-wrap: anywhere !important;
  white-space: normal !important;
}
.gisc-table strong {
  white-space: normal !important;
  word-break: break-word !important;
}

/* Stronger override for the source column to ensure wrapping */
.gisc-table td .gisc-source-text,
.gisc-table td .gisc-source-text *,
.gisc-table td:first-child .gisc-source-text {
  display: block !important;
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  max-width: 100% !important;
}
