/* --- Grundinställningar --- */
body { 
    font-family: sans-serif; 
    margin: 0; 
    background-color: #f0f2f5; 
    color: #333;
}

header {
    background-color: #fbbf50;
    padding: 1rem;
    border-bottom: 1px solid #ddd;
    position: sticky; /* Detta låser den vid toppen */
    top: 0;
    z-index: 1000; /* Säkerställer att den ligger ovanpå receptkorten */
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1rem;
}

.logo-container {
    display: flex;
    align-items: center;
}

.logo-container img {
    width: 32px;
    height: 32px;
    border-radius: 5px;
}

.site-name {
    font-size: 1.2rem;
    font-weight: bold;
    margin-left: 0.5rem;
}

/* --- Meny & Hamburgare --- */
.menu-container { position: relative; }

.hamburger-menu {
    cursor: pointer;
    padding: 0.5rem;
    z-index: 100;
}

.bar {
    display: block;
    width: 25px;
    height: 3px;
    margin: 5px auto;
    background-color: #333;
    transition: 0.3s;
}

.menu-items {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background-color: white;
    border: 1px solid #ddd;
    list-style: none;
    padding: 0;
    margin: 0;
    min-width: 160px;
    z-index: 10;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.menu-items.active { display: block; }

.menu-items li a, .user-greeting {
    display: block;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: #333;
}

.menu-items li a:hover { background-color: #f0f0f0; }

/* --- Recept-Grid (Listan) --- */
.recipes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); 
    gap: 20px;
    max-width: 1000px;
    margin: 2rem auto;
    padding: 0 20px;
}

.recipe-card {
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid #eee;
}

.recipe-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.1);
}

.recipe-card-image-placeholder {
    height: 120px;
    background-color: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #eee;
}

.recipe-card-title {
    padding: 15px;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
    line-height: 1.3;
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Sökfält --- */
.search-container {
    max-width: 1000px;
    margin: 0 auto; /* Ta bort övre margin så den ansluter till headern */
    background-color: #fff;
    border-radius: 0 0 8px 8px; /* Avrunda bara de nedre hörnen för en snyggare anslutning */
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    position: sticky; /* Gör även sökfältet pinnat */
    top: 65px; /* Justera detta värde baserat på din headers faktiska höjd */
    z-index: 999;
}

.search-container input {
    border: none;
    outline: none;
    flex-grow: 1;
    padding: 0.5rem;
    font-size: 1rem;
}

/* --- Receptdetaljer --- */
.recipe-detail-container {
    max-width: 800px;
    margin: 2rem auto;
    background-color: #fff;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.recipe-image {
    width: 100%;
    max-height: 400px;
    object-fit: contain; /* <--- Detta tvingar hela bilden att synas */
    background-color: #f1f3f4; /* Valfritt: Ger en snygg ljusgrå bakgrund där bilden inte täcker */
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* --- Instruktioner med Checkboxar --- */
.steps-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 15px;
}

.step-item {
    display: flex;
    flex-direction: column; 
    gap: 8px;
    margin-bottom: 20px;
    padding: 12px;
    background: #f9f9f9; /* Valfritt: en ljus bakgrund gör stegen tydligare */
    border-radius: 8px;
}

.step-item:hover {
    border-color: #fbbf50;
    background: #fffefb;
}

.step-header {
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #eee; /* Tydlig avgränsning */
    padding-bottom: 5px;
    margin-bottom: 5px;
}

.step-checkbox {
    width: 18px;
    height: 18px;
    margin: 0;
}

.step-checkbox:checked ~ .step-text {
    color: #999;
    text-decoration: line-through;
    opacity: 0.6;
}
.step-number {
    font-weight: bold;
    color: #fbbc04;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.step-text {
    line-height: 1.6;
    font-size: 1.05em;
    color: #333;
    padding-top: 4px;
}

/* --- Inloggningsmodal --- */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    justify-content: center;
    align-items: center;
}

.modal.active { display: flex !important; }

.modal-content {
    background-color: #fff;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 380px;
    position: relative;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.modal-content input {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-sizing: border-box;
}

.close-modal {
    position: absolute;
    right: 20px;
    top: 10px;
    font-size: 28px;
    cursor: pointer;
    color: #666;
}

/* --- Knappar --- */
.cast-button {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #4285F4;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: bold;
    margin: 2rem auto;
    border: none;
    cursor: pointer;
}

/* --- Mobilanpassningar (2 i bredd på listan) --- */
@media (max-width: 600px) {
    .recipes-grid {
        display: flex;
        flex-direction: column; /* Gör om grid till en lista */
        gap: 8px;
        padding: 0 15px;
        margin-top: 1rem;
    }
    .back-button span {
        display: none;
    }

    .recipe-card {
        flex-direction: row; /* Lägg innehåll på rad istället för kolumn */
        align-items: center;
        border-radius: 8px;
        box-shadow: 0 1px 2px rgba(0,0,0,0.05);
        height: 50px; /* Fixerad höjd för en tajt lista */
    }

    /* Vi döljer den stora grå boxen på mobilen */
    .recipe-card-image-placeholder {
        display: none;
    }

    .recipe-card-title {
        padding: 0 15px;
        text-align: left;
        font-size: 0.95rem;
        width: 100%;
    }
    
    /* Lägg till en liten pil till höger på mobilen för att det ska se ut som en lista */
    .recipe-card::after {
        content: '›';
        font-size: 1.5rem;
        color: #ccc;
        margin-right: 15px;
    }
}

/* --- Lägg till recept (add.php) --- */
.add-container {
    padding: 20px;
    max-width: 600px;
    margin: 0 auto;
}

.add-container label {
    display: block;
    margin-top: 15px;
    font-weight: bold;
}

.add-container input[type="text"], .add-container textarea {
    width: 100%;
    padding: 12px;
    margin-top: 5px;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-sizing: border-box;
}

.back-button {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: #333; /* Samma färg som din text eller logga */
    font-size: 14px;
    font-weight: 500;
    padding: 8px;
    border-radius: 50%; /* Gör den till en cirkel vid klick */
    transition: background 0.2s;
}

.back-button:active {
    background: rgba(0,0,0,0.05); /* Liten effekt när man trycker med tummen */
}

.back-button svg {
    width: 24px;
    height: 24px;
}

/* Mapp-struktur */
.recipes-folders {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    max-width: 800px;
    margin: 0 auto;
}

.folder-header {
    background: #e0e0e0;
    padding: 12px 16px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.folder-header:hover {
    background: #d0d0d0;
}

.folder-content {
    padding-left: 10px;
    display: none;
    overflow: hidden;
    transition: all 0.3s ease-out;
}

/* Raden för varje recept */
.recipe-list-item {
    display: flex;
    align-items: center;
    background: #ffffff;
    padding: 12px 16px;
    border-radius: 8px;
    text-decoration: none;
    color: #333333;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s;
}

.recipe-list-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.08);
}

/* Bild- och Avatar-behållare */
.recipe-avatar-container {
    width: 45px;
    height: 45px;
    margin-right: 16px;
    flex-shrink: 0;
}

.recipe-list-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.recipe-avatar-text {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: bold;
    font-size: 1.2rem;
}

/* Textinfo */
.recipe-list-info {
    flex-grow: 1;
}

.recipe-list-title {
    font-weight: 600;
    font-size: 1.05rem;
    margin-bottom: 4px;
}

/* Taggar */
.recipe-list-tags {
    display: flex;
    gap: 6px;
}

.recipe-tag {
    font-size: 0.75rem;
    background: #f0f0f0;
    color: #666666;
    padding: 2px 8px;
    border-radius: 12px;
}

/* Pil till höger */
.recipe-list-arrow {
    color: #cccccc;
    display: flex;
    align-items: center;
}

/* Helkärmsvisning för receptbilder */
.fullscreen-image-modal {
    display: none; /* Dold som standard */
    position: fixed;
    z-index: 9999; /* Ligger över allt annat (även inloggningsmenyn) */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9); /* Svart halvgenomskinlig bakgrund */
    align-items: center;
    justify-content: center;
    cursor: zoom-out; /* Visar att man kan klicka för att stänga */
}

.fullscreen-image-modal img {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    animation: zoomIn 0.3s ease;
}

@keyframes zoomIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Gör originalbilden klickbar */
.recipe-image {
    cursor: zoom-in;
}