/* ============================
   GLOBAL TRAC PLANNING TOOL CSS
   Anpassad för Flatsome grid
   ============================ */

/* --- Preview --- */
.col {
    padding: initial;
}

.preview {
    text-align: center;
    margin-bottom: 20px;
}

/* Kolumnen med preview-bild */
#planning-tool-global-trac .preview-fieldset {
    flex: 0 0 45%;
    /* ~halva bredden på desktop */
    min-width: 300px;
    /* inte mindre än 300px */
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Preview-bild */
#planning-tool-global-trac .preview-fieldset img {
    width: 100%;
    /* större maxstorlek på desktop */
    height: auto;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    margin-top: 10px;
    background-color: rgb(193, 193, 193);
}

/* --- Spinner CSS --- */
.spinner-container {
    text-align: center;
    margin-bottom: 10px;
}

.spinner {
    margin: 20px auto;
    width: 50px;
    height: 50px;
    border: 4px solid #ccc;
    border-top-color: #2d76f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.goto-product a {
    background: var(--wp--preset--color--success);
    color: #fff;
    display: block;
    padding: 10px;
    font-weight: bold;
}

.goto-product a:hover {
    background: var(--wp--preset--color--secondary);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- Message div --- */
#add-to-cart-message {
    display: none;
    margin-bottom: 15px;
    padding: 10px;
    border-radius: 5px;
    text-align: center;
}

#add-to-cart-message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

#add-to-cart-message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* --- Radioknappar / Fieldsets --- */
input[type=radio] {
    display: none;
    min-width: 50px;
}

/* Ta bort custom flex-layout på form – låt Flatsome styra */
#planning-tool-global-trac .form form {
    display: block;
    gap: 0;
    align-items: initial;
}

/* Rubrik överst */
#planning-tool-global-trac h1 {
    text-align: center;
    margin: 16px 0;
}

#planning-tool-global-trac .description {
    font-size: 1rem;
    line-height: 1.6;
    color: #333;
    margin-bottom: 20px;
    text-align: left;
}

/* Varje fieldset (Färg, Form, Längd) */
#planning-tool-global-trac .fieldset {
    flex: 1;
    min-width: 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

/* Rubrik över varje fieldset */
#planning-tool-global-trac .fieldset h3 {
    margin-bottom: 10px;
    text-align: center;
}

/* Radioknappar med bilder */
#planning-tool-global-trac .fieldset label {
    display: inline-block;
    cursor: pointer;
    margin: 10px;
}

/* Highlight på vald radioknapp */
#planning-tool-global-trac .fieldset input[type="radio"]:checked+label {
    border: 2px solid #2d76f6;
    border-radius: 5px;
}

/* Längdalternativ */
#planning-tool-global-trac .length-option {
    display: inline-block;
    min-width: 75px;
}

.length-option label {
    padding: 6px;
}

/* --- Produktkort --- */
#product-selection {
    margin-top: 20px;
}

#add-products-form {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: stretch;
}

#add-products-form .product-card {
    position: relative;
    flex: 1 1 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    text-align: center;
    transition: all 0.2s;
    min-height: 250px;
    box-sizing: border-box;
    cursor: pointer;
}

#add-products-form .product-card .price {
    font-size: 22px;
    color: #000;
    margin: 10px 0;
}

#add-products-form .product-card .quantity-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: var(--fs-color-secondary);
    color: #fff;
    font-weight: bold;
    padding: 5px 8px;
    border-radius: 50%;
    font-size: 14px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

#add-products-form .product-card img {
    max-width: 120px;
    height: auto;
    margin-bottom: 10px;
}

#add-products-form .product-card div,
#add-products-form .product-card span {
    margin-bottom: 5px;
}

#add-products-form .product-card.selected {
    border-color: #2d76f6;
    box-shadow: 0 0 15px rgba(45, 118, 246, 0.3);
}

/* Add to cart button */
#add-products-form #add-to-cart-btn {
    flex-basis: 100%;
    margin-top: 15px;
    background-color: var(--fs-color-success);
    color: #fff;
    border: none;
    padding: 12px 20px;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#add-products-form #add-to-cart-btn:hover {
    background-color: var(--fs-color-secondary);
}

/* --- Responsivt --- */
@media (max-width: 768px) {
    #planning-tool-global-trac .preview-fieldset {
        flex-basis: 100%;
        max-width: 100%;
        min-width: 0;
    }

    #add-products-form {
        flex-direction: column;
        gap: 15px;
    }

    #add-products-form .product-card {
        min-height: auto;
    }
}