/* =========================================================
   KotiApp – päätyylitiedosto
   ========================================================= */

/* ---- Variables ---- */
:root {
  --green-dark:   #2d4a22;
  --green-mid:    #3e6b30;
  --green-light:  #5a9044;
  --green-pale:   #eaf3e6;
  --brown:        #7a5c3a;
  --brown-light:  #f5efe6;
  --text:         #1e2a1a;
  --text-muted:   #6b7c63;
  --white:        #ffffff;
  --gray-100:     #f7f8f6;
  --gray-200:     #e8ebe5;
  --gray-300:     #cdd4c8;
  --danger:       #c0392b;
  --danger-light: #fdf0ef;
  --success:      #2e7d32;
  --success-light:#edf7ee;
  --info-light:   #e8f4fd;
  --radius:       10px;
  --shadow:       0 2px 12px rgba(0,0,0,.08);
  --shadow-lg:    0 6px 24px rgba(0,0,0,.13);
  --font:         'Segoe UI', system-ui, -apple-system, sans-serif;
  --nav-h:        60px;
}

/* ---- Reset & base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--gray-100);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--green-mid); text-decoration: none; }
a:hover { color: var(--green-dark); text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

code {
  background: var(--gray-200);
  padding: .15em .4em;
  border-radius: 4px;
  font-size: .9em;
}

/* ---- Navbar ---- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: var(--green-dark);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  border-radius: 6px;
  padding: .2rem .4rem;
  transition: background .15s;
}
.nav-brand:hover {
  background: rgba(255,255,255,.15);
  color: #fff;
  text-decoration: none;
}

.nav-icon { font-size: 1.4rem; }

/* Hampurilaisnappi – piilotettu oletuksena, näytetään mobiilissa */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 2.2rem;
  height: 2.2rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
}
.nav-toggle:hover { background: rgba(255,255,255,.15); }
.nav-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform .2s, opacity .2s;
}
/* Animaatio auki-tilassa */
.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.nav-links {
  display: flex;
  align-items: center;
  gap: .25rem;
}

.nav-link {
  color: rgba(255,255,255,.85);
  padding: .4rem .75rem;
  border-radius: 6px;
  font-size: .95rem;
  transition: background .15s;
  background: transparent;
  border: none;
  cursor: pointer;
  font: inherit;
  line-height: inherit;
}

.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,.15);
  color: #fff;
  text-decoration: none;
}

.nav-logout {
  background: rgba(180,30,30,.45) !important;
  color: #fff !important;
  margin-left: .25rem;
}
.nav-logout:hover { background: rgba(180,30,30,.7) !important; }

/* Mobiilinavigaatio */
@media (max-width: 700px) {
  .navbar {
    flex-wrap: wrap;
    height: auto;
    padding: 0.75rem 1rem;
  }
  .nav-toggle { display: flex; }
  .nav-links {
    display: none;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    padding: 0.5rem 0 0.25rem;
    gap: 0.1rem;
  }
  .nav-links.open { display: flex; }
  .nav-link { padding: .6rem .75rem; }
}

/* ---- Container ---- */
.container {
  flex: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1rem;
  width: 100%;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .55rem 1.2rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: .95rem;
  font-family: var(--font);
  font-weight: 600;
  transition: background .15s, transform .1s, box-shadow .15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }

.btn-primary   { background: var(--green-mid); color: #fff; }
.btn-primary:hover { background: var(--green-dark); color: #fff; }

.btn-secondary { background: var(--gray-200); color: var(--text); }
.btn-secondary:hover { background: var(--gray-300); color: var(--text); }

.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a93226; color: #fff; }

.btn-sm  { padding: .35rem .8rem; font-size: .85rem; }
.btn-xs  { padding: .2rem .55rem; font-size: .78rem; }
.btn-block { width: 100%; justify-content: center; }

/* ---- Alerts / Flash ---- */
.flash-messages { margin-bottom: 1rem; }

.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: .5rem;
  font-size: .95rem;
}

.alert-success { background: var(--success-light); border-left: 4px solid var(--success); color: #1b5e20; }
.alert-danger  { background: var(--danger-light);  border-left: 4px solid var(--danger);  color: var(--danger); }
.alert-info    { background: var(--info-light);    border-left: 4px solid #1976d2;        color: #0d47a1; }
.alert-warning { background: #fff8e1;              border-left: 4px solid #f9a825;        color: #6d4c00; }

/* ---- Login page ---- */
.login-page {
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green-mid) 60%, var(--brown) 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-wrapper { width: 100%; max-width: 420px; padding: 1rem; }

.login-card {
  background: var(--white);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow-lg);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-icon { font-size: 3rem; display: block; margin-bottom: .5rem; }

.login-header h1 {
  font-size: 1.8rem;
  color: var(--green-dark);
  margin-bottom: .25rem;
}

.login-header p { color: var(--text-muted); font-size: .95rem; }

/* ---- Forms ---- */
.form-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.form-group { margin-bottom: 1.25rem; }

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: .4rem;
  font-size: .9rem;
  color: var(--green-dark);
}

.form-control {
  width: 100%;
  padding: .6rem .85rem;
  border: 1.5px solid var(--gray-300);
  border-radius: 7px;
  font-family: var(--font);
  font-size: .95rem;
  color: var(--text);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--green-light);
  box-shadow: 0 0 0 3px rgba(90,144,68,.15);
}

textarea.form-control { resize: vertical; min-height: 120px; }

.form-control-file {
  display: block;
  width: 100%;
  padding: .5rem;
  font-size: .9rem;
  color: var(--text-muted);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-hint {
  font-size: .8rem;
  color: var(--text-muted);
  font-weight: 400;
}

.form-error {
  color: var(--danger);
  font-size: .82rem;
  display: block;
  margin-top: .25rem;
}

.form-actions {
  display: flex;
  gap: .75rem;
  margin-top: 1.5rem;
}

/* ---- Hero ---- */
.hero {
  background: linear-gradient(135deg, var(--green-dark), var(--green-mid));
  border-radius: 16px;
  padding: 3rem 2rem;
  margin-bottom: 2.5rem;
  color: #fff;
}

.hero-content h1 { font-size: 2rem; margin-bottom: .5rem; }
.hero-subtitle { font-size: 1.05rem; opacity: .85; margin-bottom: 1.5rem; }
.hero-content .btn { margin-right: .5rem; margin-bottom: .5rem; }
.hero .btn-secondary { background: rgba(255,255,255,.2); color: #fff; }
.hero .btn-secondary:hover { background: rgba(255,255,255,.3); }

/* ---- Section ---- */
.section { margin-bottom: 2rem; }
.section-title {
  font-size: 1.25rem;
  color: var(--green-dark);
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 2px solid var(--green-pale);
}

/* ---- Page header ---- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-header h1 { font-size: 1.6rem; color: var(--green-dark); }

/* ---- Entry cards (grid view) ---- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.entry-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow .2s, transform .2s;
}

.entry-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }

.entry-card-img img {
  width: 100%;
  height: 180px;
  object-fit: cover;
}

.entry-card-body { padding: 1rem; flex: 1; display: flex; flex-direction: column; gap: .4rem; }

/* ---- Entry list (logbook view) ---- */
.entry-list { display: flex; flex-direction: column; gap: 1rem; }

.entry-row {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  gap: 1rem;
  overflow: hidden;
  transition: box-shadow .2s;
}

.entry-row:hover { box-shadow: var(--shadow-lg); }

.entry-row-thumb { flex-shrink: 0; width: 140px; }
.entry-row-thumb img { width: 140px; height: 100%; object-fit: cover; }
.entry-row-body { padding: 1rem; flex: 1; display: flex; flex-direction: column; gap: .4rem; }

/* ---- Entry shared ---- */
.entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  font-size: .82rem;
  color: var(--text-muted);
}

.entry-author { font-weight: 600; color: var(--green-dark); }

.entry-badge-new {
  display: inline-block;
  background: #38a169;
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  padding: .1rem .4rem;
  border-radius: 999px;
  margin-left: .25rem;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e53e3e;
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  min-width: 1.1rem;
  height: 1.1rem;
  border-radius: 999px;
  padding: 0 .25rem;
  margin-left: .3rem;
  vertical-align: middle;
  line-height: 1;
}

.uusia-info {
  font-size: .85rem;
  color: #4a5568;
  margin-bottom: 1rem;
  padding: .5rem .75rem;
  background: #f0fff4;
  border-left: 3px solid #38a169;
  border-radius: 0 4px 4px 0;
}

.entry-weather {
  background: var(--green-pale);
  color: var(--green-dark);
  padding: .1rem .5rem;
  border-radius: 99px;
  font-size: .8rem;
}

.entry-title { font-size: 1.05rem; }
.entry-title a { color: var(--text); }
.entry-title a:hover { color: var(--green-mid); text-decoration: none; }

.entry-excerpt { color: var(--text-muted); font-size: .9rem; flex: 1; }
.entry-activities { font-size: .85rem; color: var(--brown); }

.entry-footer {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  margin-top: .25rem;
}

.comment-count { font-size: .85rem; color: var(--text-muted); }

/* ---- Full entry ---- */
.entry-full {
  background: var(--white);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

.entry-full-header { margin-bottom: 1.5rem; }
.entry-full-header h1 { font-size: 1.8rem; color: var(--green-dark); margin-bottom: .5rem; }

.entry-image {
  margin: 1.5rem 0;
  border-radius: var(--radius);
  overflow: hidden;
  max-height: 500px;
}

.entry-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.entry-body {
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--text);
  word-break: break-word;
}

.entry-body p {
  margin: 0 0 1rem 0;
}

.entry-body p:last-child {
  margin-bottom: 0;
}

.entry-actions { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--gray-200); }

/* ---- Comments ---- */
.comments-section {
  background: var(--white);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.comment-list { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 2rem; }

.comment {
  background: var(--gray-100);
  border-radius: 8px;
  padding: .85rem 1rem;
  border-left: 3px solid var(--green-pale);
}

.comment-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .4rem;
  flex-wrap: wrap;
}

.comment-author { color: var(--green-dark); font-size: .9rem; }
.comment-date { font-size: .8rem; color: var(--text-muted); }
.comment-body { font-size: .95rem; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }

.comment-form-wrapper {
  border-top: 1px solid var(--gray-200);
  padding-top: 1.5rem;
  margin-top: 1rem;
}

.comment-form-wrapper h3 { margin-bottom: 1rem; font-size: 1.05rem; color: var(--green-dark); }

/* ---- Admin table ---- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

.data-table th {
  background: var(--green-pale);
  color: var(--green-dark);
  text-align: left;
  padding: .65rem 1rem;
  font-weight: 700;
  border-bottom: 2px solid var(--gray-300);
}

.data-table td {
  padding: .6rem 1rem;
  border-bottom: 1px solid var(--gray-200);
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--gray-100); }

.badge {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 99px;
  font-size: .78rem;
  font-weight: 600;
  background: var(--gray-200);
  color: var(--text-muted);
}

.badge-admin { background: var(--green-pale); color: var(--green-dark); }
.badge-mod   { background: #d4e8b0; color: #3a5a10; }

/* ---- Pagination ---- */
.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.5rem; }

/* Poistetaan number-kentän nuolet kaikissa selaimissa */
.pagination input[type=number]::-webkit-inner-spin-button,
.pagination input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.pagination input[type=number] { -moz-appearance: textfield; }

.page-info { color: var(--text-muted); font-size: .9rem; }

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-icon { font-size: 3rem; display: block; margin-bottom: 1rem; }
.empty-state h1 { font-size: 3rem; color: var(--green-dark); }
.empty-state p { margin-bottom: 1rem; font-size: 1.05rem; }

/* ---- Footer ---- */
.footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: .85rem;
  border-top: 1px solid var(--gray-200);
  background: var(--white);
}

/* ---- Utilities ---- */
.text-center { text-align: center; }
.text-muted   { color: var(--text-muted); }
.mt-2         { margin-top: 2rem; }

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
  .entry-row { flex-direction: column; }
  .entry-row-thumb { width: 100%; }
  .entry-row-thumb img { width: 100%; height: 200px; }
  .hero { padding: 2rem 1rem; }
  .hero-content h1 { font-size: 1.5rem; }
  .entry-full { padding: 1.25rem; }
  .comments-section { padding: 1.25rem; }
  .form-card { padding: 1.25rem; }
}

/* ---- Guide list ---- */
.guide-list { display: flex; flex-direction: column; gap: 0.75rem; }

.guide-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}

.guide-info { flex: 1; }

.guide-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .guide-item { flex-direction: column; }
  .guide-actions { width: 100%; }
}

/* ---- Galleria ---- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.gallery-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 8px;
  cursor: pointer;
  background: var(--border);
  outline-offset: 2px;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .25s;
  display: block;
}

.gallery-item:hover img,
.gallery-item:focus img { transform: scale(1.05); }

.gallery-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,.65));
  color: #fff;
  padding: 0.5rem 0.6rem 0.4rem;
  opacity: 0;
  transition: opacity .2s;
  display: flex;
  flex-direction: column;
}

.gallery-item:hover .gallery-overlay,
.gallery-item:focus .gallery-overlay { opacity: 1; }

.gallery-title { font-size: .8rem; font-weight: 600; line-height: 1.2; }
.gallery-date  { font-size: .7rem; opacity: .8; margin-top: .15rem; }

/* Lightbox */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.92);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.lightbox.open { display: flex; }

.lightbox-content {
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.lightbox-content img {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 6px;
  display: block;
}

.lightbox-caption {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.lightbox-title {
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  text-decoration: underline;
}
.lightbox-title:hover { color: #cfc; }
.lightbox-date { color: rgba(255,255,255,.6); font-size: .85rem; }

.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: fixed;
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  font-size: 1.8rem;
  cursor: pointer;
  border-radius: 50%;
  width: 2.8rem;
  height: 2.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  line-height: 1;
}
.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover { background: rgba(255,255,255,.3); }

.lightbox-close { top: 1rem; right: 1rem; font-size: 1.5rem; }
.lightbox-prev  { left: 1rem; top: 50%; transform: translateY(-50%); }
.lightbox-next  { right: 1rem; top: 50%; transform: translateY(-50%); }

/* ---- Useiden kuvien grid merkintänäkymässä ---- */
.entry-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.5rem;
  margin: 1rem 0;
}

.entry-image-thumb {
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 8px;
  cursor: pointer;
  background: var(--border);
}

.entry-image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .2s;
  display: block;
}

.entry-image-thumb:hover img,
.entry-image-thumb:focus img { transform: scale(1.05); }

/* ---- Sääennuste ---- */
.saa-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.saa-paiva {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.saa-paiva-otsikko {
  background: var(--green-dark);
  color: #fff;
  text-align: center;
  padding: 0.4rem 0.5rem;
  font-size: 0.9rem;
}

.saa-tunnit {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.saa-piste {
  display: grid;
  grid-template-columns: 2.8rem 1.6rem 3rem 3.2rem 3.5rem;
  align-items: center;
  gap: 0.2rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.78rem;
  border-bottom: 1px solid var(--border);
}

.saa-piste:last-child { border-bottom: none; }

.saa-aika      { color: var(--text-muted); font-size: 0.73rem; }
.saa-emoji     { font-size: 0.95rem; text-align: center; }
.saa-lampotila { font-weight: 600; }
.saa-tuuli     { color: var(--text-muted); font-size: 0.73rem; }
.saa-sade      { color: #2980b9; font-size: 0.73rem; }

.saa-container-alarivi { margin-top: 0.75rem; }


.saa-lahde {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.saa-virhe {
  padding: 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---- Dark mode ---- */
:root {
  --card-bg: var(--white);
  --border:  var(--gray-200);
}

/* ---- Teema: Meriteema (Navy) ---- */
[data-theme="navy"] {
  --green-dark:  #1a3a5c;
  --green-mid:   #2563eb;
  --green-light: #3b82f6;
  --green-pale:  #eff6ff;
  --brown:       #1e40af;
  --text:        #0f172a;
  --text-muted:  #64748b;
  --gray-100:    #f0f4f8;
  --gray-200:    #e2e8f0;
  --gray-300:    #cbd5e1;
}

/* ---- Teema: Liuskekivi (Slate) ---- */
[data-theme="slate"] {
  --green-dark:  #1e293b;
  --green-mid:   #0ea5e9;
  --green-light: #38bdf8;
  --green-pale:  #f0f9ff;
  --brown:       #0284c7;
  --text:        #0f172a;
  --text-muted:  #64748b;
  --gray-100:    #f8fafc;
  --gray-200:    #e2e8f0;
  --gray-300:    #cbd5e1;
}

/* ---- Teema: Lämmin (Warm) ---- */
[data-theme="warm"] {
  --green-dark:  #7c3a2a;
  --green-mid:   #c2633a;
  --green-light: #d4845e;
  --green-pale:  #fdf1ec;
  --brown:       #92400e;
  --text:        #2c1810;
  --text-muted:  #78503e;
  --gray-100:    #fdf6f0;
  --gray-200:    #f5e6da;
  --gray-300:    #e8cdb8;
}

/* ---- Pimeä tila ---- */
[data-dark] {
  --gray-100:     #1a1a1a;
  --gray-200:     #2e2e2e;
  --gray-300:     #3d3d3d;
  --white:        #242424;
  --text:         #e8e8e8;
  --text-muted:   #9aa090;
  --green-pale:   #1c2e1a;
  --brown-light:  #2a2018;
  --danger-light: #3d1a18;
  --success-light:#182e1a;
  --info-light:   #1a2535;
  --card-bg:      #242424;
  --border:       #3d3d3d;
}

/* Pimeä tila + teema: green-pale per teema */
[data-dark][data-theme="navy"]  { --green-pale: #0f1f30; --text-muted: #8090a8; }
[data-dark][data-theme="slate"] { --green-pale: #0f1820; --text-muted: #8090a8; }
[data-dark][data-theme="warm"]  { --green-pale: #2a1510; --text-muted: #9a7868; }

/* ---- Responsiivisuus: piilotetaan saa mobiilissa ---- */
@media (max-width: 900px) {
  .saa-osio { display: none !important; }
}

/* ---- Luonto havainto -avainsanat (keyword chips) ---- */
.keyword-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
  min-height: 1.5rem;
}

.keyword-chip {
  background: var(--green-mid);
  color: var(--white);
  border-radius: 999px;
  padding: 0.2rem 0.75rem;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  user-select: none;
}

.keyword-chip .chip-remove {
  cursor: pointer;
  opacity: 0.75;
  font-size: 1rem;
  line-height: 1;
}

.keyword-chip .chip-remove:hover { opacity: 1; }

/* Näyttöchipit (lokikirja, view_entry, haku) */
.keyword-chip-display {
  background: var(--green-pale);
  color: var(--green-dark);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.8rem;
  display: inline-block;
}

/* Dropdown-valikko */
.keyword-input-wrapper {
  position: relative;
}

.keyword-dropdown {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 220px;
  overflow-y: auto;
}

.keyword-dropdown-item {
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text);
}

.keyword-dropdown-item:hover {
  background: var(--green-pale);
}

.keyword-dropdown-add {
  color: var(--green-mid);
  font-weight: 600;
  border-top: 1px solid var(--gray-200);
}

/* ---- Sisäilma-sivu ---- */
.sensor-current {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 1.5rem;
}

.sensor-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: 1.2rem 2rem;
  text-align: center;
  min-width: 140px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.sensor-card-sm {
  padding: 0.8rem 1.2rem;
  min-width: 100px;
}

.sensor-label {
  display: block;
  font-size: 0.82rem;
  color: var(--gray-600);
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.sensor-value {
  display: block;
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}

.sensor-value-sm {
  font-size: 1.6rem;
}

.sensor-updated {
  width: 100%;
  font-size: 0.8rem;
  color: var(--gray-400);
  margin: 0;
}

.sensor-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.sensor-controls-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.sensor-date-input {
  padding: 0.25rem 0.4rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.85rem;
}
.sensor-date-sep {
  color: #888;
}

.sensor-stats {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 0.7rem 1rem;
  font-size: 0.88rem;
  margin-bottom: 1.2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 2rem;
}

.sensor-charts {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.chart-wrapper {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 1rem 1.2rem;
}

.chart-wrapper h3 {
  margin: 0 0 0.6rem;
  font-size: 0.95rem;
  color: var(--gray-600);
}

/* ---- Järjestelmän tila ---- */
.jarjestelma-header {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.paivitettu-aika {
  font-size: 0.8rem;
  color: var(--gray-500, #888);
}

.jarjestelma-section {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 1.2rem 1.4rem;
  margin-bottom: 1.2rem;
}

.jarjestelma-section h2 {
  margin: 0 0 1rem;
  font-size: 1rem;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.jarjestelma-palvelut {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.jarjestelma-palvelu {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
}

.palvelu-ok  { background: #e8f5e9; color: #2e7d32; }
.palvelu-virhe { background: #ffebee; color: #c62828; }

.palvelu-ikoni { font-weight: 700; font-size: 1rem; }
.palvelu-tila  { font-size: 0.8rem; opacity: 0.8; }

.jarjestelma-levy {
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.levy-pct {
  font-weight: 700;
}

.levy-varoitus { color: #c62828; }
.sensori-varoitus { color: #c62828; }

.sensori-aika {
  font-size: 0.85rem;
  color: var(--gray-600);
  margin-top: 0.3rem;
}

.jarjestelma-backup {
  font-size: 1rem;
}

.backup-viimeksi {
  font-size: 0.85rem;
  color: var(--gray-600);
  margin-top: 0.3rem;
}

.varoitus-teksti {
  font-size: 0.85rem;
  font-weight: 600;
  color: #c62828;
  margin-top: 0.3rem;
}

.jarjestelma-ohjeet .ohjeet-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem 1.5rem;
}

.jarjestelma-ohjeet code {
  display: block;
  background: var(--gray-100);
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  font-size: 0.82rem;
  margin-top: 0.2rem;
  word-break: break-all;
}

@media (max-width: 600px) {
  .jarjestelma-ohjeet .ohjeet-grid { grid-template-columns: 1fr; }
}

/* ---- Teemavalitsin (asetukset) ---- */
.theme-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  border: 2px solid var(--gray-200);
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
  min-width: 80px;
}

.theme-option:hover {
  border-color: var(--gray-300);
  box-shadow: var(--shadow);
}

.theme-option:has(.theme-radio:checked) {
  border-color: var(--green-mid);
  box-shadow: 0 0 0 3px rgba(0,0,0,.06);
}

.theme-radio { display: none; }

.theme-swatch {
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,.08);
  display: block;
}

.theme-swatch-green { background: linear-gradient(135deg, #2d4a22 0%, #3e6b30 100%); }
.theme-swatch-navy  { background: linear-gradient(135deg, #1a3a5c 0%, #2563eb 100%); }
.theme-swatch-slate { background: linear-gradient(135deg, #1e293b 0%, #0ea5e9 100%); }
.theme-swatch-warm  { background: linear-gradient(135deg, #7c3a2a 0%, #c2633a 100%); }

.theme-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}
