/* -----------------------------------------
   Global theme — minimal black/white + saffron
------------------------------------------ */

:root {
  --bg: #0f172a;
  /* Slate 900 */
  --text: #f1f5f9;
  /* Slate 100 */
  --text-soft: #cbd5e1;
  /* Slate 300 - Improved contrast */
  --border: #334155;
  /* Slate 700 */
  --accent: #DFAF2B;
  --accent-soft: #1e293b;
  /* Slate 800 - replacing yellow tint with card bg color */
  --radius: 12px;
  --sidebar-width: 260px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Inter", sans-serif;
}

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  line-height: 1.6;
}

/* -----------------------------------------
   Sidebar
------------------------------------------ */

header {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  background: var(--bg);
  color: var(--text);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 1.2rem 1.2rem 1.6rem 1.2rem;
  border-right: 1px solid var(--border);
}

.app-title {
  font-weight: normal;
  font-size: 1.9rem;
  letter-spacing: -0.05em;
  color: var(--text);
  margin-top: 1rem;
  margin-bottom: 2rem;
  line-height: 1.2;
  /* Match menu alignment */
  padding-left: 10px;
  border-left: none;
}

nav {
  width: 100%;
  text-align: left;
  display: flex;
  flex-direction: column;
  margin-top: auto;
  padding-top: 1rem;
  margin-bottom: 2rem;
}

nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

nav ul li {
  margin: 0.25rem 0;
}

nav ul li a {
  text-decoration: none;
  color: var(--text-soft);
  font-weight: 500;
  font-size: 1rem;
  display: block;
  padding: 0.4rem 0 0.4rem 10px;
  border-left: 3px solid transparent;
  transition: color 0.18s ease, border-color 0.18s ease, transform 0.1s ease;
}

nav ul li a:hover {
  color: var(--text);
  border-left-color: var(--accent);
  transform: translateX(2px);
}

nav ul li strong {
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1rem;
  display: block;
  padding: 0.4rem 0 0.4rem 10px;
  border-left: 3px solid var(--accent);
}

/* -----------------------------------------
   Content area
------------------------------------------ */

.content-wrapper {
  margin-left: var(--sidebar-width);
  flex-grow: 1;
  min-height: 100vh;
  background-color: var(--bg);
  display: block;
  padding: 3rem 4rem 3rem 4rem;
}

main {
  max-width: 1100px;
  width: 100%;
  background-color: transparent;
  min-height: 100vh;
}

.content-padding {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding-top: 0;
}

/* Sovellus1:n h1 on referenssi */
h1 {
  font-size: 2.5rem;
  margin-top: 0;
  margin-bottom: 1.3rem;
  letter-spacing: -0.04em;
  font-weight: 800;
}

/* -----------------------------------------
   Täsmällinen linjaus muille sivuille
------------------------------------------ */

.page-default h1 {
  margin-top: 1.4rem;
  margin-left: 0.85rem;
}

.page-default .content-padding {
  padding-left: 0.85rem;
}

/* Tasaa leipätekstit otsikon (h1) kanssa */
.page-default .content-padding>p,
.page-default .content-padding>h2,
.page-default .content-padding>h3,
.page-default .content-padding>ul,
.page-default .content-padding>ol,
.page-default .content-padding>dl,
.page-default .content-padding>blockquote,
.page-default .content-padding>.blog-post {
  margin-left: 0.85rem;
}

p {
  font-size: 1.05rem;
  color: var(--text-soft);
  line-height: 1.7;
}

/* -----------------------------------------
   Blog content
------------------------------------------ */

.blog-post {
  margin-bottom: 4rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.date {
  color: var(--accent);
  font-size: 1rem;
  margin-bottom: 0.4rem;
}

.blog-post h2 {
  font-size: 1.6rem;
  margin-top: 0.3rem;
  margin-bottom: 0.6rem;
}

.date+h2 {
  margin-top: 0.3rem;
}

.content-padding a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.content-padding a:hover {
  text-decoration: underline;
}

/* -----------------------------------------
   FAVORITES – musta + bold, ei alaviivaa
------------------------------------------ */

.favorite-name {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

/* -----------------------------------------
   SAMPLELISTA – lopullinen, toimiva korjaus
------------------------------------------ */

#sample-list a {
  color: var(--text) !important;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--text);
  cursor: pointer;
}

#sample-list a:hover {
  text-decoration-color: var(--accent);
}

/* -----------------------------------------
   Laskuri-sivun korjaukset
------------------------------------------ */

.favorite-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  grid-template-rows: auto auto;
  gap: 0.35rem 0.45rem;
  padding: 0.6rem 0.5rem;
  border-radius: 10px;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  align-items: center;
  margin-bottom: 0.35rem;
}

.favorite-name {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.25;
  grid-column: 1 / 2;
  grid-row: 1 / 2;
}

.favorite-amount {
  grid-column: 1 / 2;
  grid-row: 2 / 3;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.favorite-fiber {
  grid-column: 2 / 3;
  grid-row: 1 / 2;
}

.favorite-cal {
  grid-column: 3 / 4;
  grid-row: 1 / 2;
}

.favorite-row .danger-button {
  grid-column: 4 / 5;
  grid-row: 1 / 2;
}

.amount-input {
  width: 80px;
  font-size: 0.95rem;
  padding: 0.45rem 0.6rem;
  box-sizing: border-box;
}

/* -----------------------------------------
   Kuitutavoite-otsikko ja pudotusvalikko
------------------------------------------ */

.summary-subtitle {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 1.2rem;
  margin-bottom: 0.4rem;
  color: var(--text);
}

.styled-select {
  appearance: none;
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 2rem 0.5rem 0.8rem;
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--text);
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23555' stroke-width='2' fill='none' fill-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  background-size: 12px 8px;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.styled-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* -----------------------------------------
   Responsive
------------------------------------------ */

@media (max-width: 900px) {
  header {
    display: none;
  }

  .content-wrapper {
    margin-left: 0;
    padding: 2rem 1.5rem;
  }

  main {
    max-width: 100%;
  }

  .content-padding {
    max-width: 100%;
  }

  h1 {
    font-size: 2.1rem;
  }
}

.app-title {
  font-size: 1.85rem;
  font-weight: 600;
}

.app-title-com {
  color: #F4D03F;
  font-size: 1.85rem;
  font-weight: 600;
}

/* -----------------------------------------
   LOGO FIX — override header + app-title
------------------------------------------ */

.app-title .app-title-com {
  color: var(--accent) !important;
  font-size: 1.85rem;
  font-weight: 600;
}

header .app-title .app-title-com {
  color: var(--accent) !important;
}

/* -----------------------------------------
   Shared UI Components (Buttons, Inputs)
------------------------------------------ */

/* Primary Button (Saffron) - Matches kuitulaskuri.css */
.primary-button {
  background: var(--accent);
  color: #1a1304;
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: 0 4px 6px -1px rgba(223, 175, 43, 0.2), 0 2px 4px -1px rgba(223, 175, 43, 0.1);
  cursor: pointer;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.7rem 1.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  min-width: 140px;
  text-decoration: none;
  /* In case it's an anchor */
}

.primary-button:hover {
  background: #B8871F !important;
  /* var(--accent-strong) manually resolved if variable issues occur, but var is better */
  background: var(--accent) !important;
  /* Using a slightly darker shade via filter/var */
  filter: brightness(0.95);
  transform: translateY(-1px);
  box-shadow: 0 6px 8px -1px rgba(223, 175, 43, 0.3);
  color: #1a1304;
  text-decoration: none;
}

.primary-button:active {
  transform: translateY(1px);
}

/* Base Input Style */
input[type="text"],
input[type="email"],
input[type="number"],
textarea {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,

/* -----------------------------------------
   Light Mode Overrides (Global)
------------------------------------------ */
body.light-mode {
  --bg: #ffffff;
  --text: #0f172a;
  /* Slate 900 */
  --text-soft: #475569;
  /* Slate 600 */
  --border: #e2e8f0;
  /* Slate 200 */
  --accent-soft: #f8fafc;
  /* Very light cool grey */

  /* Kuitulaskuri / SpotVaiFix Specific Overrides */
  --k-bg: #ffffff;
  --k-card: #ffffff;
  --k-card-alt: #f8fafc;
  --k-text: #111111;
  --k-text-soft: #555555;
  --k-border: #e2e8f0;
  --fixed-blue: #3b82f6;
}

body.light-mode header {
  background: #f8fafc;
  border-right-color: #e2e8f0;
}

body.light-mode .content-wrapper {
  background: #ffffff;
}

/* Ensure inputs stand out in light mode */
body.light-mode input,
body.light-mode select,
body.light-mode textarea {
  background: #ffffff;
  border-color: #cbd5e1;
  color: var(--text);
}

/* Kuitulaskuri / SpotVaiFix specials (if mapped to global vars) */
body.light-mode .fiber-app-shell {
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 14%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

body.light-mode .card,
body.light-mode .sample-card,
body.light-mode .chart-card {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

body.light-mode .result-box,
body.light-mode .favorite-row,
body.light-mode .selected-simple {
  background: #f8fafc;
  /* Alternate light bg */
}

/* Ensure dark mode-like contrast for header is reset */
body.light-mode .app-title,
body.light-mode h1,
body.light-mode h2,
body.light-mode h3 {
  color: #0f172a;
}