/**
 * Recipe Adaptive Shoplist - Frontend Styles
 */

/* ============================================
   Ingredient Row Enhancement
   ============================================ */

.ras-ingredient-row {
    position: relative;
}

.ras-ingredient-row.ras-has-products .wprm-shopping-list-ingredient-name,
.ras-ingredient-row.ras-in-inventory .wprm-shopping-list-ingredient-name {
    cursor: pointer;
}

.ras-ingredient-row.ras-from-inventory {
    opacity: 0.6;
}

.ras-ingredient-row.ras-from-inventory .wprm-shopping-list-ingredient-name {
    text-decoration: line-through;
}

/* ============================================
   Indicator Badges
   ============================================ */

.ras-indicators {
    display: inline-flex;
    gap: 6px;
    margin-left: 8px;
    vertical-align: middle;
}

.ras-indicator {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ras-indicator-products {
    background-color: #e3f2fd;
    color: #1565c0;
    border: 1px solid #bbdefb;
}

.ras-indicator-products:hover {
    background-color: #bbdefb;
}

.ras-indicator-inventory {
    background-color: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.ras-indicator-inventory:hover {
    background-color: #c8e6c9;
}

.ras-indicator-inventory.ras-expired {
    background-color: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

.ras-indicator-icon {
    margin-right: 4px;
    font-size: 12px;
}

/* ============================================
   Expandable Section
   ============================================ */

.ras-expandable {
    display: none;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin: 8px 0 12px 24px;
    padding: 12px;
    animation: ras-slide-down 0.2s ease;
}

.ras-expandable.ras-open {
    display: block;
}

@keyframes ras-slide-down {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ras-expandable-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #dee2e6;
}

.ras-expandable-title {
    font-weight: 600;
    font-size: 13px;
    color: #495057;
}

.ras-close-expandable {
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0;
}

.ras-close-expandable:hover {
    color: #343a40;
}

/* ============================================
   Product List
   ============================================ */

.ras-products-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ras-product-item {
    display: flex;
    align-items: center;
    padding: 10px;
    margin-bottom: 8px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ras-product-item:hover {
    border-color: #adb5bd;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.ras-product-item.ras-selected {
    border-color: #1976d2;
    background-color: #e3f2fd;
}

.ras-product-item:last-child {
    margin-bottom: 0;
}

.ras-product-radio {
    margin-right: 12px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.ras-product-image {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 12px;
    background-color: #f1f3f4;
}

.ras-product-no-image {
    width: 50px;
    height: 50px;
    background-color: #e9ecef;
    border-radius: 4px;
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #adb5bd;
    font-size: 20px;
}

.ras-product-info {
    flex: 1;
    min-width: 0;
}

.ras-product-name {
    font-weight: 500;
    font-size: 14px;
    color: #212529;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.ras-product-site {
    font-size: 12px;
    color: #6c757d;
}

.ras-product-pricing {
    text-align: right;
    margin-left: 12px;
}

.ras-product-price {
    font-weight: 600;
    font-size: 15px;
    color: #212529;
}

.ras-product-quantity {
    font-size: 11px;
    color: #6c757d;
    margin-top: 2px;
}

.ras-product-unit-price {
    font-size: 10px;
    color: #868e96;
}

.ras-product-link {
    margin-left: 10px;
    color: #1976d2;
    text-decoration: none;
    font-size: 18px;
}

.ras-product-link:hover {
    color: #1565c0;
}

/* ============================================
   Inventory Section
   ============================================ */

.ras-inventory-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed #dee2e6;
}

.ras-inventory-checkbox-wrapper {
    display: flex;
    align-items: center;
    padding: 10px;
    background: #e8f5e9;
    border-radius: 6px;
    cursor: pointer;
}

.ras-inventory-checkbox-wrapper:hover {
    background: #c8e6c9;
}

.ras-inventory-checkbox-wrapper.ras-checked {
    background: #a5d6a7;
}

.ras-inventory-checkbox {
    margin-right: 10px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.ras-inventory-label {
    flex: 1;
}

.ras-inventory-title {
    font-weight: 500;
    font-size: 14px;
    color: #2e7d32;
}

.ras-inventory-details {
    font-size: 12px;
    color: #558b2f;
    margin-top: 2px;
}

.ras-inventory-expiry {
    font-size: 11px;
    margin-top: 4px;
}

.ras-inventory-expiry.ras-expiring-soon {
    color: #f57c00;
}

.ras-inventory-expiry.ras-expired {
    color: #d32f2f;
}

/* ============================================
   Total Summary
   ============================================ */

.ras-total-summary {
    position: sticky;
    bottom: 0;
    background: linear-gradient(to bottom, rgba(255,255,255,0.9), #fff);
    border-top: 2px solid #1976d2;
    padding: 16px 20px;
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
}

.ras-total-label {
    font-size: 14px;
    color: #495057;
}

.ras-total-label strong {
    font-size: 16px;
}

.ras-total-amount {
    font-size: 24px;
    font-weight: 700;
    color: #1976d2;
}

.ras-total-items {
    font-size: 12px;
    color: #6c757d;
    margin-top: 4px;
}

/* ============================================
   Loading State
   ============================================ */

.ras-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #6c757d;
}

.ras-loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e9ecef;
    border-top-color: #1976d2;
    border-radius: 50%;
    animation: ras-spin 0.8s linear infinite;
    margin-right: 10px;
}

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

/* ============================================
   No Products Message
   ============================================ */

.ras-no-products {
    text-align: center;
    padding: 20px;
    color: #6c757d;
    font-size: 13px;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 600px) {
    .ras-expandable {
        margin-left: 0;
    }

    .ras-product-item {
        flex-wrap: wrap;
    }

    .ras-product-image,
    .ras-product-no-image {
        width: 40px;
        height: 40px;
    }

    .ras-product-pricing {
        width: 100%;
        text-align: left;
        margin-left: 30px;
        margin-top: 8px;
    }

    .ras-indicators {
        display: flex;
        margin-left: 0;
        margin-top: 6px;
    }

    .ras-total-summary {
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
    .ras-indicators,
    .ras-expandable,
    .ras-total-summary {
        display: none !important;
    }

    .ras-ingredient-row.ras-from-inventory {
        opacity: 1;
    }

    .ras-ingredient-row.ras-from-inventory::after {
        content: " (from inventory)";
        font-style: italic;
        color: #666;
    }
}
