/* LNCB website
   Color palette derived from acad-icht.tm.edu.ro:
     primary: #0A5794 (deep navy blue)
     accent : #C6D9DB (cool grey-blue)
     light  : #f1f1f1 (near-white background)
     text   : #333
*/

:root {
  --primary: #0A5794;
  --primary-dark: #074069;
  --primary-light: #e7eff5;
  --accent: #C6D9DB;
  --accent-light: #eaf1f2;
  --bg: #f7f7f7;
  --bg-alt: #f1f1f1;
  --surface: #ffffff;
  --border: #d8dde2;
  --text: #2a2a2a;
  --muted: #6a6f76;
  --danger: #b03a2e;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Open Sans", "Roboto Condensed", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { color: var(--primary-dark); margin: 0; font-family: "Roboto Condensed", "Open Sans", sans-serif; font-weight: 700; }

/* ===== Header ===== */
.site-header {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo { height: 56px; width: auto; background: #fff; padding: 4px; border-radius: 4px; }
.logo-iccd { height: 56px; }
.logo-ros { height: 56px; }
.title-block h1 {
  color: #fff;
  font-size: 28px;
  letter-spacing: 1px;
  line-height: 1;
}
.subtitle {
  margin: 4px 0 0;
  color: var(--accent);
  font-size: 13px;
  letter-spacing: .3px;
}
.main-nav { margin-left: auto; display: flex; gap: 18px; flex-wrap: wrap; }
.main-nav a { color: #fff; font-size: 14px; padding: 6px 4px; border-bottom: 2px solid transparent; }
.main-nav a:hover { border-bottom-color: var(--accent); text-decoration: none; }

/* ===== Sections ===== */
.section { padding: 36px 0; }
.section-alt { background: var(--bg-alt); }
.section-inner { max-width: 1400px; margin: 0 auto; padding: 0 24px; }
.section h2 { font-size: 22px; margin-bottom: 16px; }
.muted { color: var(--muted); }

/* ===== Filters ===== */
.filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.filter-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filter { display: flex; flex-direction: column; gap: 4px; min-width: 200px; }
.filter-label { font-size: 12px; font-weight: 600; color: var(--primary-dark); text-transform: uppercase; letter-spacing: .5px; }
.filter input, .filter select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
  width: 100%;
}
.filter input:focus, .filter select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }
.filter-search { flex: 1 1 320px; }

.extra-filters { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.extra-filter {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--accent-light);
  padding: 10px 12px;
  border-radius: 4px;
  position: relative;
  min-width: 200px;
}
.extra-filter .remove {
  position: absolute; top: 4px; right: 6px;
  background: transparent; border: 0; cursor: pointer;
  color: var(--muted); font-size: 14px; line-height: 1;
}
.extra-filter .remove:hover { color: var(--danger); }
.extra-filter .field-row { display: flex; gap: 6px; }
.extra-filter select, .extra-filter input { padding: 6px 8px; font-size: 13px; border: 1px solid var(--border); border-radius: 3px; }

/* ===== Buttons ===== */
.btn {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  padding: 8px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-secondary { background: #fff; color: var(--primary); }
.btn-secondary:hover { background: var(--primary-light); color: var(--primary-dark); }
.btn-ghost { background: transparent; color: var(--primary); border-color: transparent; }
.btn-ghost:hover { background: var(--primary-light); color: var(--primary-dark); }

/* ===== Results bar ===== */
.results-bar { display: flex; align-items: center; gap: 12px; margin: 12px 0; flex-wrap: wrap; }
.results-bar .grow { flex: 1; }
#result-count { color: var(--muted); font-size: 13px; }
.page-size { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.page-size select { padding: 4px 6px; border: 1px solid var(--border); border-radius: 3px; }

/* ===== Table ===== */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
table { border-collapse: collapse; width: 100%; font-size: 13px; }
thead th {
  position: sticky; top: 0;
  background: var(--primary);
  color: #fff;
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
}
tbody td {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  vertical-align: top;
  word-break: break-word;
}
tbody tr:hover { background: var(--accent-light); }
.smiles-cell { font-family: ui-monospace, "Cascadia Code", Consolas, "Courier New", monospace; font-size: 12px; max-width: 280px; overflow-wrap: anywhere; }
.structure-cell { width: 160px; min-width: 160px; }
.structure-cell svg, .structure-cell canvas {
  width: 150px;
  height: 100px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 3px;
  display: block;
}

.type-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.type-tag-drug { background: #dcedc1; color: #2d5016; }
.type-tag-diversity { background: var(--accent); color: var(--primary-dark); }

.detail-link { color: var(--primary); cursor: pointer; background: none; border: 0; font-size: 13px; padding: 0; }
.detail-link:hover { text-decoration: underline; }

/* ===== Pagination ===== */
.pagination { display: flex; justify-content: center; align-items: center; gap: 12px; margin: 16px 0; }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }
#page-indicator { color: var(--muted); font-size: 14px; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-overlay[hidden] { display: none !important; }
.modal {
  background: #fff;
  border-radius: 6px;
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
}
.modal-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal-header h3 { color: var(--primary-dark); font-size: 18px; flex: 1; }
.modal-body { padding: 18px; overflow: auto; }
.modal-body table { font-size: 13px; }
.modal-body td.k { font-weight: 600; color: var(--primary-dark); width: 200px; vertical-align: top; }
.modal-body td.v { word-break: break-word; }
.modal-structure { float: right; margin: 0 0 12px 12px; border: 1px solid var(--border); padding: 6px; background: #fff; border-radius: 4px; }
.modal-structure svg, .modal-structure canvas { width: 280px; height: 200px; }

/* ===== Downloads ===== */
.downloads-list { padding-left: 18px; }
.downloads-list li { margin: 6px 0; }

/* ===== Footer ===== */
.site-footer {
  background: var(--primary-dark);
  color: #d6e1ea;
  padding: 24px 0;
  margin-top: 32px;
  font-size: 13px;
}
.footer-inner { max-width: 1400px; margin: 0 auto; padding: 0 24px; display: flex; gap: 32px; flex-wrap: wrap; }
.footer-col { flex: 1 1 240px; }
.footer-col a { color: var(--accent); }
.footer-col a:hover { color: #fff; }
.footer-acad { text-align: right; }
.footer-acad img { height: 60px; background: #fff; padding: 4px; border-radius: 4px; }

.stats { background: var(--accent-light); padding: 10px 14px; border-radius: 4px; display: inline-block; }

/* ===== Clickable rows ===== */
.compound-row { cursor: pointer; }

/* ===== Responsive tweaks ===== */
@media (max-width: 720px) {
  .header-inner { padding: 10px 14px; }
  .title-block h1 { font-size: 22px; }
  .subtitle { font-size: 12px; }
  .main-nav { gap: 12px; font-size: 13px; }
  .section { padding: 24px 0; }
  .section-inner { padding: 0 14px; }
  .filter { min-width: 140px; }
  .footer-acad { text-align: left; }
}

/* ===== Mobile card layout (≤768px) ===== */
@media (max-width: 768px) {
  .table-wrap { border: none; box-shadow: none; background: transparent; overflow: visible; }

  #compounds-table thead { display: none; }

  #compounds-table,
  #compounds-table tbody,
  #compounds-table tr,
  #compounds-table td { display: block; width: 100%; }

  #compounds-table tr.compound-row {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 12px;
    padding: 14px;
    box-shadow: var(--shadow);
    position: relative;
    min-height: 110px;
  }

  #compounds-table tr.compound-row:hover { background: var(--accent-light); }

  /* Reset all td styling */
  #compounds-table td {
    border: none;
    padding: 0;
    display: block;
  }

  /* Type tag: top-left */
  .col-type { margin-bottom: 8px; }

  /* Structure: float top-right */
  .col-structure {
    float: right;
    margin: 0 0 8px 12px;
    width: auto !important;
    min-width: auto !important;
  }
  .col-structure svg {
    width: 140px;
    height: 95px;
  }

  /* ID: bold */
  .col-id { font-weight: 700; font-size: 14px; margin-bottom: 2px; }

  /* Name: normal text, wraps */
  .col-name { font-size: 14px; margin-bottom: 4px; color: var(--text); }

  /* SMILES: monospace, wraps */
  .col-smiles {
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 12px;
    color: var(--muted);
    overflow-wrap: anywhere;
    word-break: break-all;
    max-width: none !important;
    margin-bottom: 4px;
  }

  /* Hide columns that are accessible via the detail modal */
  .col-formula,
  .col-mw,
  .col-plate,
  .col-well,
  .col-target,
  .col-pathway,
  .col-cas,
  .col-details { display: none !important; }

  /* Clear float after card content */
  #compounds-table tr.compound-row::after {
    content: '';
    display: block;
    clear: both;
  }

  /* Pagination: full width buttons */
  .pagination { flex-wrap: wrap; }
  .pagination button { flex: 1; min-width: 80px; }

  /* Results bar: stack */
  .results-bar { flex-direction: column; align-items: flex-start; gap: 8px; }

  /* ===== Mobile modal: stacked label/value layout ===== */
  .modal-overlay { padding: 0; align-items: stretch; }
  .modal {
    max-width: 100%;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
  }
  .modal-header { position: sticky; top: 0; background: #fff; z-index: 2; }
  .modal-header h3 { font-size: 16px; }
  .modal-body { padding: 16px; }

  /* Structure: centered, full width */
  .modal-structure {
    float: none;
    margin: 0 auto 16px;
    display: block;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    background: #fff;
  }
  .modal-structure svg, .modal-structure canvas {
    width: 100%;
    max-width: 300px;
    height: 200px;
    margin: 0 auto;
    display: block;
  }

  /* Key-value table → stacked single-column */
  .modal-body table { width: 100%; }
  .modal-body table,
  .modal-body tbody,
  .modal-body tr,
  .modal-body td { display: block; width: 100%; }
  .modal-body tr {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
  }
  .modal-body tr:last-child { border-bottom: none; }
  .modal-body td.k {
    width: 100%;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--primary);
    margin-bottom: 2px;
    padding: 0;
  }
  .modal-body td.v {
    width: 100%;
    font-size: 14px;
    color: var(--text);
    padding: 0;
    word-break: break-word;
  }
}
