/* Organisationens färger. Standardvärden; index.php skriver över dem med organisationens egna val. */
:root {
    --org-accent: #31a7eb;
    --org-menu-rgb: 33, 37, 41;
    --org-footer-rgb: 33, 37, 41;
    --org-menu-text: #ffffff;
    --org-footer-text: #ffffff;
    --org-accent-text: #ffffff;
    --org-header-text: #ffffff;
    --org-header-shadow: rgba(0, 0, 0, 0.5);
    --org-bg: #ffffff;
    --org-text: #212529;
    --org-page-max: 1124px;
}

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    overflow-x: hidden; /* en logga som sticker ut åt sidan ska inte ge sidscroll */
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
    background: linear-gradient(to bottom, #e9e9e9, #f8f8f8);
    background-attachment: fixed;
}

.own_container {
    max-width: var(--org-page-max);
    margin: 20px auto;
    background-color: var(--org-bg);
    color: var(--org-text);
    box-shadow: 0 0 15px rgba(0,0,0,0.1);
    min-height: calc(100vh - 40px);
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    overflow: visible; /* loggan får sticka ut ur headern och sidan; hörnen rundas av header och footer själva */
}

header {
    border-radius: 15px 15px 0 0;
    /* Organisationens egen bakgrundsbild om den har laddat upp en (variabeln sätts av org_colors_css()), annars en enkel färgtoning av temat */
    background-image: var(--org-header-bg, var(--org-header-fill, linear-gradient(135deg, rgb(var(--org-menu-rgb)), var(--org-accent))));
    background-size: cover;
    background-position: center;
    width: 100%;
    height: var(--org-header-height, 250px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    position: relative;
}

.logo-text {
    height: var(--org-logo-height, 180px);
    margin-top: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    color: var(--org-header-text);
    font-size: 2.6rem;
    font-weight: 700;
    text-align: center;
    text-shadow: 0 2px 6px var(--org-header-shadow);
}

.org-slogan {
    margin-top: -10px;
    padding: 0 20px;
    color: var(--org-header-text);
    font-size: 1.15rem;
    text-align: center;
    text-shadow: 0 1px 4px var(--org-header-shadow);
    position: relative;
    z-index: 4;
}

/* Loggan ligger utanför headerns flöde: den får vara högre än headern och sticker då ut över innehållet nedanför.
   Placeringen (vänster/mitten/höger) styrs av .header-align-*. */
.logo-wrap {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100; /* över allt (meny, innehåll) utom sitt eget skyddslager */
    line-height: 0;
}

.logo {
    display: block;
    height: var(--org-logo-height, 180px);
    width: auto;
    max-width: none;
}

/* Osynligt skyddslager ovanpå loggan (högre än loggan, så att den inte går att klicka på, spara eller dra ut) */
.logo-guard {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 101;
    background: transparent;
}

/* Sloganen ligger under en bildlogga */
.org-slogan.below-logo { margin-top: calc(var(--org-logo-height, 180px) + 2px); }
header nav { margin-top: auto; }

/* Placering av logga/text och slogan i headern (organisationens val, standard centrerat) */
.header-align-left .logo-wrap { left: 30px; transform: none; }
.header-align-right .logo-wrap { left: auto; right: 30px; transform: none; }
.header-align-left .logo-text,
.header-align-left .org-slogan { align-self: flex-start; margin-left: 30px; text-align: left; justify-content: flex-start; padding-left: 0; }
.header-align-right .logo-text,
.header-align-right .org-slogan { align-self: flex-end; margin-right: 30px; text-align: right; justify-content: flex-end; padding-right: 0; }

main {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
}

/* Helt genomskinligt skyddslager över headerns bakgrund och logga, men under menyn.
   Det tar emot klick, högerklick och drag så att loggan och bakgrunden inte går att
   klicka på eller spara/dra ut. Det tonar inte ner något. */
.header-overlay {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: transparent;
    z-index: 1;
}

.logo {
    user-select: none;
    -webkit-user-drag: none;
}

nav {
    position: relative;
    z-index: 5; /* över .header-overlay */
    box-sizing: border-box;
    text-align: center;
    width: 100%;
    padding: 0 10px;
}

nav ul.main-nav {
    display: inline-flex;
    background-color: rgba(var(--org-menu-rgb), 0.7);
    border-radius: 8px;
    padding: 5px;
    list-style-type: none;
    margin: 0;
    justify-content: center;
    flex-wrap: wrap;
}

nav ul.main-nav li {
    margin: 0 10px;
}

nav ul.main-nav > li > a {
    text-decoration: none;
    color: var(--org-menu-text);
    padding: 8px 12px;
    display: block;
}

nav ul.main-nav li a:hover {
    text-decoration: underline;
}

/* --- Undermenyer i huvudmenyn --- */
nav ul.main-nav li.has-sub {
    position: relative;
}

nav ul.main-nav ul.submenu {
    display: none;
    position: absolute;
    left: 0;
    top: 100%;
    min-width: 200px;
    background-color: rgb(var(--org-menu-rgb));
    border-radius: 6px;
    padding: 5px;
    margin: 0;
    list-style: none;
    text-align: left;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.25);
    z-index: 15;
}

nav ul.main-nav li.has-sub:hover > ul.submenu,
nav ul.main-nav li.has-sub:focus-within > ul.submenu {
    display: block;
}

nav ul.main-nav ul.submenu li {
    margin: 0;
}

nav ul.main-nav ul.submenu a {
    display: block;
    padding: 8px 12px;
    color: var(--org-menu-text);
    text-decoration: none;
    white-space: nowrap;
}

nav ul.main-nav a.menu-label {
    cursor: default;
}

/* --- Dropdown Styles --- */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown .dropbtn {
    color: white;
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    padding: 8px 12px;
    display: block;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    background-color: #f1f1f1;
    min-width: 200px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 10;
    border-radius: 5px;
    overflow: hidden;
    text-align: left;
}

.dropdown-content a {
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
}

.dropdown-content a:hover {
    background-color: #ddd;
    text-decoration: none;
}

.dropdown:hover .dropdown-content {
    display: block;
}

.dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid #ddd;
    background-color: #e9ecef;
    color: #495057;
    font-size: 0.9em;
}

/* --- User Menu Styles --- */
.user-menu {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 11;
}

.user-menu .user-icon {
    background-color: var(--org-accent);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 16px;
    font-weight: bold;
    color: var(--org-accent-text);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: transform 0.2s ease-in-out;
}

.user-menu .user-icon:hover {
    transform: scale(1.1);
}

.login-button {
    background-color: var(--org-accent);
    color: var(--org-accent-text);
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 5px;
    transition: background-color 0.2s;
}

/* Dölj hamburgarknappen som standard (dator & surfplatta) */
.menu-toggle {
    display: none;
}

footer {
    border-radius: 0 0 15px 15px;
    background: linear-gradient(rgba(var(--org-footer-rgb), 0.8), rgba(var(--org-footer-rgb), 0.8)), var(--org-header-bg, none);
    background-position: bottom;
    color: var(--org-footer-text);
    padding: 0;
    text-align: center;
    height: 30px;
    line-height: 30px;
    flex-shrink: 0;
}

footer p {
    margin: 0;
}

footer a {
    color: var(--org-footer-text);
    text-decoration: underline;
}

footer a:hover {
    text-decoration: none;
}

/* ==========================================
   RESPONSIVA ANPASSNINGAR (SURFPLATTA & MOBIL)
   ================================---------- */

/* Surfplatta (skärmar upp till 768px) - Behåller den vanliga menyn */
@media screen and (max-width: 768px) {
    .container {
        max-width: 95%;
        margin: 10px auto;
        min-height: calc(100vh - 20px);
        border-radius: 10px;
    }

    header {
        height: calc(var(--org-header-height, 250px) * 0.8);
    }

    .logo-wrap { top: 10px; }

    .logo {
        height: calc(var(--org-logo-height, 180px) * 0.67);
    }

    .org-slogan.below-logo { margin-top: calc(var(--org-logo-height, 180px) * 0.67 + 2px); }

    nav ul.main-nav {
        flex-wrap: wrap;
        max-width: 100%;
    }

    nav ul.main-nav li {
        margin: 0 5px;
    }
}

/* Mobiltelefon (skärmar upp till 480px) - Aktiverar modern hamburgarmeny */
@media screen and (max-width: 480px) {
    .container {
        margin: 0;
        max-width: 100%;
        width: 100%;
        min-height: 100vh;
        border-radius: 0;
        box-shadow: none;
    }

    header {
        height: calc(var(--org-header-height, 250px) * 0.56);
        justify-content: flex-start;
    }

    .logo-wrap { top: 10px; }

    .logo {
        height: calc(var(--org-logo-height, 180px) * 0.39);
    }

    .org-slogan.below-logo { margin-top: calc(var(--org-logo-height, 180px) * 0.39 + 2px); }

    .user-menu {
        top: 12px;
        right: 12px;
    }

    .user-menu .user-icon {
        width: 32px;
        height: 32px;
        font-size: 13px;
    }

    /* Modern Hamburgarknapp */
    .menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 0;
        position: absolute;
        top: 15px;
        left: 15px;
        z-index: 12;
        color: var(--org-menu-text);
        font-size: 1.8rem;
    }

    .main-nav-container {
        display: none;
        position: absolute;
        top: 140px;
        left: 0;
        width: 100%;
        background-color: rgba(var(--org-menu-rgb), 0.95);
        box-shadow: 0 4px 8px rgba(0,0,0,0.3);
        z-index: 20;
        padding: 15px 0;
    }

    .main-nav-container.active {
        display: block;
    }

    nav ul.main-nav {
        display: flex;
        flex-direction: column;
        width: 100%;
        background-color: transparent;
        padding: 0;
    }

    nav ul.main-nav li {
        margin: 5px 0;
        text-align: center;
    }

    nav ul.main-nav > li > a,
    .dropdown .dropbtn {
        padding: 10px;
        font-size: 1rem;
        display: block;
        width: 100%;
    }

    nav ul.main-nav ul.submenu {
        display: block;
        position: static;
        background-color: rgba(0, 0, 0, 0.2);
        box-shadow: none;
        text-align: center;
    }

    .dropdown-content {
        position: static;
        box-shadow: none;
        background-color: rgba(0, 0, 0, 0.2);
        width: 100%;
    }

    .dropdown-content a {
        color: white;
        text-align: center;
    }

    .dropdown-content a:hover {
        background-color: rgba(255, 255, 255, 0.1);
    }

    .dropdown-header {
        background-color: rgba(0, 0, 0, 0.3);
        color: white;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        text-align: center;
    }

    main {
        padding: 12px;
    }
}
/* --- SBSLogik Klubb --- */
.clickable-row { cursor: pointer; }
.org-content img { max-width: 100%; height: auto; }
.org-content table { width: 100%; }
.error-page { text-align: center; padding: 40px 0; }
