/* ============================================================================
   Egna recept — Formulär och lista
   ============================================================================ */

/* === 1. WRAPPERS + FOUC === */

/* Formuläret har egen max-bredd + padding (standalone på /skapa-recept/) */
.sp-er-form-wrap {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
    box-sizing: border-box;
    font-family: 'Proxima Nova', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #2c2c2c;
    opacity: 1 !important;
    transition: opacity 0.15s ease;
}

/* Listan ärver bredd från föräldern (fungerar både standalone och inuti Elementor-layout) */
.sp-er-list-wrap {
    box-sizing: border-box;
    font-family: 'Proxima Nova', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #2c2c2c;
    opacity: 1 !important;
    transition: opacity 0.15s ease;
}

.sp-er-form-wrap *,
.sp-er-form-wrap *::before,
.sp-er-form-wrap *::after,
.sp-er-list-wrap *,
.sp-er-list-wrap *::before,
.sp-er-list-wrap *::after {
    box-sizing: border-box;
}


/* === 2. FORMULÄR === */

.sp-er-form {
    background: #fff;
    border: 1px solid #e8ece8;
    border-radius: 12px;
    padding: 28px;
}

.sp-er-form-title {
    font-family: 'Montserrat', 'Proxima Nova', sans-serif;
    font-size: 24px;
    font-weight: 700;
    color: #2c2c2c;
    margin: 0 0 28px;
}

.sp-er-field {
    margin-bottom: 28px;
}

.sp-er-field:last-of-type {
    margin-bottom: 0;
}

.sp-er-label {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: #2c2c2c;
    margin-bottom: 8px;
}

.sp-er-required {
    color: #999;
    font-weight: 400;
    font-size: 0.9em;
}

.sp-er-hint {
    font-size: 13px;
    color: #888;
    line-height: 1.5;
    margin: -2px 0 10px;
}

.sp-er-input,
.sp-er-form textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 16px;
    font-family: inherit;
    color: #2c2c2c;
    background: #fff;
    border: 1px solid #d6e2d6;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.sp-er-input--small {
    width: 100px;
}

.sp-er-input:focus,
.sp-er-form textarea:focus {
    border-color: #3D5F42;
    box-shadow: 0 0 0 3px rgba(61, 95, 66, 0.1);
}

.sp-er-error {
    color: #c0392b;
    font-size: 13px;
    margin-top: 6px;
    display: none;
}


/* === 3. BILDUPLOAD === */

.sp-er-image-upload {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.sp-er-image-preview {
    width: 120px;
    height: 120px;
    background: #f0f4f0 center/cover no-repeat;
    border: 1px dashed #c5d1c5;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 12px;
    text-align: center;
    flex-shrink: 0;
}

.sp-er-image-placeholder {
    padding: 8px;
}

.sp-er-file-input {
    display: none;
}

.sp-er-file-label {
    display: inline-block;
    padding: 8px 16px;
    background: #fff;
    border: 1px solid #3D5F42;
    color: #3D5F42;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.sp-er-file-label:hover {
    background: #f0f4f0;
}

.sp-er-remove-image {
    font-size: 13px;
    color: #c0392b;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}


/* === 4. REPEATERS (ingredienser + instruktioner) === */

.sp-er-ingredients,
.sp-er-instructions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}

.sp-er-ingredient-row {
    display: grid;
    grid-template-columns: minmax(0, 140px) minmax(0, 1fr) 36px;
    gap: 8px;
    align-items: center;
}

.sp-er-instruction-row {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) 36px;
    gap: 8px;
    align-items: start;
}

.sp-er-ing-mangd,
.sp-er-ing-vara,
.sp-er-step-text {
    width: 100%;
    padding: 8px 12px;
    font-size: 15px;
    font-family: inherit;
    color: #2c2c2c;
    background: #fff;
    border: 1px solid #d6e2d6;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.sp-er-ing-mangd:focus,
.sp-er-ing-vara:focus,
.sp-er-step-text:focus {
    border-color: #3D5F42;
    box-shadow: 0 0 0 2px rgba(61, 95, 66, 0.1);
}

.sp-er-step-text {
    resize: vertical;
    min-height: 48px;
}

.sp-er-step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #3D5F42;
    color: #fff;
    border-radius: 50%;
    font-weight: 700;
    font-size: 14px;
    margin-top: 4px;
}

.sp-er-remove-row {
    width: 32px;
    height: 32px;
    background: none;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    color: #999;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
    margin-top: 4px;
}

.sp-er-remove-row:hover {
    color: #c0392b;
    border-color: #c0392b;
    background: rgba(192, 57, 43, 0.05);
}

.sp-er-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    align-self: flex-start;
    padding: 8px 14px;
    background: none;
    border: 1px dashed #c5d1c5;
    color: #3D5F42;
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    font-family: inherit;
}

.sp-er-add-btn:hover {
    background: #f0f4f0;
    border-color: #3D5F42;
    color: #2c4530;
}


/* === 5. ACTIONS === */

.sp-er-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.sp-er-submit {
    padding: 12px 28px;
    background: #3D5F42;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
    font-family: inherit;
}

.sp-er-submit:hover {
    background: #2c4530;
}

.sp-er-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.sp-er-cancel {
    color: #666;
    font-size: 14px;
    text-decoration: none;
}

.sp-er-cancel:hover {
    color: #2c2c2c;
}

.sp-er-delete {
    margin-left: auto;
    padding: 8px 16px;
    background: none;
    color: #c0392b;
    border: 1px solid #c0392b;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
    font-family: inherit;
}

.sp-er-delete:hover {
    background: rgba(192, 57, 43, 0.05);
}


/* === 6. MEDDELANDEN === */

.sp-er-success {
    padding: 12px 16px;
    background: #edf5ed;
    color: #3D5F42;
    border-radius: 8px;
    font-weight: 600;
    margin-bottom: 16px;
}

.sp-er-global-error {
    margin-top: 12px;
    padding: 10px 14px;
    background: #fdf4f4;
    color: #b14040;
    border-radius: 6px;
    font-size: 14px;
}


/* === 7. LISTA === */

/* Card-container kring bara header-delen — korten ligger på sidans bg */
.sp-er-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    background: #fff;
    border: 1px solid #e8e5e1;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.sp-er-list-header-text {
    flex: 1;
    min-width: 0;
}

.sp-er-list-title {
    font-family: 'Proxima Nova', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: #2c2c2c;
    margin: 0 0 2px;
    line-height: 1.3;
}

.sp-er-list-intro {
    margin: 0;
    color: #888;
    font-size: 13px;
    line-height: 1.5;
}

.sp-er-create-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: #3D5F42;
    color: #fff !important;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}

.sp-er-create-btn:hover {
    background: #2c4530;
    color: #fff !important;
}

.sp-er-empty {
    text-align: center;
    padding: 48px 24px;
    background: #fafaf7;
    border: 1px dashed #d6d6d6;
    border-radius: 10px;
}

.sp-er-empty-title {
    font-family: 'Montserrat', 'Proxima Nova', sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: #555;
    margin: 0 0 8px;
    line-height: 1.3;
}

.sp-er-empty-hint {
    font-size: 15px;
    color: #888;
    margin: 0;
    line-height: 1.5;
}

.sp-er-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.sp-er-card {
    display: block;
    background: #fff;
    border: 1px solid #e8ece8;
    border-radius: 10px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s, box-shadow 0.15s;
}

.sp-er-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
    color: inherit;
}

.sp-er-card-image {
    aspect-ratio: 328 / 191;
    background: #f0f4f0 center/cover no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #c5d1c5;
}

.sp-er-card-body {
    padding: 14px 16px;
}

.sp-er-card-title {
    font-family: 'Montserrat', 'Proxima Nova', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: #2c2c2c;
    margin: 0 0 4px;
    line-height: 1.3;
}

.sp-er-card-date {
    font-size: 12px;
    color: #888;
}


/* === 8. FLIKAR (Sparade recept) === */

.sp-sr-tabs-wrap {
    opacity: 1 !important;
    transition: opacity 0.15s ease;
}

.sp-sr-tabs-nav {
    display: flex;
    gap: 0;
    background: #e8e8e8;
    border-radius: 10px;
    padding: 3px;
    margin-bottom: 12px;
    opacity: 1 !important;
    transition: opacity 0.15s ease;
}

/* Viewport-specifika varianter (brytpunkt: 1024px — surfplatta räknas som mobil) */
.sp-sr-tabs-nav--mobile-only { display: flex; }
.sp-sr-tabs-nav--desktop-only { display: none; }

@media (min-width: 1025px) {
    .sp-sr-tabs-nav--mobile-only { display: none; }
    .sp-sr-tabs-nav--desktop-only { display: flex; }
}

/* Desktop (≥1025px): vit bakgrund + subtil card-ram (matchar sidofält, resultatbar etc.) */
@media (min-width: 1025px) {
    .sp-sr-tabs-nav {
        background: #fff;
        border: 1px solid #e8e5e1;
        gap: 4px;
    }
}


/* Mobil + surfplatta: full-bleed, sitter ihop med hero ovan och filter nedan */
@media (max-width: 1024px) {
    .sp-sr-tabs-nav {
        position: relative;
        left: 50%;
        right: 50%;
        margin-left: -50vw;
        margin-right: -50vw;
        width: 100vw;
        max-width: 100vw;
        border-radius: 0;
        padding: 8px 12px;
        margin-top: 0;
        margin-bottom: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .sp-sr-tabs-nav::-webkit-scrollbar {
        display: none;
    }
}

.sp-sr-tab {
    flex: 1;
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #3a3a3a;
    font-family: 'Proxima Nova', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
    white-space: nowrap;
    line-height: 1.3;
}

@media (hover: hover) {
    .sp-sr-tab:not(.is-active):hover {
        color: #2e4a32;
        background: #f1f6f2;
    }
}

.sp-sr-tab.is-active {
    background: #fff;
    color: #2c2c2c;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Desktop (≥1025px): nav har vit bakgrund så aktiv flik behöver annan markering */
@media (min-width: 1025px) {
    .sp-sr-tab.is-active {
        background: #e2ece3;
        color: #243a28;
        font-weight: 600;
        box-shadow: none;
    }
}

.sp-sr-tab:focus-visible {
    outline: 2px solid #3D5F42;
    outline-offset: 2px;
    border-radius: 4px;
}

.sp-sr-tab-panel {
    display: none;
}

.sp-sr-tab-panel.is-active {
    display: block;
}


/* === 9. MOBIL === */

@media (max-width: 600px) {
    .sp-er-form-wrap {
        padding: 0 12px;
    }

    .sp-sr-tab {
        padding: 10px 14px;
        font-size: 13px;
    }

    .sp-er-form {
        padding: 20px 16px;
    }

    .sp-er-form-title {
        font-size: 20px;
    }

    .sp-er-list-header {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        padding: 16px;
    }

    .sp-er-create-btn {
        justify-content: center;
        width: 100%;
    }

    .sp-er-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .sp-er-card-body {
        padding: 12px 14px;
    }

    .sp-er-card-title {
        font-size: 15px;
    }

    .sp-er-ingredient-row {
        grid-template-columns: minmax(0, 110px) minmax(0, 1fr) 32px;
    }

    .sp-er-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .sp-er-delete {
        margin-left: 0;
    }
}
