/**
 * MSW Recipe Finder - Stylesheet
 * Version: 1.1.0
 * Culinary-themed design for seniors 55+
 */

/* ==========================================================================
   BASE / CALCULATOR CONTAINER
   ========================================================================== */

.msw-recipe-finder {
    max-width: 1100px;
    margin: 0 auto;
    padding: 30px 25px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 18px;
    line-height: 1.6;
    color: #333333;
}

.msw-recipe-finder *,
.msw-recipe-finder *::before,
.msw-recipe-finder *::after {
    box-sizing: border-box;
}

/* ==========================================================================
   HEADER
   ========================================================================== */

.msw-calculator__header {
    text-align: center;
    margin-bottom: 25px;
}

.msw-calculator__title {
    font-size: 32px;
    font-weight: 700;
    color: #B8621B;
    margin: 0 0 8px 0;
}

.msw-calculator__subtitle {
    font-size: 20px;
    color: #666666;
    margin: 0;
}

/* ==========================================================================
   INSTRUCTIONS
   ========================================================================== */

.msw-calculator__instructions {
    background: #FFF8F0;
    border: 2px solid #D4772A;
    border-radius: 8px;
    padding: 20px 25px;
    margin-bottom: 30px;
}

.msw-calculator__instructions p {
    margin: 0 0 8px 0;
}

.msw-calculator__instructions p:last-child {
    margin-bottom: 0;
}

.msw-logged-in-notice {
    color: #2E7D32;
    font-weight: 600;
}

/* ==========================================================================
   FORM / FILTERS
   ========================================================================== */

.msw-calculator__form {
    margin-bottom: 30px;
}

.msw-form-section {
    background: #FFFFFF;
    border: 2px solid #E8E8E8;
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 25px;
}

.msw-form-section__title {
    font-size: 24px;
    font-weight: 600;
    color: #B8621B;
    margin: 0 0 20px 0;
}

.msw-form-row {
    margin-bottom: 20px;
}

.msw-form-group {
    margin-bottom: 15px;
}

.msw-form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: #333333;
}

.msw-form-input,
.msw-form-select {
    width: 100%;
    border: 2px solid #CCCCCC;
    border-radius: 6px;
    font-size: 18px;
    font-family: inherit;
    background: #FFFFFF;
    color: #333333;
    transition: border-color 0.2s ease;
}

.msw-form-input:focus,
.msw-form-select:focus {
    border-color: #D4772A;
    outline: none;
    box-shadow: 0 0 0 3px rgba(212, 119, 42, 0.15);
}

.msw-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

/* Dietary Checkboxes */
.msw-dietary-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 15px 0;
    margin-bottom: 15px;
    border-top: 1px solid #E8E8E8;
    border-bottom: 1px solid #E8E8E8;
}

.msw-dietary-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
}

.msw-dietary-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* Filter Actions */
.msw-filter-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
}

.msw-results-count {
    margin-left: auto;
    font-size: 16px;
    color: #666666;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.msw-button {
    padding: 12px 24px;
    border: 2px solid #D4772A;
    border-radius: 6px;
    font-size: 18px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1.3;
}

.msw-button--primary {
    background: #D4772A;
    color: #FFFFFF;
    border-color: #D4772A;
}

.msw-button--primary:hover {
    background: #B8621B;
    border-color: #B8621B;
}

.msw-button--primary:disabled {
    background: #999999;
    border-color: #999999;
    cursor: default;
}

.msw-button--secondary {
    background: #FFFFFF;
    color: #D4772A;
    border-color: #D4772A;
}

.msw-button--secondary:hover {
    background: #FFF8F0;
}

.msw-button--favourites {
    background: #FFFFFF;
    color: #C0392B;
    border-color: #C0392B;
}

.msw-button--favourites:hover {
    background: #FDF2F2;
}

/* ==========================================================================
   RECIPE GRID
   ========================================================================== */

.msw-recipe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.msw-recipe-card {
    background: #FFFFFF;
    border: 2px solid #E8E8E8;
    border-radius: 8px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.msw-recipe-card:hover {
    border-color: #D4772A;
    box-shadow: 0 4px 12px rgba(184, 98, 27, 0.15);
    transform: translateY(-2px);
}

.msw-recipe-card__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 10px;
}

.msw-recipe-card__header h4 {
    font-size: 18px;
    font-weight: 600;
    color: #B8621B;
    margin: 0;
    flex: 1;
}

.msw-recipe-tag {
    background: #F0F0F0;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 600;
    flex-shrink: 0;
}

.msw-recipe-card__meta {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
    font-size: 14px;
    color: #666666;
}

.msw-fav-indicator {
    color: #C0392B;
}

.msw-recipe-card__tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.msw-diet-tag {
    background: #E8F5E9;
    color: #2E7D32;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.msw-no-results {
    text-align: center;
    padding: 60px 20px;
    font-size: 20px;
    color: #999999;
}

/* ==========================================================================
   FAVOURITES ACTIONS
   ========================================================================== */

.msw-favourites-actions {
    text-align: center;
    margin: 20px 0;
}

/* ==========================================================================
   RECIPE MODAL - FIXED STRUCTURE
   Wrapper > Overlay (backdrop) + Content (side by side, not nested)
   Clicks on overlay close modal. Clicks on content stay inside.
   ========================================================================== */

.msw-recipe-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 3vh 15px;
    overflow-y: auto;
}

.msw-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1;
}

.msw-modal-content {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    background: #FFFFFF;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.msw-modal-header {
    padding: 20px 30px;
    background: #FFF8F0;
    border-bottom: 2px solid #D4772A;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.msw-modal-header h3 {
    margin: 0;
    color: #B8621B;
    font-size: 24px;
    flex: 1;
    padding-right: 15px;
}

.msw-modal-close,
.msw-shopping-close {
    background: none;
    border: none;
    font-size: 32px;
    cursor: pointer;
    color: #999999;
    line-height: 1;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.msw-modal-close:hover,
.msw-shopping-close:hover {
    color: #B8621B;
}

/* CRITICAL: Modal body scrolls internally so full recipe is always accessible */
.msw-modal-body {
    padding: 30px;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0; /* Required for flex scroll to work */
}

.msw-modal-footer {
    padding: 20px 30px;
    background: #F9F9F9;
    border-top: 1px solid #E8E8E8;
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-shrink: 0;
}

/* ==========================================================================
   RECIPE DETAIL CONTENT (inside modal body)
   ========================================================================== */

.msw-recipe-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    padding: 20px;
    background: #F9F9F9;
    border-radius: 6px;
    margin-bottom: 25px;
    font-size: 16px;
}

.msw-serving-adjuster {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 25px;
    padding: 15px;
    background: #FFF8F0;
    border-radius: 6px;
}

.msw-serving-btn {
    padding: 8px 16px;
    border: 2px solid #D4772A;
    background: #FFFFFF;
    color: #B8621B;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 16px;
    font-family: inherit;
    transition: all 0.2s ease;
    min-width: 44px;
    min-height: 44px;
}

.msw-serving-btn:hover {
    background: #FFF8F0;
}

.msw-serving-active {
    background: #D4772A !important;
    color: #FFFFFF !important;
}

.msw-recipe-section {
    margin-bottom: 25px;
}

.msw-recipe-section h4 {
    font-size: 20px;
    color: #B8621B;
    margin: 0 0 15px 0;
}

/* Ingredient List */
.msw-ingredient-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.msw-ingredient-list li {
    padding: 10px 0;
    border-bottom: 1px solid #F0F0F0;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.msw-ingredient-list li:last-child {
    border-bottom: none;
}

.msw-ingredient-check {
    margin-top: 4px;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    cursor: pointer;
}

/* Checked ingredients get strikethrough */
.msw-ingredient-check:checked + span {
    text-decoration: line-through;
    color: #999999;
}

/* Instruction List */
.msw-instruction-list {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: step-counter;
}

.msw-instruction-list li {
    counter-increment: step-counter;
    padding: 12px 0 12px 45px;
    position: relative;
    border-bottom: 1px solid #F0F0F0;
    line-height: 1.6;
}

.msw-instruction-list li:last-child {
    border-bottom: none;
}

.msw-instruction-list li::before {
    content: counter(step-counter);
    position: absolute;
    left: 0;
    top: 12px;
    width: 30px;
    height: 30px;
    background: #D4772A;
    color: #FFFFFF;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

/* Nutrition Grid */
.msw-nutrition-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    padding: 15px;
    background: #F9F9F9;
    border-radius: 6px;
}

/* ==========================================================================
   SHOPPING LIST
   ========================================================================== */

.msw-shopping-intro {
    margin: 0 0 15px 0;
    color: #666666;
    font-style: italic;
}

.msw-shopping-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.msw-shopping-list li {
    padding: 12px 0;
    border-bottom: 1px solid #F0F0F0;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.msw-shopping-list li:last-child {
    border-bottom: none;
}

.msw-shopping-check {
    margin-top: 4px;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    cursor: pointer;
}

.msw-shopping-check:checked + span {
    text-decoration: line-through;
    color: #999999;
}

/* ==========================================================================
   TIPS
   ========================================================================== */

.msw-tips {
    background: #F9F9F9;
    padding: 30px;
    border-radius: 8px;
    border: 2px solid #E8E8E8;
    margin-top: 30px;
}

.msw-tips__title {
    font-size: 24px;
    font-weight: 600;
    color: #B8621B;
    margin: 0 0 20px 0;
}

.msw-tips__list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.msw-tips__list li {
    padding: 12px 0 12px 35px;
    position: relative;
    border-bottom: 1px solid #E8E8E8;
}

.msw-tips__list li:last-child {
    border-bottom: none;
}

.msw-tips__list li::before {
    content: "🍳";
    position: absolute;
    left: 0;
    font-size: 20px;
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
    .msw-calculator__instructions,
    .msw-form-section,
    .msw-favourites-actions,
    .msw-tips,
    .msw-modal-footer,
    .msw-modal-close,
    .msw-shopping-close,
    .msw-filter-actions,
    .msw-serving-adjuster {
        display: none !important;
    }
    
    .msw-recipe-modal {
        position: static !important;
    }
    
    .msw-modal-overlay {
        display: none !important;
    }
    
    .msw-modal-content {
        max-height: none !important;
        box-shadow: none !important;
        border: none !important;
    }
    
    .msw-modal-body {
        overflow: visible !important;
    }
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 768px) {
    .msw-recipe-finder {
        padding: 20px 15px;
    }
    
    .msw-calculator__title {
        font-size: 26px;
    }
    
    .msw-filter-grid {
        grid-template-columns: 1fr;
    }
    
    .msw-recipe-grid {
        grid-template-columns: 1fr;
    }
    
    .msw-dietary-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .msw-filter-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .msw-results-count {
        margin-left: 0;
        text-align: center;
    }
    
    .msw-recipe-modal {
        padding: 1vh 8px;
    }
    
    .msw-modal-content {
        max-height: 96vh;
    }
    
    .msw-modal-header {
        padding: 15px 20px;
    }
    
    .msw-modal-header h3 {
        font-size: 20px;
    }
    
    .msw-modal-body {
        padding: 20px;
    }
    
    .msw-modal-footer {
        padding: 15px 20px;
        flex-direction: column;
    }
    
    .msw-nutrition-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .msw-recipe-meta {
        grid-template-columns: 1fr 1fr;
    }
    
    .msw-serving-adjuster {
        flex-wrap: wrap;
    }
}

/* ==========================================================================
   ACCESSIBILITY
   ========================================================================== */

*:focus-visible {
    outline: 3px solid #D4772A;
    outline-offset: 2px;
}

.msw-recipe-card:focus-visible {
    outline: 3px solid #D4772A;
    outline-offset: 2px;
}

/* Utility */
.msw-no-data {
    text-align: center;
    padding: 40px 20px;
    color: #999999;
    font-size: 18px;
}
