/* =========================================
   1. VARIABLER OG RESET
   ========================================= */
:root {
    --primary: #FA5900;
    --bg-dark: #121212;
    --bg-panel: #1e1e1e;
    --bg-sidebar: #000000;
    --text-main: #ffffff;
    --text-muted: #aaaaaa;
    --border: #333333;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden; /* Standard PC: Låser scroll på body */
}

/* =========================================
   2. HOVEDLAYOUT (DESKTOP)
   ========================================= */
.admin-wrapper {
    display: grid;
    grid-template-columns: 260px 1fr; /* 260px sidebar, resten innhold */
    height: 100vh;
    width: 100%;
}

/* Skjul mobil-ting på PC */
.mobile-toggle-btn { display: none; }
.desktop-only { display: inline-block; }

/* Overlay (Kun for mobil) */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 900;
    backdrop-filter: blur(3px);
}

/* =========================================
   3. SIDEBAR (MENY)
   ========================================= */
.sidebar {
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    overflow-y: auto;
    z-index: 1000;
    height: 100%;
}

.brand {
    color: var(--primary);
    font-size: 1.5rem;
    font-weight: bold;
    text-align: center;
    margin-bottom: 30px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-menu ul { list-style: none; }

.sidebar-menu li a {
    display: flex;
    align-items: center;
    padding: 15px 25px;
    color: var(--text-muted);
    text-decoration: none;
    transition: 0.3s;
    border-left: 4px solid transparent;
}

.sidebar-menu li a:hover, .sidebar-menu li a.active {
    background-color: #1a1a1a;
    color: #fff;
    border-left-color: var(--primary);
}

.sidebar-icon {
    width: 24px;
    margin-right: 15px;
    filter: grayscale(100%);
    transition: 0.3s;
}

.sidebar-menu li a:hover .sidebar-icon, 
.sidebar-menu li a.active .sidebar-icon { 
    filter: none; 
}

/* =========================================
   4. INNHOLD (MAIN CONTENT)
   ========================================= */
.main-content {
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* Scroller innholdet */
    position: relative;
    background-color: var(--bg-dark);
}

/* Top Bar */
.top-bar {
    background-color: var(--bg-panel);
    padding: 15px 30px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 800;
}

.user-info { font-weight: bold; color: #fff; display: flex; align-items: center; gap: 10px; }

.logout-btn {
    color: #ff4d4d;
    text-decoration: none;
    font-size: 0.9rem;
    border: 1px solid #ff4d4d;
    padding: 5px 15px;
    border-radius: 4px;
    transition: 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.logout-btn:hover { background: #ff4d4d; color: #fff; }

/* Page Content */
.page-content { padding: 30px; }

h1.page-title {
    font-size: 1.8rem;
    margin-bottom: 20px;
    color: var(--primary);
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

/* =========================================
   5. KOMPONENTER
   ========================================= */

/* KORT */
.card, .dash-card {
    background: var(--bg-panel);
    padding: 25px;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

/* KNAPPER */
.btn, .btn-outline, .btn-cta, .btn-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 5px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    cursor: pointer;
    line-height: 1.2;
    border: none;
}

.btn, .btn-cta { background-color: var(--primary); color: #fff; }
.btn:hover, .btn-cta:hover { background-color: #e04e00; transform: translateY(-1px); }

.btn-outline { background-color: transparent; border: 1px solid #555; color: #ccc; }
.btn-outline:hover { border-color: var(--primary); color: #fff; background-color: rgba(250, 89, 0, 0.1); }

.btn-small { padding: 5px 10px; font-size: 0.8rem; }

/* SKJEMA */
input[type="text"], input[type="password"], input[type="email"], 
input[type="number"], input[type="date"], input[type="time"], 
textarea, select {
    background: #2a2a2a;
    border: 1px solid #444;
    color: #fff;
    padding: 10px;
    border-radius: 4px;
    width: 100%;
    font-size: 1rem;
    outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); }

/* TABELLER */
.admin-table-wrapper { overflow-x: auto; }
.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-panel);
    border-radius: 8px;
    overflow: hidden;
    min-width: 600px;
}
.admin-table th, .admin-table td { padding: 15px; text-align: left; border-bottom: 1px solid var(--border); }
.admin-table th { background-color: #252525; color: var(--primary); font-weight: bold; text-transform: uppercase; font-size: 0.85rem; }
.admin-table tr:hover { background-color: #2a2a2a; }

/* DASHBOARD */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
}
.dash-card { display: flex; align-items: center; transition: transform 0.2s; }
.dash-card:hover { transform: translateY(-5px); border-color: var(--primary); }
.dash-icon { font-size: 2rem; margin-right: 20px; color: var(--primary); }
.dash-info h3 { font-size: 2rem; margin: 0; color: #fff; }
.dash-info span { color: var(--text-muted); text-transform: uppercase; font-size: 0.85rem; }

/* ALERTS */
.alert { padding: 15px; margin-bottom: 20px; border-radius: 5px; font-weight: bold; display: flex; align-items: center; gap: 10px; }
.alert-success { background: rgba(40,167,69,0.2); color: #28a745; border: 1px solid #28a745; }
.alert-error { background: rgba(220,53,69,0.2); color: #dc3545; border: 1px solid #dc3545; }

/* TRENERE & PARTNERE */
.staff-list { display: flex; flex-direction: column; gap: 15px; max-width: 1000px; }
.staff-card { display: flex; align-items: center; background-color: var(--bg-panel); border: 1px solid var(--border); border-radius: 8px; padding: 20px; transition: background 0.2s; }
.staff-card:hover { border-color: var(--primary); background-color: #252525; }
.staff-img { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; margin-right: 25px; border: 2px solid var(--primary); flex-shrink: 0; }
.staff-info { flex-grow: 1; }
.staff-info h3 { margin: 0 0 5px 0; font-size: 1.2rem; color: #fff; }
.staff-meta { display: block; color: #aaa; font-size: 0.9rem; margin-bottom: 5px; }
.staff-actions { display: flex; gap: 10px; }

.partner-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; }
.partner-card { background: #fff; padding: 20px; border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; border: 1px solid #ccc; height: 100%; transition: transform 0.2s; }
.partner-card:hover { transform: translateY(-5px); border-color: var(--primary); }
.partner-img { max-width: 100%; max-height: 80px; object-fit: contain; margin-bottom: 15px; }
.partner-actions { margin-top: 10px; width: 100%; display: flex; justify-content: center; gap: 10px; }


/* =========================================
   6. MOBIL RESPONSIVITET (Override)
   ========================================= */
@media (max-width: 1000px) {
    
    /* Skjul PC-ting */
    .desktop-only { display: none !important; }

    /* 1. LÅS OPP SCROLLING (Viktig fiks!) */
    body {
        overflow: auto !important;
        height: auto !important;
    }

    .main-content {
        overflow: visible !important;
        height: auto !important;
    }

    /* 2. Endre grid til blokk (dette fikser den ødelagte layouten du så) */
    .admin-wrapper {
        display: block; 
        position: relative;
        height: auto !important;
    }

    /* 3. Flytt sidebar UT av skjermen */
    .sidebar {
        position: fixed;
        top: 0;
        left: -280px; 
        width: 260px;
        height: 100%;
        transition: left 0.3s ease-in-out;
        box-shadow: 5px 0 15px rgba(0,0,0,0.5);
        z-index: 2000;
    }

    .sidebar.active { left: 0; }

    /* 4. Vis meny-knappen */
    .mobile-toggle-btn {
        display: block;
        background: transparent;
        border: none;
        color: var(--primary);
        font-size: 1.5rem;
        cursor: pointer;
        padding: 5px 10px;
        margin-right: 10px;
    }

    /* 5. Innholdsjusteringer */
    .page-content { padding: 15px; }
    .top-bar { padding: 10px 15px; position: sticky; top: 0; z-index: 800; }
    .admin-wrapper-split { grid-template-columns: 1fr !important; }

    /* 6. Lister */
    .staff-card { flex-direction: column; text-align: center; }
    .staff-img { margin-right: 0; margin-bottom: 15px; }
    .staff-actions { width: 100%; margin-top: 15px; justify-content: center; }
    .partner-grid { grid-template-columns: 1fr 1fr; }
}
/* =========================================
   7. INNLOGGING OG SIKKERHETSSIDER
   ========================================= */
.login-body { height: auto; overflow: auto; }
.login-side { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: #121212; }
.login-kort { width: 100%; max-width: 400px; padding: 40px; background: #1e1e1e; border: 1px solid #333; border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.login-kort h1 { font-size: 1.5rem; margin-bottom: 20px; }
.login-merke { color: var(--primary); font-size: 1.5rem; font-weight: bold; text-transform: uppercase; letter-spacing: 1px; text-align: center; margin-bottom: 28px; line-height: 1.3; }
.login-merke small { display: block; color: #666; font-size: .75rem; font-weight: normal; }
.login-kort label { display: block; color: var(--text-muted); font-size: .9rem; margin: 14px 0 4px; }
.login-knapp { width: 100%; margin-top: 24px; padding: 12px; font-size: 1.05rem; }
.login-liten { text-align: center; margin-top: 20px; font-size: .85rem; }
.login-liten a, .login-kort a:not(.btn) { color: var(--text-muted); }
.login-kort a:not(.btn):hover { color: #fff; }

button.logout-btn { background: transparent; cursor: pointer; font: inherit; font-size: .9rem; }
.alert i { flex: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
button[disabled], input[disabled] { opacity: .6; cursor: wait; }

/* Menyikoner (Font Awesome) */
i.sidebar-icon { width: 24px; margin-right: 15px; text-align: center; font-size: 1.05rem; color: #777; filter: none; transition: 0.3s; flex: none; }
.sidebar-menu li a:hover i.sidebar-icon, .sidebar-menu li a.active i.sidebar-icon { color: var(--primary); }

/* =========================================
   8. NYE KOMPONENTER (felles admin-motor)
   ========================================= */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-header h1.page-title { margin-bottom: 4px; border-bottom: 0; padding-bottom: 0; }
.undertittel { color: var(--text-muted); font-size: .92rem; max-width: 720px; }
.topp-knapper { display: flex; gap: 10px; flex-wrap: wrap; }
.dempet, .dempet a { color: #888; }
.under-tittel { font-size: 1.15rem; margin: 28px 0 12px; color: #fff; }
.kort-tittel { font-size: 1.05rem; color: var(--primary); margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.kort-topp { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.kort-topp h3 { color: #fff; font-size: 1.05rem; }
a.dash-card { text-decoration: none; color: inherit; }

/* Skjema */
.skjema .felt { margin-bottom: 20px; }
.skjema label, .skjema .etikett { display: block; color: #ccc; font-size: .9rem; margin-bottom: 6px; font-weight: 600; }
.skjema label.avkryss { display: flex; align-items: center; gap: 10px; font-weight: normal; cursor: pointer; margin-bottom: 6px; }
.skjema label.avkryss input { width: auto; flex: none; }
.krav { color: #ff7a7a; }
.hjelp { display: block; color: #888; font-size: .82rem; margin-top: 6px; line-height: 1.4; }
.felt-feil input, .felt-feil select, .felt-feil textarea { border-color: #dc3545 !important; box-shadow: 0 0 0 2px rgba(220,53,69,.25); }
.feilmelding { color: #ff7a7a; font-size: .88rem; margin-top: 6px; font-weight: 600; }
.feilmelding::before { content: "\26A0\FE0E  "; }
.flervalg { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 20px; background: #1a1a1a; border: 1px solid var(--border); border-radius: 6px; padding: 12px 14px; }
details.gruppe { border: 1px solid var(--border); border-radius: 6px; margin: 4px 0 20px; padding: 0 16px; background: #1a1a1a; }
details.gruppe summary { cursor: pointer; padding: 12px 0; color: #aaa; font-weight: 600; }
details.gruppe[open] summary { border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.skjema-knapper { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; padding-top: 18px; border-top: 1px solid var(--border); }
textarea { min-height: 90px; resize: vertical; line-height: 1.5; font-family: inherit; }
.rik-verktoy { display: flex; gap: 6px; margin-bottom: 6px; }
.rik-verktoy button { background: #2a2a2a; border: 1px solid #444; color: #ddd; border-radius: 4px; padding: 4px 11px; cursor: pointer; font: inherit; font-size: .85rem; }
.rik-verktoy button:hover { border-color: var(--primary); color: #fff; }
.forhandsvis { margin-top: 10px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.forhandsvis img { max-width: 220px; max-height: 140px; object-fit: cover; border-radius: 6px; border: 1px solid #444; }
input[type=file] { color: #ccc; padding: 8px; }

/* Lister */
.admin-table td.handling, .admin-table th.handling { text-align: right; white-space: nowrap; }
.admin-table td { vertical-align: middle; }
.miniatyr { width: 64px; height: 48px; object-fit: cover; border-radius: 4px; border: 1px solid #444; display: block; }
.ingen-bilde { width: 64px; height: 48px; display: flex; align-items: center; justify-content: center; background: #222; border: 1px dashed #555; border-radius: 4px; color: #666; }
.inline-skjema { display: inline; margin: 0; }
.btn-fare { background: transparent; border: 1px solid #d9534f; color: #ff7a7a; }
.btn-fare:hover { background: #d9534f; color: #fff; }
.btn.deaktivert { opacity: .4; cursor: not-allowed; }
.soke-rad { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.soke-rad input[type=search] { max-width: 320px; background: #2a2a2a; border: 1px solid #444; color: #fff; padding: 10px; border-radius: 4px; }
.sider, .sider-info { display: flex; gap: 14px; align-items: center; justify-content: center; margin: 22px 0; color: #888; font-size: .9rem; }
.tomt { text-align: center; color: #888; padding: 40px 20px; }
.tomt i { font-size: 2rem; display: block; margin-bottom: 10px; color: #555; }
.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 10px; background: #333; color: #ddd; vertical-align: middle; }
.badge-gronn { background: rgba(40,167,69,.2); color: #5ddc7c; }
.badge-gul { background: rgba(255,193,7,.2); color: #ffd04d; }
.badge-rod { background: rgba(220,53,69,.2); color: #ff7a7a; }
.badge-blaa { background: rgba(23,162,184,.2); color: #5bd0e6; }
.badge-gra { background: #333; color: #aaa; }
.fremdrift { height: 6px; background: #333; border-radius: 3px; margin-top: 6px; overflow: hidden; width: 120px; }
.fremdrift div { height: 100%; background: var(--primary); }

/* Oversikt */
.admin-wrapper-split { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.hurtig { display: flex; flex-direction: column; gap: 10px; }
.logg-liste, .tips { list-style: none; margin: 0 0 12px; padding: 0; }
.logg-liste li { padding: 9px 0; border-bottom: 1px solid #2a2a2a; font-size: .9rem; }
.tips li { padding: 8px 0; color: #ddd; }
.tips li i { color: var(--primary); width: 22px; }
.tips a { color: var(--primary); }
.meny-gruppe { text-transform: uppercase; letter-spacing: .09em; font-size: .7rem; color: #666; padding: 18px 25px 6px; }

/* Statistikk */
.soyler { display: flex; align-items: flex-end; gap: 8px; height: 190px; padding-top: 18px; }
.soyle { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-width: 0; }
.soyle .stolpe { width: 100%; max-width: 46px; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 2px; }
.soyle .verdi { font-size: .72rem; color: #aaa; margin-bottom: 4px; }
.soyle .navn { font-size: .75rem; color: #888; margin-top: 6px; }

/* Hjelp */
.hjelp-kort { padding: 16px 22px; margin-bottom: 10px; }
.hjelp-tittel { color: #fff; font-weight: 600; text-decoration: none; display: block; }
.hjelp-kort.apen .hjelp-tittel { color: var(--primary); }
.hjelp-kort ul { margin: 14px 0 0 20px; line-height: 1.7; color: #ccc; }
.hjelp-kort li { margin-bottom: 8px; }

@media (max-width: 1000px) {
	.admin-wrapper-split { grid-template-columns: 1fr; }
	.admin-table thead { display: none; }
	.admin-table, .admin-table tbody, .admin-table tr, .admin-table td { display: block; width: 100%; min-width: 0; }
	.admin-table tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
	.admin-table td { padding: 4px 0; border: 0; }
	.admin-table td[data-label]::before { content: attr(data-label) ": "; color: #777; font-size: .78rem; }
	.admin-table td.handling { text-align: left; padding-top: 10px; }
}

/* =========================================
   9. LENKER, MELDINGER OG FANER
   ========================================= */
/* Vanlige lenker i adminpanelet skal følge designet (ikke nettleserens blå) */
.page-content a:not(.btn):not(.btn-outline):not(.btn-small):not(.fane):not(.hjelp-tittel):not(.dash-card) { color: var(--primary); text-decoration: none; }
.page-content a:not(.btn):not(.btn-outline):not(.btn-small):not(.fane):not(.hjelp-tittel):not(.dash-card):hover { text-decoration: underline; color: #ff8a3d; }
.page-content a:visited:not(.btn) { color: var(--primary); }
.admin-table a:not(.btn) { word-break: break-all; }
a.btn, a.btn:visited { color: #fff; text-decoration: none; }
a.btn.btn-outline { color: #ccc; }
a.btn.btn-outline:hover { color: #fff; }
a.btn-fare, .btn-fare { color: #ff7a7a; }
.dempet a { color: #999; }

.meny-merke { margin-left: auto; background: var(--primary); color: #fff; font-size: .7rem; font-weight: 700; padding: 1px 8px; border-radius: 10px; }
.sidebar-menu li a { align-items: center; }

.faner { display: flex; gap: 6px; margin-bottom: 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.fane { padding: 10px 18px; color: #aaa; text-decoration: none; border-bottom: 3px solid transparent; font-weight: 600; margin-bottom: -1px; }
.fane:hover { color: #fff; }
.fane.aktiv { color: #fff; border-bottom-color: var(--primary); }
tr.uleste td { background: rgba(250, 89, 0, .06); }
tr.uleste td b { color: #fff; }

.melding-kort { padding: 0; overflow: hidden; }
.melding-hode { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 18px 24px; background: #252525; border-bottom: 1px solid var(--border); }
.melding-tekst { padding: 22px 24px; line-height: 1.7; color: #e5e5e5; white-space: normal; word-break: break-word; }
.card > .melding-tekst { padding: 0; }
