
/* ROOT VARIABLES */
:root {
  --primary: #e0243a;
  --primary-dark: #b01b2d;
  --bg: #f7f7fb;
  --text: #1f2430;
  --muted: #6b7280;
  --card-bg: #ffffff;
  --accent: #0f766e;
}

header {
    padding: 18px 6vw;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.lang-switch select {
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #ccc;
    background: #fff;
    font-size: 0.9rem;
    cursor: pointer;
}


/* RESET */
* {
  box-sizing: border-box;
  margin: 0;
}

/* BODY */
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.footer {
    display: flex;
    align-items: center;
    justify-content: center; /* ← keskelle */
    gap: 6px;
    margin-bottom: 0;
}


/* PAGE WRAPPER */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* HEADER */
header {
  padding: 8px 4vw;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 1.1rem;
}

.header-logo img {
  max-height: 42px;
}

/* BUTTONS */
.btn-primary,
.btn-outline {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
}

.btn-outline {
  border: 1px solid var(--primary);
  background: transparent;
  color: var(--primary);
}

/* TARJOUSPYYNNÖT-NAPPI HEADERIIN */
#requests-btn {
  margin-left: auto;
}

/* HERO */
.small-hero {
  padding: 6px 1vw 2px;
  text-align: left;
}

.small-hero h1 {
  font-size: clamp(1.6rem, 2.4vw, 2.1rem);
  margin-bottom: 4px;
}

.small-hero p {
  color: var(--muted);
  max-width: 520px;
  font-size: 0.9rem;
  margin-left: 4px;
}

/* CARDS */
.card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.card h2 {
  margin-bottom: 6px;
  font-size: 1.05rem;
}

.card label {
  display: block;
  margin-top: 6px;
  font-size: 0.85rem;
  font-weight: bold;
  color: #3b2323;
}

.card input,
.card select {
  width: 100%;
  padding: 6px 8px;
  margin-top: 3px;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  font-size: 0.9rem;
}

/* GRID LAYOUTS */
.pro-grid,
.request-grid {
  display: grid;
  gap: 9px;
  padding: 2px 1vw 5px;
}

/* DESKTOP GRID AREAS */
@media (min-width: 900px) {
  .pro-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "model customer"
      "accessories summary"
      "terms terms";
  }

  .request-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "model customer"
      "accessories summary";
  }

  #card-model       { grid-area: model; }
  #card-customer    { grid-area: customer; }
  #card-accessories { grid-area: accessories; }
  #card-summary     { grid-area: summary; }
  #card-terms       { grid-area: terms; }
}

/* ACCESSORY HEADER */
.accessory-header {
  display: grid;
  grid-template-columns: 24px 60px 1fr auto;
  padding: 6px 0;
  font-weight: 600;
  font-size: 0.85rem;
  border-bottom: 1px solid rgba(0,0,0,0.15);
}

/* ACCESSORY ROW */
.accessory-row {
  display: grid;
  grid-template-columns: 24px 60px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}


.accessory-row:last-child {
  border-bottom: none;
}

/* CHECKBOX */
.accessory-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

/* QTY BOX */
.qty-box {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 2px;
  width: 60px;
  min-width: 60px;
  max-width: 60px;
}

/* QTY BUTTONS */
.qty-btn {
  width: 18px;
  height: 22px;
  padding: 0;
  font-size: 12px;
  line-height: 1;
  text-align: center;
  border: 1px solid #ccc;
  background: #f2f2f2;
  cursor: pointer;
}

/* QTY INPUT */
.qty-input {
  width: 22px;
  height: 22px;
  padding: 0;
  text-align: center;
  border: 1px solid #ccc;
  font-size: 12px;
}

/* ACCESSORY NAME */
.accessory-row div:nth-child(3) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ACCESSORY PRICE */
.accessory-row div:nth-child(4) {
  text-align: right;
  font-weight: 600;
  white-space: nowrap;
}

/* SCROLLABLE CARDS */
@media (min-width: 900px) {
  #card-accessories,
  #card-summary {
    max-height: 360px;
    overflow-y: auto;
    padding-right: 4px;
  }
}

/* POPUPS */
#error-popup-overlay,
#success-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.45);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

#error-popup,
#success-popup {
  background: white;
  padding: 16px 20px;
  border-radius: 8px;
  width: min(90vw, 380px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.25);
}

#error-popup h3 { color: #b00000; }
#success-popup h3 { color: #008000; }

#error-popup-close,
#success-popup-close {
  padding: 8px 12px;
  background: #333;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  width: 100%;
  font-size: 0.85rem;
}

/* FOOTER */
footer {
  padding: 10px 4vw 14px;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}

footer img {
  max-height: 18px;
}
/* ================================
   DESKTOP OPTIMOINNIT (min-width:900px)
   ================================ */
@media (min-width: 900px) {

  /* --- 1) GRID-KORJAUS: TERMS EI KOKO LEVEYTTÄ --- */
  .pro-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "model customer"
      "accessories summary"
      "terms summary";   /* ennen: "terms terms" */
  }

  /* --- 2) MALLIN VALINTA + ASIAKASTIEDOT MATALAMMAKSI --- */
  #card-model,
  #card-customer {
    padding: 5px 5px;     /* pienempi sisäpadding */
  }

  #card-model h2,
  #card-customer h2 {
    margin-bottom: 4px;     /* pienempi otsikkoväli */
    font-size: 0.95rem;     /* hieman pienempi otsikko */
  }

  #card-customer label {
    margin-top: 1px;
    margin-bottom: 0px;
    font-size: 0.65rem;      /* pienempi label-teksti */
    font-weight: bold;
  }

  #card-customer input,
  #card-customer select {
    height: 20px;           /* matalampi input */
    padding: 2px 4px;
    font-size: 0.65rem;
  }

  /* --- 3) ACCESSORIES + SUMMARY KORKEAMMAKSI --- */
  #card-accessories,
  #card-summary {
    max-height: 460px;      /* aiemmin 360px */
    overflow-y: auto;
    padding-right: 4px;
  }

  /* --- 4) TERMS KOMPATKIMMAKSI JA EI LEVEÄMPI KUIN ACCESSORIES --- */
  #card-terms {
    max-height: 260px;
    overflow-y: auto;
  }

  /* --- 5) ACCESSORY-RIVIT KOMPATKIMMAKSI --- */
  .accessory-header,
  .accessory-row {
    padding: 4px 0;
    gap: 6px;
  }

  .qty-btn {
    height: 20px;
  }

  .qty-input {
    height: 20px;
    font-size: 12px;
  }
}
/* ================================
   KORKEUSRAJOITUKSET ISOLLE NÄYTÖLLE
   ================================ */
@media (min-width: 900px) {

  /* --- 1) Model + Customer max 40% näytön korkeudesta --- */
  #card-model,
  #card-customer {
    max-height: 70vh;
    overflow-y: auto;
    padding: 4px 4px; /* hieman kompaktimpi */
  }

  /* --- 2) Accessories + Summary yhteensä 60% näytön korkeudesta --- */
  #card-accessories,
  #card-summary {
    max-height: 80vh;
    overflow-y: auto;
    padding-right: 4px;
  }

  /* --- 3) Terms ei saa olla leveämpi kuin accessories --- */
  .pro-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "model customer"
      "accessories summary"
      "terms summary"; /* EI enää terms terms */
  }

  /* --- 4) Terms kompaktiksi (ei vie tilaa accessories+summary alueelta) --- */
  #card-terms {
    max-height: 110vh;
    overflow-y: auto;
  }

  /* --- 5) Rivien ja inputtien korkeus hieman pienemmäksi --- */
  #card-customer input,
  #card-customer select {
    height: 20px;
    padding: 2px 4px;
    font-size: 0.7rem;
  }

  .accessory-row,
  .accessory-header {
    padding: 4px 0;
  }

  .qty-btn {
    height: 20px;
  }

  .qty-input {
    height: 20px;
    font-size: 12px;
  }
}

/* Piilota menu bar kokonaan */
nav,
.menu,
.header-menu {
  display: none !important;
}
header {
  display: none !important;
}

/* --- PRO-OTSikon nappi viereen --- */
#pro-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

#pro-title-actions button {
    margin: 0;
    padding: 6px 12px;
    font-size: 0.7rem;
}



/* Lisävarusteiden tekstin optimointi */
.accessory-row div:nth-child(3) {
    font-size: 0.85rem;
    white-space: normal;
    line-height: 1.2;
}

.accessory-row {
    padding: 4px 0;
}
/* --- PRO-otsikko + nappi SalesEsy-tyyliin --- */

/* --- PRO-otsikko + nappi SalesEsy-tyyliin --- */
#pro-title {
    display: flex;
    align-items: center;
    gap: 14px;
    font-weight: 700;
}

#pro-title-actions {
    display: flex;
    align-items: center;
}

/* SalesEsy-tyylinen nappi */
.pro-requests-btn {
    padding: 6px 14px;
    background: #1f2937;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.pro-requests-btn {
    padding: 6px 14px;
    background: var(--primary); /* SalesEsy punainen */
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.pro-requests-btn:hover {
    background: var(--primary-dark); /* tummempi punainen */
}

/* --- SalesEsy-tyylinen H3 --- */
h3 {
    color: var(--primary-dark); /* tumma punainen teksti */
    background: rgba(224, 36, 58, 0.06); /* vaalea punainen tausta */
    padding: 6px 10px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 8px;
}


/* --- SalesEsy-tyylinen H2 --- */
h2 {
    color: var(--primary-dark); /* tumma punainen teksti */
    background: rgba(224, 36, 58, 0.06); /* vaalea punainen tausta */
    padding: 1px 12px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 1.15rem;
    margin-bottom: 10px;
}
/* --- SalesEsy Primary Button --- */
.btn-primary,
.pro-requests-btn {
    background: var(--primary);
    color: #fff;
    padding: 10px 20px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(224, 36, 58, 0.25);
    transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
    white-space: nowrap;
}

.btn-primary:hover,
.pro-requests-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(224, 36, 58, 0.3);
}
/* --- SalesEsy Outline Button --- */
.btn-outline {
    border-radius: 999px;
    border: 1px solid var(--primary);
    padding: 9px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary);
    background: transparent;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.btn-outline:hover {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 8px 20px rgba(224, 36, 58, 0.25);
}
/* --- Small SalesEsy Button --- */
.btn-small {
    background: var(--primary);
    color: #fff;
    padding: 6px 14px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.8rem;
    border: none;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}

.btn-small:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}


/* --- SalesEsy Primary Button --- */
.btn-primary,
.pro-requests-btn {
    background: var(--primary);
    color: #fff;
    padding: 10px 20px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(224, 36, 58, 0.25);
    transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
    white-space: nowrap;
}

.btn-primary:hover,
.pro-requests-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(224, 36, 58, 0.3);
}
/* --- SalesEsy-tyylinen H1 --- */
/* --- SalesEsy pill-tyylinen H1 (napin tyylillä) --- */
/* --- SalesEsy Premium H1 (napin tyylillä) --- */
h1 {
    background: #930011;
    color: #fff;
    padding: 5px 11px;
    border-radius: 10px;
    font-weight: 700;
    font-size: clamp(1.6rem, 2.4vw, 2.2rem);
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    cursor: default;
    box-shadow: 0 2px 12px rgba(224, 36, 58, 0.25);
    transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
    white-space: nowrap;
}


/* --- SalesEsy pill-tyylinen H2 punaisella pisteellä --- */
h2 {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 1px 12px;
    border-radius: 999px;
    background: rgba(224, 36, 58, 0.06);
    color: #090104;
    font-size: 1rem; /* hieman isompi kuin label, koska tämä on otsikko */
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 12px;
    width: fit-content; /* estää venymisen koko riville */
}

/* punainen piste h2:n alkuun */
h2::before {
    content: "";
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    display: inline-block;
}

/* Toggle label */
.view-toggle {
    display: inline-flex;       /* ei veny koko riville */
    width: fit-content;         /* palkki vain tekstin levyinen */
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--primary-dark);
    background: rgba(224, 36, 58, 0.06);
    padding: 4px 10px;
    border-radius: 999px;
    margin-bottom: 10px;
    cursor: pointer;
    margin-left: 15px;
}

.view-toggle input {
    transform: scale(1.2);
}

/* Kun body saa luokan .list-view → kaikki kortit allekkain */
body.list-view .pro-grid,
body.list-view .request-grid {
    display: block !important;
}

body.list-view .pro-grid > *,
body.list-view .request-grid > * {
    margin-bottom: 14px;
}
/* --- Lisävarusteiden - ja + napit SalesEsy-väreillä --- */
.qty-btn {
    width: 62px;
    height: 16px;
    padding: 0;
    font-size: 14px;
    line-height: 1;
    text-align: center;
    border: none;
    color: #fff;
    cursor: pointer;
    border-radius: 6px;
    font-weight: 700;
}

/* Miinusnappi = punainen */
.qty-btn.minus {
    background: var(--primary); /* SalesEsy punainen */
}

.qty-btn.minus:hover {
    background: var(--primary-dark);
}

/* Plusnappi = vihreä */
.qty-btn.plus {
    background: var(--accent); /* SalesEsy vihreä */
}

.qty-btn.plus:hover {
    background: #0c5f58; /* hieman tummempi vihreä */
}
/* Dimmaa lisävarusterivin, jos checkbox ei ole valittu */
.accessory-row input[type="checkbox"]:not(:checked) ~ div,
.accessory-row input[type="checkbox"]:not(:checked) ~ .qty-box {
    opacity: 0.70;
    pointer-events: none; /* estää klikkauksen qty-nappeihin */
}

/* Kun checkbox on valittu → rivi aktiivinen */
.accessory-row input[type="checkbox"]:checked ~ div,
.accessory-row input[type="checkbox"]:checked ~ .qty-box {
    opacity: 1;
    pointer-events: auto;
}
/* --- Lisävarusteet: fit-to-screen + max 70% screen height --- */
#card-accessories {
    width: 100%;            /* venyy koko käytettävissä olevan leveyden */
    max-height: 80vh;       /* enintään 70% näytön korkeudesta */
    overflow-y: auto;       /* scrollaa sisällön */
    padding-right: 6px;     /* pieni tila scrollbarille */
    box-sizing: border-box;
}
/* --- Uusi 3-rivin PRO / Request layout --- */
.pro-grid,
.request-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
    gap: 20px;
}

/* 1. rivi */
#card-model {
    grid-column: 1;
    grid-row: 1;
}

#card-picture {
    grid-column: 2;
    grid-row: 1;
}

/* 2. rivi */
#card-accessories {
    grid-column: 1;
    grid-row: 2;
}

#card-summary {
    grid-column: 2;
    grid-row: 2;
}

/* 3. rivi */
#card-customer {
    grid-column: 1;
    grid-row: 3;
}

#card-send-offer {
    grid-column: 2;
    grid-row: 3;
}
.needs-selection {
    border: 2px solid #ff9800;
    box-shadow: 0 0 10px rgba(255, 152, 0, 0.8);
    animation: glow 1.5s infinite alternate;
}

@keyframes glow {
    from {
        box-shadow: 0 0 6px rgba(255, 152, 0, 0.6);
    }
    to {
        box-shadow: 0 0 14px rgba(255, 152, 0, 1);
    }
}
.accessory-header,
.accessory-row {
  display: grid;
  grid-template-columns: 28px 80px auto 70px 80px;
  gap: var(--space-sm);
  align-items: center;
}


.hero-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 20px;
}

/* H1 max 30 %, mutta title-left saa kasvaa */
.title-left {
    display: flex;
    flex-direction: column;
    max-width: 30%;
}

/* H1 skaalautuu */
.title-left h1 {
    margin: 0;
    word-break: break-word;
    hyphens: auto;
}

/* pro-title-actions näkyy H1:n alla */
#pro-title-actions {
    margin-top: 4px;
    font-size: 0.9rem;
    color: #666;
}

/* kielivalitsin ei kutistu */
.lang-switch-inline {
    flex-shrink: 0;
}

.lang-switch-inline select {
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #ccc;
    background: #fff;
    font-size: 0.9rem;
    cursor: pointer;
}

/* Mobiilissa rivinvaihto */
@media (max-width: 600px) {
    .hero-title-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .title-left {
        max-width: 100%;
    }
}



/* ============================================================
   PRO-SIVUN OTSIKON LOPULLINEN, DETERMINISTINEN LAYOUT
   ============================================================ */

/* Otsikkorivi: H1 vasemmalle, kielivalitsin oikealle */
.hero-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 20px;
}

/* Vasemman puolen kontti: H1 + pro-title-actions */
.title-left {
    display: flex;
    flex-direction: column;
    max-width: 60%;
}

/* H1 saa rivittyä normaalisti (korjaa katoamisongelman) */
.title-left h1 {
    margin: 0;
    word-break: break-word;
    hyphens: auto;
    white-space: normal !important;   /* ← tärkein korjaus */
}

/* PRO-toiminnot H1:n alla */
#pro-title-actions {
    margin-top: 4px;
    font-size: 0.9rem;
    color: #666;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Kielivalitsin oikealle */
.lang-switch-inline {
    flex-shrink: 0;
}

.lang-switch-inline select {
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #ccc;
    background: #fff;
    font-size: 0.9rem;
    cursor: pointer;
}

/* Mobiilissa otsikko allekkain */
@media (max-width: 600px) {
    .hero-title-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .title-left {
        max-width: 100%;
    }
}
