/* ════════════════════════════════════════
   Gistaru Scraper – Stylesheet
   ════════════════════════════════════════ */

:root {
  --primary:   #1a6b3c;
  --primary-d: #124d2b;
  --primary-l: #e8f5ee;
  --accent:    #f0a500;
  --danger:    #dc3545;
  --success:   #198754;
  --bg:        #f4f6f8;
  --surface:   #ffffff;
  --border:    #dde2e8;
  --text:      #1e2a35;
  --text-muted:#6c757d;
  --shadow:    0 2px 12px rgba(0,0,0,.10);
  --radius:    8px;
  --sidebar-w: 320px;
  --header-h:  56px;
}

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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ─── HEADER ─── */
header {
  height: var(--header-h);
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  z-index: 1000;
}
.header-brand { display: flex; align-items: center; gap: 12px; }
.header-brand i { font-size: 24px; color: var(--accent); }
.header-brand h1 { font-size: 16px; font-weight: 700; line-height: 1.2; }
.header-brand span { font-size: 11px; opacity: .8; }
.header-info { display: flex; align-items: center; gap: 12px; }
.source-url { font-size: 11px; opacity: .7; }
.source-url i { margin-right: 4px; }

/* Badge */
.badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.badge-idle    { background: rgba(255,255,255,.2); }
.badge-loading { background: var(--accent); color: #222; animation: pulse 1s infinite; }
.badge-ok      { background: #28a745; }
.badge-error   { background: var(--danger); }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.5} }

/* ─── LAYOUT ─── */
.layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ─── SIDEBAR ─── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
  position: relative;
  transition: width .25s ease, opacity .25s ease;
}
.sidebar.collapsed { width: 0; opacity: 0; overflow: hidden; }

.sidebar-toggle {
  position: absolute;
  right: -16px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 500;
  background: var(--primary);
  color: #fff;
  border: none;
  width: 16px;
  height: 48px;
  border-radius: 0 6px 6px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}
.sidebar-toggle:hover { background: var(--primary-d); }
.sidebar.collapsed .sidebar-toggle i { transform: rotate(180deg); }

/* ─── PANELS ─── */
.panel {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.panel h2 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.panel label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin: 10px 0 4px;
  font-weight: 600;
}
.panel input[type="text"],
.panel input[type="number"],
.panel select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .2s;
}
.panel input:focus, .panel select:focus { border-color: var(--primary); }
.panel select:disabled { opacity: .5; cursor: not-allowed; }

.input-group { display: flex; gap: 4px; }
.input-group input { flex: 1; }

.checkbox-group { margin-top: 10px; }
.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  margin: 0;
  font-weight: 400;
}

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: none;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, opacity .2s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary  { background: var(--primary); color: #fff; width: 100%; justify-content: center; margin-top: 10px; }
.btn-primary:hover:not(:disabled)  { background: var(--primary-d); }
.btn-secondary{ background: var(--primary-l); color: var(--primary); }
.btn-secondary:hover { background: #d0eadb; }
.btn-success  { background: var(--success); color: #fff; flex: 1; justify-content: center; }
.btn-success:hover:not(:disabled) { background: #145e3c; }
.btn-danger   { background: var(--danger); color: #fff; width: 100%; justify-content: center; }
.btn-danger:hover:not(:disabled) { background: #b02a37; }
.btn-ghost    { background: transparent; color: var(--text-muted); padding: 4px 8px; }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { font-size: 11px; padding: 4px 8px; }
.btn-group { display: flex; gap: 6px; margin-top: 8px; }

/* Result summary */
.result-summary {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-muted);
  min-height: 40px;
}
.result-summary strong { color: var(--primary); }

/* ─── LOG ─── */
.panel-log { flex: 1; }
#log-box {
  background: #0e1a24;
  color: #7ed87e;
  border-radius: var(--radius);
  padding: 8px 10px;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  line-height: 1.7;
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 6px;
}
.log-info  { color: #7ed87e; }
.log-warn  { color: #f0c040; }
.log-error { color: #ff6b6b; }
.log-dim   { color: #6b8080; }

/* ─── MAP ─── */
.map-container { flex: 1; position: relative; overflow: hidden; }
#map { width: 100%; height: 100%; }

/* Map toolbar */
.map-toolbar {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.map-tool-btn {
  width: 34px;
  height: 34px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: background .2s;
}
.map-tool-btn:hover { background: var(--primary-l); color: var(--primary); }

/* Feature info box */
.feature-info {
  position: absolute;
  bottom: 20px;
  right: 10px;
  width: 300px;
  max-height: 320px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 500;
}
.feature-info.hidden { display: none; }
.feature-info h3 {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 700;
  background: var(--primary-l);
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.close-btn {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
}
.close-btn:hover { color: var(--danger); }
#feature-table {
  overflow-y: auto;
  flex: 1;
  padding: 8px;
}
#feature-table table { width: 100%; border-collapse: collapse; }
#feature-table tr { border-bottom: 1px solid var(--border); }
#feature-table td {
  padding: 4px 6px;
  font-size: 11px;
  vertical-align: top;
  word-break: break-word;
}
#feature-table td:first-child {
  font-weight: 700;
  color: var(--text-muted);
  width: 40%;
}

/* ─── ATTRIBUTE TABLE ─── */
.attr-panel {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-w);
  right: 0;
  height: 240px;
  background: var(--surface);
  border-top: 2px solid var(--primary);
  z-index: 600;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -4px 16px rgba(0,0,0,.1);
  transition: left .25s ease;
}
.attr-panel.hidden { display: none; }
.attr-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: var(--primary-l);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.attr-header span { font-size: 12px; font-weight: 700; color: var(--primary); }
.attr-header input {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  margin-right: 6px;
  outline: none;
  width: 180px;
}
#attr-table-wrapper { overflow: auto; flex: 1; }
#attr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
#attr-table th {
  background: var(--bg);
  padding: 5px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}
#attr-table td {
  padding: 4px 8px;
  border-bottom: 1px solid #f0f0f0;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}
#attr-table tbody tr:hover { background: var(--primary-l); cursor: pointer; }

/* Toggle attr table button */
.btn-attr-toggle {
  position: fixed;
  bottom: 12px;
  left: calc(var(--sidebar-w) + 12px);
  z-index: 601;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow);
}
.btn-attr-toggle.hidden { display: none; }
.btn-attr-toggle:hover { background: var(--primary-d); }

/* ─── LOADING OVERLAY ─── */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 800;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
  .sidebar { width: 100%; position: absolute; z-index: 700; top: 0; bottom: 0; left: 0; }
  .sidebar.collapsed { display: none; }
  .attr-panel { left: 0; }
  .btn-attr-toggle { left: 12px; }
}
