/* css/style.css - Lõplik parandatud versioon */

:root {
    --primary-blue: #005e87;
    --secondary-blue: #0079a7;
    --primary-font: 'Roboto', sans-serif;
}

body {
    background-color: #f0f2ff;
    font-family: var(--primary-font);
}

/* --- NAVIGATSIOONIRiba STIILID --- */
.main-navigation { background-color: var(--primary-blue); border-bottom: 1px solid var(--secondary-blue); }
.navbar-toggler { border-color: rgba(255, 255, 255, 0.25); }
.navbar-toggler:focus { box-shadow: 0 0 0 0.25rem rgba(255, 255, 255, 0.3); }
.main-navigation .nav-link { color: #ffffff; opacity: 0.9; font-weight: bold; border-radius: 4px; padding: 0.75rem 1rem; display: flex; align-items: center; }
.main-navigation .nav-link i { font-size: 1.2rem; margin-right: 15px; width: 25px; text-align: center; }
.main-navigation .nav-link.active { background-color: #ffffff; color: var(--primary-blue); opacity: 1; }
.main-navigation .nav-link:hover, .main-navigation .nav-link:focus {
    background-color: #ffffff;
    color: var(--primary-blue);
    opacity: 1;
}

@media (max-width: 991.98px) { .main-navigation .navbar-nav { padding-top: 0.5rem; } }
@media (min-width: 992px) {
    .main-navigation .nav-item { border-left: 1px solid var(--secondary-blue); padding: 0.5rem 1.25rem; }
    .main-navigation .nav-item:last-child { border-right: 1px solid var(--secondary-blue); }
    .main-navigation .nav-link { flex-direction: column; text-align: center; padding: 0.5rem; }
    .main-navigation .nav-link i { font-size: 2rem; margin-right: 0; margin-bottom: 0.25rem; }
    .main-navigation .nav-link:hover, .main-navigation .nav-link:focus {
    background-color: #ffffff;
    color: var(--primary-blue);
    opacity: 1;
}
}
@media (max-width: 991.98px) {
    .main-navigation .navbar-nav {
        padding-top: 0.5rem;
    }
    .main-navigation .nav-item {
        margin-bottom: 0.25rem; /* Väike vahe linkide vahele */
    }
}

/* --- BÄNNERI STIIL --- */
.hero-banner { background-color: var(--primary-blue); color: white; padding: 3rem 1rem; clip-path: polygon(0 0, 100% 0, 100% 80%, 0 100%); }
.hero-title { font-size: 3.5rem; font-weight: 900; text-transform: uppercase; letter-spacing: 2px; }
.hero-subtitle { font-size: 2rem; font-weight: 700; margin-top: -10px; }

@media (max-width: 768px) {
    .hero-banner { padding: 2rem 1rem; clip-path: polygon(0 0, 100% 0, 100% 90%, 0 100%); }
    .hero-title { font-size: 2.2rem; word-break: break-word; }
    .hero-subtitle { font-size: 1.5rem; }
}
@media (max-width: 400px) {
    .hero-title { font-size: 1.8rem; }
    .hero-subtitle { font-size: 1.1rem; }
}

/* --- POSTITUSTE STIILID --- */
.post-card { border: none; transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out; }
.post-card:hover { transform: translateY(-5px); box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important; }
.card-img-top { width: 100%; height: 200px; object-fit: cover; }
.card-text-content { max-height: 100px; overflow: hidden; transition: max-height 0.5s ease-in-out; position: relative; }
.card-text-content.expanded { max-height: 300px; overflow-y: auto; }
.card-text-content.is-truncated:not(.expanded)::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 30px; background: linear-gradient(to top, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0)); }
.read-more-link { cursor: pointer; color: var(--secondary-blue); font-weight: bold; text-decoration: none; display: inline-block; margin-top: 10px; }
.read-more-link:hover { text-decoration: underline; color: var(--primary-blue); }

/* --- NUPPUDE STIILID --- */
.btn-info {
    background-image: linear-gradient(0deg, var(--primary-blue), var(--secondary-blue));
    border: none;
    color: white;
    font-weight: bold;
    transition: opacity 0.2s;
}
.btn-info:hover {
    opacity: 0.9;
    color: white;
}

.btn-primary {
    background-color: white !important;
    color: var(--primary-blue) !important;
    border: 2px solid var(--primary-blue) !important;
    font-weight: bold;
    transition: all 0.2s ease-in-out;
}

.btn-primary:hover, .btn-primary:active, .btn-primary:focus {
    background-color: #f0f2f5 !important;
    color: var(--primary-blue) !important;
    border-color: var(--primary-blue) !important;
}

/* --- JALUSE STIILID --- */
.social-icon { margin: 0 15px; font-size: 1.5rem; color: var(--primary-blue); transition: color 0.2s; }
.social-icon:hover { color: var(--secondary-blue); }

#scrollTopBtn {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 30px;
    z-index: 99;
    border: none;
    outline: none;
    background-color: var(--primary-blue);
    color: white;
    cursor: pointer;
    padding: 15px;
    border-radius: 10px;
    font-size: 18px;
    transition: background-color 0.3s;
}
#scrollTopBtn:hover {
    background-color: var(--secondary-blue);
}

/* --- Ostukorvi lehe stiilid --- */
.price-table-wrapper {}

.price-table {
    font-size: 0.9rem;
    background-color: #ffffff;
}
.price-table a { font-weight: bold; text-decoration: none; color: #212529; }
.price-table a:hover { text-decoration: underline; }


/* Kleepuv päis ja esimene veerg (suurele ekraanile) */
.price-table thead th {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 10;
}

.price-table th:first-child,
.price-table td:first-child {
    position: -webkit-sticky;
    position: sticky;
    left: 0;
}

.price-table td:first-child {
    background-color: #ffffff;
    z-index: 5;
}

.price-table th:first-child {
    z-index: 11;
}

/* Värvilised päised */
.price-table .cell-selver { background-color: #ffc107; color:white; }
.price-table .cell-barbora { background-color: #0d6efd; color:white; }
.price-table .cell-rimi { background-color: #dc3545; color:white; }
.price-table .cell-prisma { background-color: #198754; color:white; }
.price-table .cell-coop { background-color: #0dcaf0; color:white; }

.price-table .discount-row { background-color: #6c757d; color: white; }
.price-table .product-name { min-width: 250px; font-weight: bold; }
.price-table th, .price-table td { vertical-align: middle; }
.product-thumbnail { width: 40px; height: 40px; object-fit: contain; margin-right: 10px; float: left; }

/* Vana hinna hüpikakna stiilid */
.old-price-trigger { font-size: 0.8rem; color: #6c757d; cursor: pointer; position: relative; display: block; margin-top: 5px; }
.old-price-popup { display: none; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); padding: 0; border-radius: 5px; box-shadow: 0 4px 8px rgba(0,0,0,0.2); width: 160px; z-index: 100; text-align: center; }
.old-price-trigger:hover .old-price-popup { display: block; }
.old-price-popup .popup-header { color: white; padding: 5px; border-radius: 5px 5px 0 0; }
.old-price-popup .popup-header .store-name { font-weight: bold; display: block; }
.old-price-popup .popup-header .date { font-size: 0.8em; }
.old-price-popup .popup-price { font-size: 1.2rem; font-weight: bold; padding: 5px; background: white; color: #212529; }
.old-price-popup .popup-change { font-weight: bold; padding: 5px; border-radius: 0 0 5px 5px; color: white; }
.price-up { background-color: #dc3545; }
.price-down { background-color: #198754; }
.price-neutral { background-color: #6c757d; }

/* Tarbijamängu lisamise vormi pildi eelvaate stiilid */
.image-preview-box { min-height: 300px; display: flex; align-items: center; justify-content: center; transition: background-color 0.2s; }
.image-preview-box:hover { background-color: #f8f9fa; }
.image-preview-box img { max-height: 300px; width: auto; }


/* === TÄIUSTATUD MOBIILIVAADE (kuni 768px) === */
@media (max-width: 768px) {
    .price-table thead { display: none; }
    .price-table th:first-child, .price-table td:first-child { position: static; }

    .price-table tbody tr, .price-table tfoot tr {
        display: block;
        border: 1px solid #ddd;
        border-radius: 5px;
        overflow: hidden;
        margin-bottom: 1rem;
    }
    .price-table tr:last-child { margin-bottom: 0; }

    .price-table td, .price-table tfoot th {
        display: block;
        border-bottom: 1px solid #eee;
        box-sizing: border-box;
    }
    .price-table tr > *:last-child { border-bottom: none; }

    /* Kaardi päis: Tootenimi koos pildiga */
    .price-table tbody td:first-child {
        display: flex;
        align-items: center;
        background-color: #f8f9fa;
        font-weight: bold;
        font-size: 1.1rem;
        padding: 0.75rem;
    }
    .price-table tbody td:first-child .product-thumbnail {
        float: none;
        flex-shrink: 0;
    }
    
    /* Kaardi päis: "KOKKU" read */
    .price-table tfoot th:first-child {
        background-color: #f8f9fa;
        font-weight: bold;
        font-size: 1.1rem;
        padding: 0.75rem;
    }

    /* Hinnaread - siin rakendub data-label */
    .price-table *[data-label] {
        display: flex;
        align-items: baseline;
        position: relative;
        padding: 0.75rem 0.75rem 0.75rem 125px;
        min-height: 45px;
    }

    /* Poe nime plokk */
    .price-table *[data-label]::before {
        content: attr(data-label);
        position: absolute;
        left: 0; top: 0; bottom: 0;
        width: 110px;
        font-weight: bold;
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Vana hinna stiil */
    .price-table .old-price-trigger {
        display: inline;
        margin-left: auto;
        padding-left: 1rem;
        font-style: italic;
        color: #6c757d;
        text-decoration: none;
        font-size: 0.95em;
        cursor: pointer;
    }
    
    .price-table .old-price-popup {
        text-align: left;
        width: 140px;
        font-size: 0.9em;
    }
    .price-table .old-price-popup .popup-price {
        font-size: 1.1em;
        padding: 4px;
    }
    .price-table .old-price-popup .popup-header,
    .price-table .old-price-popup .popup-change {
        padding: 4px;
    }


    /* Poe nimede sildid ja värvid (PÕHIOSA JA JALUS) */
    .price-table *[data-label="Selver"]::before { background-color: #ffc107; color: white; }
    .price-table *[data-label="Barbora"]::before { background-color: #0d6efd; }
    .price-table *[data-label="Rimi"]::before { background-color: #dc3545; }
    .price-table *[data-label="Prisma"]::before { background-color: #198754; }
    .price-table *[data-label="Coop"]::before { background-color: #0dcaf0; }
}