/* ============================================================
   SYYTTÄJÄN TYÖPÖYTÄ — common.css
   Shared across all views: navbar, sidebar, right toolbar, toast
   ============================================================ */

:root {
  --bg: #eef0f4;
  --panel: #ffffff;
  --navy: #1b3a6b;
  --navy-mid: #2d5fa6;
  --navy-light: #dce8f8;
  --text: #1c1f26;
  --muted: #64748b;
  --border: #dde1e7;
  --highlight: #f0f5ff;
  --active-border: #3b82f6;
  --danger: #dc2626;
  --sidebar-w: 272px;
  --nav-h: 52px;
  --radius: 5px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

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

/* ===== NAVBAR ===== */
.navbar {
  height: var(--nav-h);
  background: var(--navy);
  color: white;
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 12px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.22);
  z-index: 100;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.03em;
  color: white;
  text-decoration: none;
  white-space: nowrap;
}

.brand-badge {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  letter-spacing: 0.05em;
}

.nb-sep { width: 1px; height: 26px; background: rgba(255,255,255,0.18); flex-shrink: 0; }

.navbar-case-id {
  font-weight: 600;
  font-size: 13px;
  color: white;
}

.navbar-case-desc {
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  margin-left: 2px;
}

.navbar-spacer { flex: 1; }

.status-chip {
  padding: 3px 9px;
  border-radius: 10px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(251,191,36,0.18);
  color: #fbbf24;
  border: 1px solid rgba(251,191,36,0.28);
}

.nb-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
}

.nb-btn-ghost {
  background: rgba(255,255,255,0.1);
  color: white;
  border: 1px solid rgba(255,255,255,0.15);
}
.nb-btn-ghost:hover { background: rgba(255,255,255,0.18); }

.nb-btn-solid {
  background: white;
  color: var(--navy);
  font-weight: 600;
}
.nb-btn-solid:hover { background: #e0eaf9; }

.nb-btn-purple {
  background: rgba(139,92,246,0.8);
  color: white;
  border: 1px solid rgba(139,92,246,0.4);
}
.nb-btn-purple:hover { background: rgba(139,92,246,1); }

/* Autosave indicator */
.save-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: rgba(255,255,255,0.5);
  font-family: 'Segoe UI', sans-serif;
  transition: color 0.3s;
  user-select: none;
}
.save-indicator.saving { color: rgba(255,255,255,0.85); }
.save-indicator.saved  { color: rgba(255,255,255,0.55); }
.save-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0;
  transition: opacity 0.3s;
}
.save-indicator.saving .save-dot {
  opacity: 1;
  animation: save-pulse 0.7s ease-in-out infinite alternate;
}
.save-indicator.saved .save-dot { opacity: 1; }
@keyframes save-pulse {
  from { opacity: 0.4; }
  to   { opacity: 1; }
}

/* ===== LAYOUT ===== */
.app-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

.main-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 40px;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.sb-section { border-bottom: 1px solid var(--border); }

.sb-header {
  padding: 9px 13px;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  background: #f9fafc;
}
.sb-header:hover { background: var(--highlight); }

.sb-toggle { font-size: 9px; transition: transform 0.2s; }
.sb-toggle.collapsed { transform: rotate(-90deg); }

.sb-content { padding: 6px 8px; }

.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 13px;
  gap: 8px;
}

.meta-label { color: var(--muted); font-size: 11px; white-space: nowrap; }
.meta-value { font-size: 11px; font-weight: 500; text-align: right; color: var(--text); }

/* Sidebar outline */
.outline-item {
  display: flex;
  align-items: center;
  padding: 5px 13px;
  cursor: pointer;
  font-size: 12px;
  gap: 7px;
  border-left: 3px solid transparent;
  transition: all 0.1s;
}
.outline-item:hover { background: var(--highlight); }
.outline-item.active {
  background: var(--navy-light);
  border-left-color: var(--navy-mid);
  color: var(--navy);
  font-weight: 600;
}

.oi-badge {
  width: 17px; height: 17px;
  border-radius: 3px;
  background: var(--navy);
  color: white;
  font-size: 8.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.oi-badge.sub { background: var(--navy-mid); width: 13px; height: 13px; margin-left: 14px; }

.oi-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  margin-left: auto;
  flex-shrink: 0;
}
.oi-dot.ok      { background: #22c55e; }
.oi-dot.partial { background: #f59e0b; }
.oi-dot.empty   { background: #e5e7eb; }

.source-item {
  padding: 5px 13px;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  color: var(--muted);
  border-left: 3px solid transparent;
}
.source-item:hover { background: var(--highlight); color: var(--text); }
.source-tag {
  font-size: 9px;
  padding: 1px 5px;
  background: #fef3c7;
  color: #92400e;
  border-radius: 3px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.source-tag.rv { background: #dbeafe; color: #1e40af; }

.sidebar-scroll { overflow-y: auto; flex: 1; }

/* Collapsible sidebar sections */
.collapsible { overflow: hidden; transition: max-height 0.25s ease, opacity 0.2s, padding 0.25s; }
.collapsible.closed { max-height: 0 !important; opacity: 0; padding-top: 0 !important; padding-bottom: 0 !important; }

/* ===== RIGHT TOOLBAR ===== */
.right-toolbar {
  width: 60px;
  background: var(--panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 14px;
  gap: 6px;
  flex-shrink: 0;
  z-index: 5;
}

.rt-btn {
  position: relative;
  width: 42px;
  height: 42px;
  border: none;
  background: none;
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.rt-btn:hover  { background: #e8eaf0; color: var(--navy); }
.rt-btn.active { background: #dde1ea; color: var(--navy); }

.rt-badge {
  position: absolute;
  top: 5px; right: 5px;
  background: var(--navy);
  color: white;
  font-size: 7.5px;
  font-weight: 700;
  border-radius: 10px;
  min-width: 13px;
  height: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
}

.rt-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 7px; height: 7px;
  background: #f59e0b;
  border-radius: 50%;
  border: 1.5px solid var(--panel);
}

.rt-panel {
  position: absolute;
  right: 60px;
  top: 0;
  bottom: 0;
  width: 0;
  overflow: hidden;
  background: var(--panel);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  transition: width 0.22s ease;
  display: flex;
  flex-direction: column;
  z-index: 20;
  box-shadow: -4px 0 16px rgba(0,0,0,0.07);
}
.rt-panel.open { width: 290px; }

.rt-panel-inner {
  width: 290px;
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rt-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.rt-panel-title {
  font-size: 10.5pt;
  font-weight: 700;
  color: var(--navy);
}

.rt-panel-close {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 13px; padding: 2px 4px; border-radius: 3px;
}
.rt-panel-close:hover { color: var(--navy); background: #e8eaf0; }

.rt-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  position: relative;
}
.rt-card-title { font-size: 10pt; font-weight: 600; color: var(--text); margin-bottom: 3px; padding-right: 18px; }
.rt-card-body  { font-size: 9pt; color: var(--muted); line-height: 1.5; }
.rt-card-dismiss {
  position: absolute; top: 8px; right: 8px;
  background: none; border: none; cursor: pointer;
  color: #94a3b8; font-size: 12px; line-height: 1;
  padding: 1px 3px; border-radius: 3px;
}
.rt-card-dismiss:hover { color: var(--navy); background: #e8eaf0; }

.rt-magic-btn {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 8.5pt;
  font-family: 'Segoe UI', sans-serif;
  font-weight: 600;
  color: #6d28d9;
  background: #faf5ff;
  border: 1px solid #c4b5fd;
  border-radius: 4px;
  padding: 3px 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.rt-magic-btn:hover { background: #ede9fe; border-color: #7c3aed; }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--navy);
  color: white;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 12.5px;
  font-family: 'Segoe UI', sans-serif;
  box-shadow: 0 4px 16px rgba(0,0,0,0.22);
  z-index: 1000;
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* Rikosrekisteri panel */
.rr-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.rr-badge { display: inline-block; font-size: 8pt; font-weight: 600; border-radius: 3px; padding: 1px 7px; }
.rr-badge.punainen { background: #fee2e2; color: #991b1b; }
.rr-badge.keltainen { background: #fef9c3; color: #854d0e; }
.rr-badge.vihrea { background: #dcfce7; color: #166534; }
.rr-ote-link { font-size: 8pt; color: var(--navy); text-decoration: none; white-space: nowrap; }
.rr-ote-link:hover { text-decoration: underline; }
.rr-tuomio { border-left: 2px solid var(--border); padding: 5px 0 5px 10px; margin: 6px 0; }
.rr-tuomio-nimike { font-size: 9pt; font-weight: 600; color: var(--text); }
.rr-tuomio-meta { font-size: 8pt; color: var(--muted); margin-top: 2px; line-height: 1.5; }
.rr-tuomio-seuraamus { font-size: 8.5pt; color: var(--text); margin-top: 3px; }
.rr-konkurrenssi { background: #fff7ed; border: 1px solid #fed7aa; border-radius: 5px; padding: 8px 10px; margin: 8px 0; font-size: 8.5pt; color: #7c2d12; }
.rr-konkurrenssi-head { font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; gap: 5px; }
.rr-konkurrenssi-link { color: #c2410c; font-size: 8pt; text-decoration: none; display: inline-block; margin-top: 5px; }
.rr-konkurrenssi-link:hover { text-decoration: underline; }
.rr-vireillaolo { font-size: 9pt; }
.rr-vireillaolo-link { color: var(--navy); text-decoration: none; font-weight: 600; }
.rr-vireillaolo-link:hover { text-decoration: underline; }
.rr-section-label { font-size: 8pt; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 8px 0 4px; }
