.tooted-container {
    width: 100%;
    max-width: 1225px; /* Maksimum laius */
    margin: 20px auto; /* Keskele joondamine */
    padding: 0 20px; /* Väike padding servadele */
    box-sizing: border-box;
}

.tooted-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 20px;
    opacity: 1;
    transition: opacity 0.3s ease;
    justify-items: center; /* Keskele joondab grid items */
}

@media (max-width: 1400px) {
    .tooted-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1200px) {
    .tooted-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .tooted-grid {
        grid-template-columns: 1fr;
    }
}

.toode-card {
    width: min(280px, calc((100vw - 140px) / 4)); /* Dünaamiline suurus, max 280px */
    height: min(280px, calc((100vw - 140px) / 4)); /* Sama kõrgus kui laius */
    position: relative;
    cursor: pointer;
    perspective: 1000px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 40px 8px 40px 8px; /* Muudetud: erisugused nurgad */
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
    margin: 0 auto;
    flex-shrink: 0;
}

/* 1225px konteineri jaoks optimeeritud suurused */
@media (min-width: 1226px) {
    .toode-card {
        width: 280px;
        height: 280px;
    }
}

@media (max-width: 1225px) and (min-width: 1001px) {
    .toode-card {
        width: min(260px, calc((100vw - 120px) / 4));
        height: min(260px, calc((100vw - 120px) / 4));
    }
}

@media (max-width: 1000px) and (min-width: 769px) {
    .toote-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .toode-card {
        width: min(240px, calc((100vw - 100px) / 3));
        height: min(240px, calc((100vw - 100px) / 3));
    }
}

@media (max-width: 768px) and (min-width: 481px) {
    .tooted-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .toode-card {
        width: min(220px, calc((100vw - 80px) / 2));
        height: min(220px, calc((100vw - 80px) / 2));
    }
}

@media (max-width: 480px) {
    .tooted-container {
        padding: 0 15px;
    }
    .toode-card {
        width: min(200px, calc(100vw - 70px));
        height: min(200px, calc(100vw - 70px));
    }
}

.toode-card:hover {
    transform: scale(1.02);
}

.toode-front,
.toode-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    transition: transform 0.8s ease;
    border-radius: 40px 8px 40px 8px; /* Muudetud: erisugused nurgad */
    display: flex;
    align-items: center;
    justify-content: center;
    top: 0;
    left: 0;
}

.toode-front {
    transform: rotateY(0deg);
  
    z-index: 2;
}

.toode-back {
    transform: rotateY(-180deg);
    background: rgba(0, 0, 0, 0.85);
    padding: min(40px, 12%); /* Proportionaalne padding */
    z-index: 1;
}

.toode-card.flipped .toode-front {
    transform: rotateY(180deg);
}

.toode-card.flipped .toode-back {
    transform: rotateY(0deg);
}

.toode-title {
    color: #ffffff;
    font-size: clamp(16px, 4vw, 22px); /* Skaleeruv font */
    font-weight: bold;
    text-align: center;
    margin: 0;
    padding: min(20px, 8%);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
    line-height: 1.2;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toode-content {
    text-align: center;
    color: #ffffff;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: min(20px, 8%);
    box-sizing: border-box;
}

.toode-description {
    font-size: clamp(12px, 3vw, 16px); /* Skaleeruv font */
    line-height: 1.4;
    margin-bottom: min(20px, 8%);
    color: #ffffff;
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.toode-button {
    display: inline-block;
    background-color: #e1dcb1;
    color: #15284b;
    padding: min(12px, 4%) min(24px, 8%);
    text-decoration: none;
    border-radius: 25px;
    font-weight: bold;
    font-size: clamp(12px, 3vw, 14px);
    transition: all 0.3s ease;
    border: 2px solid #e1dcb1;
    position: relative;
    z-index: 10;
    touch-action: manipulation;
    flex-shrink: 0;
}

.toode-button:hover {
    background-color: #d4cd9a;
    border-color: #d4cd9a;
    color: #15284b;
    text-decoration: none;
    transform: translateY(-2px);
}

/* Touch seadmete jaoks spetsiaalne käitumine */
@media (hover: none) and (pointer: coarse) {
    .toode-card:hover {
        transform: none;
    }

    .toode-button {
        padding: min(14px, 5%) min(28px, 10%);
        font-size: clamp(13px, 3.5vw, 15px);
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .toode-button:active {
        background-color: #d4cd9a;
        transform: scale(0.98);
    }
}

.tooted-admin-button {
    text-align: center;
    margin-top: 30px;
}

.tooted-manage-btn {
    display: inline-block;
    background-color: #28a745;
    color: #ffffff;
    padding: 15px 30px;
    text-decoration: none;
    border-radius: 25px;
    font-weight: bold;
    transition: all 0.3s ease;
    border: 2px solid #28a745;
}

.tooted-manage-btn:hover {
    background-color: #218838;
    border-color: #218838;
    color: #ffffff;
    text-decoration: none;
    transform: translateY(-2px);
}

/* Loading efekt */
.toode-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
    z-index: 3;
    pointer-events: none;
    border-radius: 40px 8px 40px 8px; /* Muudetud: erisugused nurgad */
}

.toode-card:hover::before {
    transform: translateX(100%);
}

/* Fallback stiilid kui pildid ei lae */
.toode-card:not([style*="background-image"]) {
    background: linear-gradient(45deg, #007cba, #005a87) !important;
}
