/*
Theme Name:   Säkkisen Lattiakauppa
Theme URI:    https://sakkisenlattiakauppa.fi
Description:  Kustomoitu Child Theme GeneratePressille.
Author:       Sinun Nimesi
Template:     generatepress
Version:      3.1.0 (NETRAUTA REPLICA & GALLERY FIX)
*/

/* =========================================
   1. GLOBAL RESET & LAYOUT
   ========================================= */
* { box-sizing: border-box; }

body, html {
    overflow-x: hidden; margin: 0; padding: 0; width: 100%;
}
body {
    color: #333;
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; /* Netrauta-tyylinen fontti */
    line-height: 1.5;
}
a { color: #2c3e50; text-decoration: none; }

/* PAKOTETAAN TÄYSLEVEÄKSI MUTTA SÄILYTETÄÄN SIVUPALKKI */
body.woocommerce .grid-container,
body.woocommerce-page .grid-container {
    max-width: 100% !important;
    padding-left: 15px;
    padding-right: 15px;
}

/* Yleiset napit (Vihreä oletus) */
button, .button, .wp-block-button__link {
    background-color: #009e48 !important; /* Netrauta vihreä */
    color: #fff !important;
    padding: 10px 20px !important;
    border-radius: 2px !important; /* Terävämpi kulma */
    font-weight: 700 !important;
    text-transform: uppercase;
    font-size: 0.9em !important;
    border: none;
    transition: background 0.2s ease;
}
button:hover, .button:hover, .wp-block-button__link:hover {
    background-color: #007a37 !important;
}

/* =========================================
   2. HEADER
   ========================================= */
.site-header .inside-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 20px; gap: 20px;
}
.header-search-container { flex: 1; max-width: 700px; }
.woocommerce-product-search { display: flex; }
.woocommerce-product-search input[type="search"] {
    width: 100%; padding: 10px; border: 2px solid #e6e6e6; border-right: none;
    border-radius: 2px 0 0 2px; background: #fff;
}
.woocommerce-product-search button {
    border-radius: 0 2px 2px 0; background: #c0392b !important; /* Brändiväri hakuun */
    padding: 0 25px !important;
}
.header-tools { display: flex; gap: 20px; align-items: center; }
.header-icon svg { width: 24px; height: 24px; color: #333; }
.cart-count {
    position: absolute; top: -5px; right: -8px;
    background: #c0392b; color: #fff; font-size: 11px; font-weight: bold;
    width: 18px; height: 18px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}

/* =========================================
   3. ETUSIVU
   ========================================= */
.wp-block-cover {
    min-height: 450px !important; display: flex; align-items: center; justify-content: center; margin-bottom: 0 !important;
}
.wp-block-cover h1 {
    font-size: 2.8rem !important; font-weight: 800 !important; text-transform: uppercase;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5); margin-bottom: 15px !important; color: #fff !important; text-align: center;
}
/* USP Palkki */
.wp-block-columns.usp-section {
    background: #fff; margin-top: -40px !important; position: relative;
    z-index: 5; border-bottom: 2px solid #eee;
    max-width: 1200px; margin-left: auto !important; margin-right: auto !important;
    padding: 20px !important; box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}
.wp-block-columns.usp-section .wp-block-column { text-align: center; border-right: 1px solid #eee; }
.wp-block-columns.usp-section .wp-block-column:last-child { border-right: none; }
.wp-block-columns.usp-section h3 { font-size: 0.95rem; text-transform: uppercase; color: #000; font-weight: 700; margin: 0; }

/* Tuoteruudukot */
.home .wc-block-grid__products {
    display: grid !important; grid-template-columns: repeat(4, 1fr) !important;
    gap: 20px !important; margin-top: 40px; margin-bottom: 60px;
}
.home .wc-block-grid__product {
    background: #fff; border: 1px solid #eee; padding: 15px; text-align: center;
    width: auto !important; margin: 0 !important; transition: box-shadow 0.2s;
}
.home .wc-block-grid__product:hover { box-shadow: 0 5px 15px rgba(0,0,0,0.1); }
.home .wc-block-grid__product-image img {
    height: 200px !important; width: 100% !important; object-fit: contain !important;
    margin-bottom: 10px;
}
.home .wc-block-grid__product-title { font-size: 1rem; font-weight: 600; margin-bottom: 5px; color: #333; text-decoration: none; }
.home .wc-block-grid__product-price { color: #c0392b; font-weight: 700; font-size: 1.1rem; }
.home .wc-block-grid__product-add-to-cart { display: none; }

/* =========================================
   4. TUOTESIVU (NETRAUTA-TYYLI)
   ========================================= */

/* Piilotetaan vain tuplakuva, SIVUPALKKI NÄKYY */
.page-header-image-single { display: none !important; }

/* Desktop-asettelu: Sivupalkki + Tuotealue */
@media (min-width: 1000px) {
    /* Tuotealueen gridi */
    .single-product div.product {
        display: grid;
        /* Tiukempi jako: 45% kuva, 53% tiedot, 2% väli */
        grid-template-columns: 48% 48%; 
        gap: 4%; 
        align-items: start;
        margin-top: 20px;
    }

    .woocommerce-product-gallery { grid-column: 1 / 2; }
    .summary.entry-summary { grid-column: 2 / 3; }

    /* Alapuolen osiot valtaavat koko leveyden (myös sivupalkin alapuolelta jos mahdollista, mutta tässä gridissä tuotealueen sisällä) */
    .woocommerce-tabs, .related.products, section.related.products, .upsells {
        grid-column: 1 / -1 !important; 
        width: 100% !important; 
        margin-top: 40px; 
        clear: both; 
        display: block;
    }
}

/* --- GALLERIA (KOMPAKTI & REUNUSTETTU) --- */
.woocommerce-product-gallery {
    position: relative;
    margin-bottom: 0 !important; /* Poistetaan turha väli */
}

.woocommerce-product-gallery figure { margin: 0; }

/* PÄÄKUVA */
.woocommerce-product-gallery__image {
    margin: 0;
    border: 1px solid #e0e0e0; /* Netrauta-tyylinen reunus */
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.woocommerce-product-gallery__image img {
    width: 100% !important;
    height: auto !important;
    max-height: 500px; /* Rajoitetaan korkeus ettei kuva veny */
    object-fit: contain; /* Varmistaa kuvan näkymisen kokonaan */
    display: block;
}

/* PIKKUKUVAT (Thumbnails) */
.flex-control-nav.flex-control-thumbs {
    display: grid;
    grid-template-columns: repeat(5, 1fr); /* 5 vierekkäin kuten Netraudassa usein */
    gap: 10px;
    padding: 0;
    margin-top: 10px; /* Pieni väli pääkuvaan */
}

.flex-control-nav.flex-control-thumbs li {
    list-style: none; width: auto !important; margin: 0; float: none !important;
}

.flex-control-nav.flex-control-thumbs img {
    width: 100%;
    height: 60px; /* Pienet ja siistit */
    object-fit: cover;
    border: 1px solid #e0e0e0;
    border-radius: 2px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.flex-control-nav.flex-control-thumbs img.flex-active,
.flex-control-nav.flex-control-thumbs img:hover {
    border-color: #333; /* Tumma reunus aktiiviselle */
}

/* Suurennuslasi */
.woocommerce-product-gallery__trigger {
    position: absolute; bottom: 10px; right: 10px; top: auto;
    z-index: 99; background: #fff; border: 1px solid #ddd;
    width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
    border-radius: 2px;
}

/* --- TUOTEKORTIN TIEDOT (OIKEA PALSTA) --- */

h1.product_title { 
    font-size: 1.8rem; /* Hieman pienempi, tiukempi */
    margin-top: 0; 
    line-height: 1.2; 
    margin-bottom: 10px;
    font-weight: 700;
}

.product-mpn-text { 
    color: #666; font-size: 0.85rem; margin-bottom: 15px; 
}

/* Hinta isolla ja punaisella (tai brändivärillä) */
.price { 
    font-size: 1.8rem; 
    color: #c0392b; /* Hinta erottuu */
    font-weight: 800; 
    margin-bottom: 20px; 
    display: block;
    line-height: 1;
}
.price .price-secondary {
    font-size: 1rem; color: #666; font-weight: normal; margin-left: 5px;
}

/* Lyhyt kuvaus */
.woocommerce-product-details__short-description {
    font-size: 0.95rem;
    color: #444;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 20px;
}

/* LASKURI JA OSTOSKORI */
.product-calculator {
    background: #f5f5f5 !important; 
    padding: 20px !important; 
    border-radius: 2px;
    margin-bottom: 20px;
    border: 1px solid #eee;
}

.calc-row { margin-bottom: 15px !important; }
.calc-row label { font-weight: 700; font-size: 0.9rem; margin-bottom: 5px; display: block; }

.input-wrapper input { 
    padding: 8px !important; height: 40px; font-size: 1.1rem; width: 100%; border: 1px solid #ccc;
}
.unit-badge { 
    height: 40px; line-height: 40px; padding: 0 15px; background: #e0e0e0; font-weight: 600; border: 1px solid #ccc; border-left: none;
}

/* Hukkavara napit */
.waste-buttons { display: flex; gap: 5px; width: 100%; }
.waste-btn {
    flex: 1; padding: 5px 0 !important; font-size: 0.8rem !important;
    background: #fff !important; color: #333 !important; border: 1px solid #ccc !important;
    font-weight: 600 !important; box-shadow: none !important;
}
.waste-btn.active-waste {
    background: #333 !important; color: #fff !important; border-color: #333 !important;
}

/* Ostoskorinappi isolla */
.single_add_to_cart_button { 
    width: 100%; 
    background-color: #009e48 !important; /* Vihreä osto-nappi */
    margin-top: 15px; 
    padding: 15px !important; 
    font-size: 1.1rem !important; 
    border-radius: 2px !important;
}
.single_add_to_cart_button:hover { background-color: #007a37 !important; }

/* --- DOKUMENTIT & TEKNISET (NETRAUTA TABIT) --- */
.woocommerce-tabs ul.tabs {
    border-bottom: 2px solid #eee; padding: 0 !important; margin: 0 0 20px;
}
.woocommerce-tabs ul.tabs li {
    border: none !important; background: transparent !important; margin: 0 20px 0 0 !important;
    padding: 0 !important;
}
.woocommerce-tabs ul.tabs li a {
    padding: 10px 0 !important; font-weight: 700; color: #555; text-transform: uppercase; font-size: 0.9rem;
}
.woocommerce-tabs ul.tabs li.active a {
    color: #000; border-bottom: 2px solid #c0392b; /* Aktiivinen tabi */
}

/* --- RELATED PRODUCTS --- */
.related.products { margin-top: 50px; border-top: 1px solid #eee; padding-top: 30px; }
.related.products > h2 { font-size: 1.3rem; margin-bottom: 20px; text-transform: uppercase; }
.related.products ul.products {
    display: grid !important; grid-template-columns: repeat(4, 1fr) !important;
    gap: 15px !important; width: 100% !important;
}
.related.products ul.products li.product {
    width: auto !important; padding: 10px; border: 1px solid #eee; background: #fff; text-align: center;
}
.related.products ul.products li.product img {
    height: 160px !important; object-fit: contain !important; margin-bottom: 10px;
}
.related.products .price .price-secondary { display: none !important; }

/* =========================================
   7. MOBILE RESPONSIVENESS
   ========================================= */
@media (max-width: 768px) {
    .site-header .inside-header { flex-wrap: wrap; padding: 10px; }
    .header-search-container { order: 3; width: 100%; min-width: 100%; margin-top: 10px; }
    
    .single-product div.product { display: block; } /* Palauttaa mobiilin pinon */
    
    .related.products ul.products,
    .home .wc-block-grid__products {
        grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important;
    }
}