/* Käyttöbelgi.info - Modern Theme Stylesheet with Light/Dark Support */

:root {
  --bg: #0f172a;
  --card: #111827;
  --panel: #1f2937;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #f59e0b;
  --accent-2: #22c55e;
  --border: #1f2937;
  --shadow: 0 20px 40px rgba(0,0,0,0.35);
  --radius: 16px;
  --pad: 1rem;
  --pad-lg: 1.5rem;
  --max: 1200px;
}

/* Light theme - applies when system prefers light OR when light-theme class is set */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #ffffff;
    --card: #f9fafb;
    --panel: #f3f4f6;
    --text: #1f2937;
    --muted: #6b7280;
    --accent: #f59e0b;
    --accent-2: #22c55e;
    --border: #e5e7eb;
    --shadow: 0 20px 40px rgba(0,0,0,0.1);
  }
}

/* Dark theme class overrides system preference */
html.dark-theme {
  --bg: #0f172a;
  --card: #111827;
  --panel: #1f2937;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #f59e0b;
  --accent-2: #22c55e;
  --border: #1f2937;
  --shadow: 0 20px 40px rgba(0,0,0,0.35);
}

/* Light theme class overrides system preference */
html.light-theme {
  --bg: #ffffff;
  --card: #f9fafb;
  --panel: #f3f4f6;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #f59e0b;
  --accent-2: #22c55e;
  --border: #e5e7eb;
  --shadow: 0 20px 40px rgba(0,0,0,0.1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell { max-width: var(--max); margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }

/* Header / Topbar */
header.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
}

.topbar-inner { max-width: var(--max); margin: 0 auto; padding: 0.75rem 1.25rem; display: flex; align-items: center; gap: 1rem; }
.brand { display: flex; align-items: center; gap: 0.75rem; font-weight: 700; letter-spacing: 0.02em; }
.brand img { height: 36px; width: auto; }
.search form { display: flex; gap: 0.5rem; }
.search input { padding: 0.55rem 0.75rem; border-radius: 10px; border: 1px solid var(--border); background: var(--panel); color: var(--text); min-width: 220px; }
.theme-toggle { background: none; border: none; color: var(--text); cursor: pointer; font-size: 1.2rem; padding: 0.5rem; border-radius: 8px; transition: 0.2s; }
.theme-toggle:hover { background: var(--panel); }

/* Menu */
.menu-toggle { background: none; border: none; color: var(--text); cursor: pointer; font-size: 1.5rem; padding: 0.5rem; border-radius: 8px; transition: 0.2s; display: block; }
.menu-toggle:hover { background: var(--panel); }
.dropdown-menu { width: 100%; background: var(--card); border-bottom: 1px solid var(--border); box-shadow: var(--shadow); z-index: 120; display: none; position: absolute; left: 0; right: 0; top: 100%; }
.dropdown-menu.active { display: block; }
.dropdown-menu ul { list-style: none; padding: 0.75rem 0; margin: 0; }
.dropdown-menu li { margin: 0; }
.dropdown-menu > ul > li { border-bottom: 1px solid var(--border); }
.dropdown-menu > ul > li:last-child { border-bottom: none; }
.dropdown-menu a { display: block; padding: 0.65rem 1.25rem; color: var(--text); text-decoration: none; transition: 0.2s; }
.dropdown-menu a:hover { background: var(--panel); color: var(--accent); }
.dropdown-menu .submenu { display: none; background: var(--panel); }
.dropdown-menu .submenu.active { display: block; }
.dropdown-menu .submenu li { border-bottom: none; }
.dropdown-menu .submenu a { padding-left: 2rem; font-size: 0.9rem; color: var(--muted); }
.dropdown-menu .submenu a:hover { background: rgba(245, 158, 11, 0.1); color: var(--accent); }

/* Pills & Badges */
.pill { display: inline-flex; align-items: center; gap: 0.35rem; background: rgba(255,255,255,0.06); color: var(--muted); padding: 0.35rem 0.7rem; border-radius: 999px; font-size: 0.85rem; }
.pill.alert { color: #fcd34d; }
.pill.good { color: var(--accent-2); }

/* Hero Section */
.hero {
  background: linear-gradient(135deg, #0b1220, #111827);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--pad-lg);
  box-shadow: var(--shadow);
  margin-top: 1rem;
}

html.light-theme .hero {
  background: linear-gradient(135deg, #f3f4f6, #fffbeb);
}

.hero-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.75rem; }
.hero-title h1 { margin: 0; font-size: clamp(1.8rem, 2vw, 2.4rem); }
.subtitle { color: var(--muted); }
.badge-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
.status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.75rem; }

/* Grid & Cards */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; margin-top: 1.25rem; }
.grid.media-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--pad-lg); box-shadow: var(--shadow); }
.card.media { max-width: 800px; margin: 0 auto; }
.card.health { grid-row: span 2; }
.card h3 { margin: 0 0 0.75rem 0; font-size: 1.05rem; }

/* Definition Lists */
dl { margin: 0; }
dt { font-weight: 600; color: var(--muted); margin-top: 0.6rem; }
dd { margin: 0.1rem 0 0.5rem 0; }

/* Utility Classes */
.flex { display: flex; gap: 1rem; flex-wrap: wrap; }
.small { font-size: 0.9rem; color: var(--muted); }

/* Media Content */
.media { display: grid; gap: 0.75rem; }
.media img { width: 100%; border-radius: 12px; border: 1px solid var(--border); display: block; }
.media-content { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
.media-content .image-col { display: flex; flex-direction: column; }
.media-content .video-col { display: flex; flex-direction: column; gap: 0.75rem; }

/* Video */
.video-thumb { position: relative; overflow: hidden; border-radius: 12px; border: 1px solid var(--border); }
.video-thumb .play { position: absolute; inset: 0; display: grid; place-items: center; background: linear-gradient(0deg, rgba(0,0,0,0.55), rgba(0,0,0,0.2)); font-size: 1.3rem; color: #fff; }
.video-item { margin-bottom: 0.5rem; }
.video-link { color: var(--accent); cursor: pointer; font-size: 0.95rem; display: inline-block; margin-bottom: 0.5rem; }
.video-link:hover { text-decoration: underline; }

/* Placeholder Image */
.placeholder-image {
  width: 100%;
  aspect-ratio: 1/1;
  background: var(--panel);
  border: 2px dashed var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  color: var(--muted);
  transition: all 0.3s ease;
  padding: 2rem;
  text-align: center;
}
.placeholder-image svg {
  opacity: 0.5;
}
.placeholder-text {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.placeholder-text strong {
  font-size: 1.25rem;
  color: var(--text);
  font-weight: 600;
}
.placeholder-text p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--muted);
}

/* Modal */
.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.9); z-index: 1000; justify-content: center; align-items: center; padding: 1rem; }
.modal.show { display: flex; }
.modal-content { position: relative; width: 100%; max-width: 900px; aspect-ratio: 16/9; background: #000; border-radius: 12px; overflow: hidden; }
.modal-close { position: absolute; top: -40px; right: 0; background: none; border: none; color: #fff; font-size: 2rem; cursor: pointer; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; }
.modal-close:hover { color: var(--accent); }
.modal iframe { width: 100%; height: 100%; border: none; }

/* Tabs - Old style (deprecated) */
.tables { margin-top: 1.5rem; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 640px; color: var(--text); }
th, td { padding: 0.75rem; border-bottom: 1px solid var(--border); }
th { text-align: left; color: var(--muted); font-weight: 600; background: var(--panel); }
tbody tr:nth-child(even) { background: rgba(255,255,255,0.03); }
tbody tr:hover { background: rgba(255,255,255,0.06); }
tr:last-child td { border-bottom: none; }

/* Blockquotes */
blockquote { margin: 0; padding: 0.75rem 1rem; border-left: 3px solid var(--accent); background: rgba(255,255,255,0.04); border-radius: 8px; color: var(--muted); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 0.65rem 1rem; border-radius: 10px; border: 1px solid var(--border); background: var(--panel); color: var(--text); cursor: pointer; }
.btn.primary { background: var(--accent); color: #111; border-color: var(--accent); }

/* Footer */
.site-footer {
  background: var(--card);
  border-top: 1px solid var(--border);
  margin-top: 3rem;
  padding: 2rem 0 1rem;
}
.footer-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1.25rem;
}
.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}
.footer-col h4 {
  margin: 0 0 1rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
}
.footer-links li {
  margin-bottom: 0.5rem;
}
.footer-links a {
  color: var(--muted);
  font-size: 0.9rem;
  transition: color 0.2s;
}
.footer-links a:hover {
  color: var(--accent);
  text-decoration: none;
}
.footer-search {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.footer-search input {
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 0.9rem;
}
.footer-search input:focus {
  outline: none;
  border-color: var(--accent);
}
.footer-note {
  margin-top: 1rem;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
}
.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 1rem;
}
.footer-social {
  display: flex;
  gap: 1rem;
}
.footer-social a {
  color: var(--muted);
  transition: color 0.2s;
}
.footer-social a:hover {
  color: var(--accent);
}
.footer-copy {
  color: var(--muted);
  font-size: 0.85rem;
}

/* Responsive Design - Tablet */
@media (max-width: 820px) {
  .hero-title h1 { font-size: clamp(1.2rem, 3.5vw, 1.8rem); }
  .topbar-inner { flex-direction: row; align-items: center; }
  .dropdown-menu { border-top: 1px solid var(--border); }
  .search form { width: 100%; }
  .search input { flex: 1; width: 100%; min-width: auto; font-size: 0.9rem; }
  .shell { padding: 0.75rem 0.5rem 1.5rem; }
  .hero { padding: 0.75rem; margin-top: 0.5rem; }
  .pill { font-size: 0.75rem; padding: 0.25rem 0.5rem; }
  .tab-button { padding: 0.4rem 0.5rem; font-size: 0.75rem; }
  .card { padding: 0.75rem; }
  .card h3 { font-size: 0.9rem; margin-bottom: 0.5rem; }
  dl { font-size: 0.85rem; }
  dt { margin-top: 0.4rem; font-size: 0.8rem; }
  dd { margin: 0.05rem 0 0.3rem 0; }
  body { font-size: 0.95rem; }
  .grid { grid-template-columns: 1fr; gap: 0.75rem; }
  .card.health { grid-row: span 1; }
  .card.media { grid-column: span 1 !important; max-width: 100%; }
  .media-content { grid-template-columns: 1fr !important; }
  .media-grid { grid-template-columns: 1fr !important; }
  .status-grid { grid-template-columns: 1fr; gap: 0.5rem; }
  .brand { font-size: 0.85rem; }
  .brand img { height: 28px; }
  table { font-size: 0.8rem; min-width: 100%; }
  th, td { padding: 0.4rem; }
  .badge-row { gap: 0.35rem; }
  .subtitle { font-size: 0.9rem; }
  .site-footer { padding: 1.5rem 0 1rem; margin-top: 2rem; }
  .footer-grid { gap: 1.5rem; grid-template-columns: 1fr; }
  .footer-inner { padding: 0 0.75rem; }
  .footer-col h4 { font-size: 0.9rem; }
  .footer-links a { font-size: 0.85rem; }
  .footer-search input { font-size: 0.85rem; }
  .footer-note { font-size: 0.75rem; }
}

/* Responsive Design - Mobile */
@media (max-width: 480px) {
  .hero-title h1 { font-size: clamp(1rem, 4.5vw, 1.3rem); }
  .brand { font-size: 0.8rem; }
  .brand img { height: 24px; }
  .shell { padding: 0.5rem 0.4rem 1rem; }
  .hero { padding: 0.6rem; margin-top: 0.4rem; }
  .pill { font-size: 0.7rem; padding: 0.2rem 0.4rem; }
  .tab-button { padding: 0.35rem 0.4rem; font-size: 0.7rem; }
  .card h3 { font-size: 0.85rem; margin-bottom: 0.4rem; }
  .card { padding: 0.6rem; }
  body { font-size: 0.9rem; }
  dl { font-size: 0.8rem; }
  dt { margin-top: 0.3rem; font-size: 0.75rem; }
  dd { margin: 0 0 0.25rem 0; }
  table { font-size: 0.75rem; }
  th, td { padding: 0.3rem; }
  .search input { font-size: 0.85rem; }
  .subtitle { font-size: 0.8rem; }
  .badge-row { gap: 0.25rem; }
  .status-grid { gap: 0.4rem; }
  .site-footer { padding: 1rem 0 0.75rem; margin-top: 1.5rem; }
  .footer-grid { gap: 1rem; }
  .footer-inner { padding: 0 0.5rem; }
  .footer-bottom { flex-direction: column; align-items: flex-start; }
  .footer-copy { font-size: 0.8rem; }
}

/* Search Results Table Styling */
.search-results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.search-results-table thead {
  background-color: var(--accent);
  color: white;
  font-weight: 600;
}

.search-results-table thead th {
  padding: 1rem;
  text-align: left;
  border: none;
}

.search-results-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background-color 0.2s ease;
}

.search-results-table tbody tr:nth-child(even) {
  background-color: rgba(0, 0, 0, 0.15);
}

html.light-theme .search-results-table tbody tr:nth-child(even) {
  background-color: rgba(0, 0, 0, 0.02);
}

.search-results-table tbody tr:hover {
  background-color: var(--panel);
}

.search-results-table td {
  padding: 1rem;
  vertical-align: middle;
}

.search-results-table a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  transition: opacity 0.2s ease;
}

.search-results-table a:hover {
  opacity: 0.8;
  text-decoration: underline;
}

.search-results-table .deceased {
  text-decoration: line-through;
  opacity: 0.6;
}

/* Database Search Form Styling */
.panel-group {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.panel {
  border: none;
  box-shadow: none;
  margin-bottom: 0;
}

.panel-heading {
  background-color: var(--accent);
  border: none;
  padding: 0;
}

.panel-heading a {
  color: white;
  font-weight: 600;
  display: block;
  padding: 1rem;
  text-decoration: none;
}

.panel-heading a:hover {
  opacity: 0.9;
}

.panel-body {
  padding: 1.5rem;
  background-color: var(--card);
}

.panel-body h4 {
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

.panel-body h4:first-child {
  margin-top: 0;
}

.panel-body label {
  display: inline-block;
  margin-right: 1rem;
  margin-bottom: 0.5rem;
  color: var(--text);
  cursor: pointer;
}

.panel-body input[type="checkbox"],
.panel-body input[type="radio"] {
  margin-right: 0.5rem;
  cursor: pointer;
}

.panel-body select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background-color: var(--bg);
  color: var(--text);
  margin-bottom: 1rem;
  font-family: inherit;
}

.panel-body select option {
  background-color: var(--card);
  color: var(--text);
}

@media (max-width: 820px) {
  .panel-body {
    padding: 1rem;
  }
  
  .panel-body h4 {
    font-size: 0.9rem;
    margin-top: 1rem;
  }
  
  .panel-body label {
    display: block;
    margin-right: 0;
    margin-bottom: 0.75rem;
  }
}

/* Mobile-optimized form styles */
@media (max-width: 820px) {
  /* Stack two-column layout to single column on smaller screens */
  section[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  
  /* Ensure touch targets are at least 44px */
  input[type="checkbox"],
  input[type="radio"] {
    min-width: 20px !important;
    min-height: 20px !important;
  }
  
  /* Make form labels more touch-friendly */
  label {
    padding: 0.75rem !important;
    min-height: 44px !important;
    display: flex !important;
    align-items: center !important;
  }
  
  /* Larger touch targets for select dropdowns */
  select {
    min-height: 44px !important;
    font-size: 16px !important; /* Prevent zoom on iOS */
    padding: 0.75rem !important;
  }
  
  /* Larger buttons for mobile */
  button[type="submit"] {
    min-height: 48px !important;
    padding: 1rem !important;
    font-size: 1.1rem !important;
  }
  
  /* Better spacing in grid layouts */
  [style*="grid-template-columns"] {
    gap: 0.75rem !important;
  }
}

@media (max-width: 480px) {
  /* Single column for all grids on very small screens */
  [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
  
  /* Make text input fields full width */
  input[type="text"],
  input[type="email"],
  input[type="number"] {
    width: 100% !important;
  }
  
  /* Ensure proper spacing between form sections */
  [style*="margin-bottom: 1.5rem"] {
    margin-bottom: 1.25rem !important;
  }
  
  /* Full-width submit buttons */
  button[type="submit"] {
    width: 100% !important;
  }
  
  /* Better proportions for quick search on mobile portrait */
  #quick-search input[name="nimi"] {
    flex: 3 !important;
  }
  
  #quick-search button[type="submit"] {
    flex: 1 !important;
    padding: 0.875rem 0.5rem !important;
  }
  
  /* Compact responsive table for mobile */
  .search-results-table {
    font-size: 0.8rem;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .search-results-table thead {
    display: none;
  }
  
  .search-results-table tbody {
    display: block;
  }
  
  .search-results-table tbody tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.25rem 0.5rem;
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
  }
  
  .search-results-table tbody tr:nth-child(even) {
    background-color: rgba(0, 0, 0, 0.15);
  }
  
  html.light-theme .search-results-table tbody tr:nth-child(even) {
    background-color: rgba(0, 0, 0, 0.02);
  }
  
  .search-results-table td {
    padding: 0.25rem 0;
    font-size: 0.8rem;
  }
  
  .search-results-table td:first-child {
    grid-column: 1 / -1;
    font-weight: 600;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.25rem;
  }
  
  .search-results-table td:not(:first-child):before {
    content: attr(data-label) ": ";
    font-weight: 600;
    color: var(--muted);
    font-size: 0.75rem;
  }
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--border);
}

.tab-button {
  padding: 0.75rem 1.5rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}

.tab-button:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.05);
}

.tab-button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

@media (max-width: 768px) {
  .tab-button {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }
}
