/* ===== Speclib — TemanRiset-style UI ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('/speclib/static/fonts/plusjakartasans-400.woff2') format('woff2');
}

html {
  --bg: #e3eaee;
  --surface: #ffffff;
  --surface2: #e9ecef;
  --border: #dee2e6;
  --text: #162030;
  --text-dim: #6c757d;
  --accent: #013880;
  --accent-hover: #012a60;
  --accent2: #ffbd07;
  --radius: 8px;
}

html[data-theme="dark"] {
  --bg: #0b0e17;
  --surface: #1a2035;
  --surface2: #232740;
  --border: #2a3150;
  --text: #e8edf5;
  --text-dim: #8892b0;
  --accent: #0099cc;
  --accent-hover: #33b3dd;
  --accent2: #ffbd07;
}

html { background: var(--bg); }
body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  transition: background 0.2s, color 0.2s;
  display: flex;
  flex-direction: column;
}

/* ===== HEADER ===== */
header {
  background: linear-gradient(135deg, #013880 0%, #014a9e 55%, #0157b4 100%);
  border-bottom: 3px solid var(--accent2);
  padding: 0.85rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  transition: background 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
header .logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.header-right { display: flex; align-items: center; gap: 0.75rem; }
.theme-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.theme-btn:hover { border-color: rgba(255,255,255,0.5); background: rgba(255,255,255,0.2); }
.header-link {
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  text-decoration: none;
  padding: 0.3rem 0.7rem;
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 16px;
  transition: all 0.2s;
}
.header-link:hover { background: rgba(255,255,255,0.2); border-color: rgba(255,255,255,0.8); color: #fff; }
.header-link.active { background: rgba(255,255,255,0.25); border-color: rgba(255,255,255,0.8); color: #fff; }

/* ===== MAIN ===== */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  flex: 1;
  width: 100%;
}

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  transition: background 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

@media (max-width: 640px) {
  .card { padding: 1rem; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.04); }
  main { padding: 1rem; }
  .detail-header h1 { font-size: 1.4rem; }
  .chart-box { height: 320px; }
}
.card h2 { font-size: 1.15rem; margin-bottom: 1rem; color: var(--text); display: flex; align-items: center; gap: 0.5rem; }

/* ===== DETAIL PAGE ===== */
.detail-header { margin-bottom: 1.5rem; }
.detail-header h1 { font-size: 1.8rem; font-weight: 800; color: var(--text); }
.detail-meta { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.4rem; }
.detail-meta span { font-size: 0.75rem; color: var(--text-dim); }

.back-link { display: inline-block; color: var(--accent); text-decoration: none; font-size: 0.9rem; margin-bottom: 1rem; }
.back-link:hover { text-decoration: underline; }

.type-badge {
  display: inline-block; font-size: 0.65rem; font-weight: 700; padding: 0.2rem 0.6rem;
  border-radius: 10px; text-transform: uppercase; letter-spacing: 0.04em;
  background: #e3f2fd; color: #1565c0;
}

/* ===== METADATA ===== */
.metadata-card { margin-bottom: 1.5rem; }
.metadata-grid { display: grid; gap: 1rem; }
.meta-label { font-size: 0.75rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.15rem; }
.meta-value { font-size: 0.95rem; color: var(--text); line-height: 1.5; }
.meta-value.citation { font-size: 0.85rem; color: var(--text-dim); font-style: italic; border-left: 2px solid var(--border); padding-left: 0.75rem; }

/* ===== FORMS ===== */
label { display: block; font-size: 0.9rem; color: var(--text-dim); margin-bottom: 0.4rem; font-weight: 500; }
input[type="text"], input[type="search"], textarea, select {
  width: 100%; padding: 0.7rem 1rem; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 0.95rem; transition: border-color 0.2s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { min-height: 120px; resize: vertical; font-family: inherit; }
select { cursor: pointer; appearance: auto; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.7rem 1.5rem; border: none; border-radius: var(--radius);
  font-size: 0.95rem; font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }

/* ===== BAND MAPPING TABLES ===== */
.mapping-table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.mapping-table th { background: var(--surface2); color: var(--text-dim); font-size: 0.75rem; padding: 0.5rem 0.75rem; text-align: left; }
.mapping-table td { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); font-size: 0.85rem; color: var(--text); }
.mapping-table tr:hover td { background: var(--surface2); }

/* ===== DATA TABLE ===== */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { background: var(--surface2); color: var(--text-dim); font-weight: 600; padding: 0.5rem 0.75rem; font-size: 0.8rem; text-align: left; white-space: nowrap; position: sticky; top: 0; }
td { padding: 0.35rem 0.75rem; border-bottom: 1px solid var(--border); font-size: 0.8rem; color: var(--text); }
tr:hover td { background: var(--surface2); }

/* ===== METHOD GRID (detail page) ===== */
.method-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.5rem; margin: 0.5rem 0; }
.method-card {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.6rem 0.75rem; cursor: pointer; transition: all 0.2s;
}
.method-card:hover { border-color: var(--accent); }
.method-card.active { border-color: var(--accent); background: rgba(1,56,128,0.05); }
.method-name { font-weight: 700; font-size: 0.85rem; color: var(--accent); margin-bottom: 0.2rem; }
.method-desc { font-size: 0.72rem; color: var(--text-dim); line-height: 1.4; }

/* ===== SENSOR TABS ===== */
.sensor-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.tab-btn {
  padding: 0.6rem 1rem; background: none; border: none; color: var(--text-dim);
  font-size: 0.85rem; font-weight: 500; cursor: pointer;
  border-bottom: 2px solid transparent; transition: all 0.2s;
}
.tab-btn:hover { color: var(--text); background: var(--surface2); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ===== MANAGE TABLE ===== */
.em-table td, .em-table th { padding: 0.45rem 0.65rem; font-size: 0.82rem; }
.inline-flex { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge-info { display: inline-block; font-size: 0.65rem; font-weight: 700; padding: 0.2rem 0.6rem; border-radius: 10px; background: #e3f2fd; color: #1565c0; }

/* Manage control bar */
.control-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.control-bar label { font-size: 0.78rem; color: var(--text-dim); white-space: nowrap; margin-bottom: 0; }
.control-bar select { width: auto; min-width: 120px; font-size: 0.8rem; padding: 0.35rem 0.6rem; }

/* ===== UPLOAD PAGE ===== */
.upload-area {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 3rem 2rem; text-align: center; cursor: pointer; transition: all 0.3s;
}
.upload-area:hover, .upload-area.dragover { border-color: var(--accent); background: rgba(1,56,128,0.03); }
.upload-area .icon { font-size: 3rem; margin-bottom: 1rem; }
.upload-area .hint { font-size: 0.8rem; color: var(--text-dim); }
.upload-area input[type="file"] { display: none; }

.form-group { margin-bottom: 1rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-group.full { grid-column: 1 / -1; }

.result { margin-top: 1rem; padding: 1rem; border-radius: var(--radius); display: none; }
.result.success { display: block; background: rgba(34,197,94,0.08); border: 1px solid rgba(34,197,94,0.3); color: #16a34a; }
.result.error { display: block; background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.3); color: #dc2626; }

/* ===== CHARTS ===== */
.chart-box { width: 100%; height: 420px; margin: 1rem 0; }
.chart-box-sm { width: 100%; height: 320px; margin: 1rem 0; }
.chart-box-lg { width: 100%; height: 400px; margin-top: 1rem; }
.chart-box-md { width: 100%; height: 320px; margin-top: 1rem; }

/* ===== FOOTER ===== */
footer {
  background: #013880;
  color: white;
  text-align: center;
  padding: 1.2rem 1rem;
  font-size: 0.8rem;
  margin-top: auto;
  border-top: 3px solid var(--accent2);
}
footer p { margin: 0; color: white; }

/* ===== ABOUT PAGE compat vars ===== */
.about-wrap {
  --primary: var(--accent);
  --text-muted: var(--text-dim);
  --bg-card: var(--surface);
  --border-light: var(--border);
  --bg-hover: var(--surface2);
}

/* ===== MISC ===== */
.error { color: #dc2626; }
.text-sm { font-size: 0.78rem; color: var(--text-dim); }
.text-red { color: #dc2626; }
.subtitle { font-size: 0.82rem; color: var(--text-dim); line-height: 1.5; margin-bottom: 1rem; }
