/* Shared CSS for the gene-input analysis pages (new_polypharma_gene.php,
 * new_comorbidity_gene.php, new_polypharma_input.php, new_comorbidity.php)
 * — extracted from their identical inline <style> blocks so these pages
 * fetch one cacheable external file instead of each re-parsing ~190 lines
 * of inline CSS on every load. Nothing else on the site links it.
 */
:root {
  --main-color: #008995;
  --main-color-dark: #006B76;
  --accent-green: #10B981;
  --accent-green-dark: #059669;
  --text-color: #0F172A;
  --light-bg: #F3F8F5;
  --accent-color: #10B981;
  --hover-color: #006B76;
  --text-muted: #666666;
  --card-bg: #ffffff;
  --border-color: #dddddd;
  --border-color-2: #d4d4d4;
  --page-gradient: linear-gradient(160deg, #F3F8F5 0%, #F7FAF8 40%, #ffffff 75%);
  --sec-bg: #F0FAFA;
  --sec-border: #C0E3ED;
  --loading-bg: #ffffff;
  --autocomplete-hover-1: #F0FAFA;
  --autocomplete-hover-2: #E8F7F7;
}
/* Consuming pages (new_comorbidity.php, new_comorbidity_gene.php,
   new_polypharma_gene.php, new_polypharma_input.php) each carry their own
   pre-paint theme-init <script> and set data-theme on <html> before this
   stylesheet is even parsed, so these selectors just work with no extra
   wiring needed here. */
:root[data-theme="dark"] {
  --main-color: #22D3D9;
  --main-color-dark: #5EEAD4;
  --accent-green: #34D399;
  --accent-green-dark: #6EE7B7;
  --text-color: #E2E8F0;
  --light-bg: #1E293B;
  --accent-color: #34D399;
  --hover-color: #5EEAD4;
  --text-muted: #94A3B8;
  --card-bg: #131C2E;
  --border-color: #334155;
  --border-color-2: #334155;
  --page-gradient: linear-gradient(160deg, #0B1220 0%, #0B1220 40%, #0B1220 75%);
  --sec-bg: #1A2740;
  --sec-border: #334155;
  --loading-bg: #131C2E;
  --autocomplete-hover-1: #1A2740;
  --autocomplete-hover-2: #1E293B;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --main-color: #22D3D9;
    --main-color-dark: #5EEAD4;
    --accent-green: #34D399;
    --accent-green-dark: #6EE7B7;
    --text-color: #E2E8F0;
    --light-bg: #1E293B;
    --accent-color: #34D399;
    --hover-color: #5EEAD4;
    --text-muted: #94A3B8;
    --card-bg: #131C2E;
    --border-color: #334155;
    --border-color-2: #334155;
    --page-gradient: linear-gradient(160deg, #0B1220 0%, #0B1220 40%, #0B1220 75%);
    --sec-bg: #1A2740;
    --sec-border: #334155;
    --loading-bg: #131C2E;
    --autocomplete-hover-1: #1A2740;
    --autocomplete-hover-2: #1E293B;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', sans-serif;
  color: var(--text-color);
  background: var(--page-gradient);
  line-height: 1.6;
}

.main-content {
  padding: 40px clamp(16px, 3vw, 60px);
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
}

.page-header {
  text-align: center;
  margin-bottom: 50px;
}

.page-header h1 {
  color: var(--main-color);
  font-size: 2.8em;
  margin-bottom: 15px;
  font-weight: 600;
  position: relative;
  display: inline-block;
}

.page-header .info-icon {
  color: #17a2b8;
  font-size: 0.5em;
  cursor: help;
  position: absolute;
  top: -0.3em;
  right: -0.9em;
  transition: color 0.3s ease, transform 0.2s ease;
  text-decoration: none;
}

.page-header .info-icon:hover { color: rgb(250, 142, 79); transform: scale(1.1); }
.page-header .info-icon:active { transform: scale(0.95); }

.page-header p { color: var(--text-muted); font-size: 1.05em; max-width: 700px; margin: 10px auto 0; }

.button-row { display: flex; gap: 10px; margin-top: 10px; }

.example-btn {
  background: var(--main-color);
  color: white;
  border: none;
  padding: 8px 20px;
  font-size: 14px;
  font-weight: bold;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.3s;
  flex: 1;
}

.example-btn:hover { background: var(--hover-color); }

.clear-btn {
  background: #999;
  color: white;
  border: none;
  padding: 8px 20px;
  font-size: 14px;
  font-weight: bold;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.3s;
  flex: 1;
}

.clear-btn:hover { background: rgb(96, 96, 96); }

.analysis-form {
  background: var(--light-bg);
  padding: 30px;
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  margin-bottom: 30px;
}

/* new_polypharma_gene.php has no descriptive <p> under its h1 (unlike
   new_comorbidity_gene.php), so its header takes less vertical space and
   needs this pull-up to match the original per-page spacing. */
body.gene-input-polypharma .analysis-form { margin-top: -45px; }

.form-row { display: flex; gap: 20px; align-items: flex-start; margin-bottom: 30px; }
.form-column { flex: 1; }
.form-column h3 { color: var(--main-color); margin-bottom: 15px; font-size: 1.2em; }

.gene-list {
  width: 100%;
  height: 300px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  background: var(--card-bg);
  color: var(--text-color);
}

#sec { background: var(--sec-bg); border: 2px solid var(--sec-border); color: var(--text-color); }
#sec option { background: linear-gradient(135deg, #ffffff 0%, #E8F7F7 100%); margin: 3px; padding: 10px 12px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,137,149,0.1); transition: all 0.3s cubic-bezier(0.4,0,0.2,1); }
#sec option:hover { background: linear-gradient(135deg, #E8F7F7 0%, #E6F5F6 100%); transform: translateX(3px); box-shadow: 0 4px 12px rgba(0,137,149,0.2); }
#sec option:selected { background: linear-gradient(135deg, #C0E3ED 0%, #A3D9DE 100%); color: #004D57; font-weight: 600; }

.control-buttons { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 20px; padding: 20px 0; }

.move-btn {
  background: var(--main-color);
  color: white;
  border: none;
  padding: 12px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.move-btn:hover { background: var(--hover-color); transform: scale(1.05); box-shadow: 0 4px 8px rgba(0,0,0,0.3); }
.move-btn:active { transform: scale(0.95); }

.analysis-options {
  background: var(--card-bg);
  padding: 25px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  margin-bottom: 30px;
}

.analysis-options h3 { color: var(--main-color); margin-bottom: 20px; }
.radio-option { margin-bottom: 15px; }
.radio-option input[type="radio"] { margin-right: 10px; }
.radio-option label { font-weight: 500; cursor: pointer; }

/* "← Back to ..." link above the page header, e.g. from an input page back
   to its hub (comorbidity/new_comorbidity*.php -> new_comorbidity_hub.php). */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--main-color);
  font-size: 14px;
  font-weight: bold;
  text-decoration: none;
}
.back-link:hover { color: var(--hover-color); text-decoration: underline; }

.submit-section { text-align: center; margin-top: 30px; }

.submit-btn {
  background: var(--main-color);
  color: white;
  border: none;
  padding: 15px 40px;
  font-size: 16px;
  font-weight: bold;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.3s;
}

.submit-btn:hover { background: var(--hover-color); }

#loadingmsg {
  color: var(--text-color);
  background: var(--loading-bg);
  padding: 20px;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

#loadingover {
  background: rgba(0,0,0,0.8);
  z-index: 999;
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
}

@media (max-width: 768px) {
  .form-row { flex-direction: column; }
  .button-row { flex-direction: column; }
}

/* ── Gene search autocomplete ──
 * Same filter-a-plain-array-and-render-at-most-50-matches technique as
 * new_venn_gene.php's autocomplete(), reused here so the gene search box
 * behaves and looks the same way across the site instead of relying on
 * Select2 (which was slow at this list size: see the comment above
 * gene-input-shared.css's creation in new_polypharma_gene.php / history).
 */
.gene-search-input {
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 10px;
  font-size: 14px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  outline: none;
  background: var(--card-bg);
  color: var(--text-color);
  transition: border-color 0.2s ease;
}
.gene-search-input:focus { border-color: var(--main-color); }

.autocomplete { position: relative; width: 100%; }

.autocomplete-items {
  position: absolute;
  border: 1px solid var(--border-color-2);
  border-top: none;
  z-index: 1000;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 320px;
  overflow-y: auto;
  background: var(--card-bg);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
  border-radius: 0 0 12px 12px;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.autocomplete-items::-webkit-scrollbar { display: none; }

.autocomplete-items div {
  padding: 12px 16px;
  cursor: pointer;
  background-color: var(--card-bg);
  color: var(--text-color);
  font-size: 14px;
  transition: all 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.autocomplete-items div:last-child { border-radius: 0 0 12px 12px; }

.autocomplete-items div:hover {
  background: linear-gradient(135deg, var(--autocomplete-hover-1), var(--autocomplete-hover-2));
  border-left: 4px solid var(--main-color);
  padding-left: 12px;
}

.autocomplete-active {
  background: linear-gradient(135deg, var(--main-color), var(--main-color-dark)) !important;
  color: #ffffff !important;
  border-left: 4px solid #ffffff !important;
  padding-left: 12px !important;
}

.autocomplete-active .match-highlight {
  background: rgba(255,255,255,0.3) !important;
  color: #ffffff !important;
}

.match-highlight {
  background: linear-gradient(135deg, #fff3cd, #ffe066);
  padding: 2px 4px;
  border-radius: 4px;
  font-weight: 700;
  color: #8b6914;
}
