/* VisionLAN - Layout: app shell, sidebar, topbar, content area, fullscreen, responsive */

/* ══════════════════════════════════════════
   APP SHELL
   ══════════════════════════════════════════ */

.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
    padding: 0.75rem;
    gap: 0.75rem;
}

/* ── Sidebar ── */
.app-sidebar {
    width: var(--vl-sidebar-width);
    min-width: var(--vl-sidebar-width);
    height: auto;
    display: flex;
    flex-direction: column;
    background: var(--vl-bg-card);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--vl-glass-border);
    border-radius: var(--vl-radius);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
}

.sidebar-brand {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--vl-glass-border);
}

.sidebar-brand a {
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-logo {
    height: 22px;
    width: auto;
    max-width: 100%;
    opacity: 0.95;
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    border-radius: var(--vl-radius-xs);
    color: var(--vl-text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.sidebar-link i {
    width: 20px;
    text-align: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.sidebar-link:hover {
    background: var(--vl-glass);
    color: var(--vl-text);
}

.sidebar-link.active {
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.15), rgba(0, 206, 201, 0.08));
    color: var(--vl-accent);
}

.sidebar-link.active i {
    color: var(--vl-accent);
}

.sidebar-badge {
    margin-left: auto;
    background: #dc3545;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    border-radius: 9px;
    padding: 0 5px;
}

/* ── Sidebar dropdown groups ── */
.sidebar-group-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    border-radius: var(--vl-radius-xs);
    color: var(--vl-text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
}

.sidebar-group-toggle i.group-icon {
    width: 20px;
    text-align: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.sidebar-group-toggle .group-chevron {
    margin-left: auto;
    font-size: 0.7rem;
    transition: transform 0.2s ease;
    opacity: 0.5;
}

.sidebar-group-toggle:hover {
    background: var(--vl-glass);
    color: var(--vl-text);
}

.sidebar-group.open > .sidebar-group-toggle {
    color: var(--vl-text);
}

.sidebar-group.open > .sidebar-group-toggle .group-chevron {
    transform: rotate(90deg);
}

.sidebar-group-items {
    display: none;
    flex-direction: column;
    gap: 1px;
    padding-left: 0.5rem;
}

.sidebar-group.open > .sidebar-group-items {
    display: flex;
}

.sidebar-group-items .sidebar-link {
    font-size: 0.825rem;
    padding: 0.45rem 0.85rem;
}

/* ── Sidebar event selector ── */
.sidebar-event-selector {
    position: relative;
    margin-bottom: 0.25rem;
}

.sidebar-event-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.55rem 0.85rem;
    border-radius: var(--vl-radius-xs);
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.12), rgba(0, 206, 201, 0.06));
    border: 1px solid rgba(108, 92, 231, 0.2);
    color: var(--vl-text);
    font-size: 0.825rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
}

.sidebar-event-btn:hover {
    border-color: rgba(108, 92, 231, 0.35);
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.18), rgba(0, 206, 201, 0.1));
}

.sidebar-event-btn > i:first-child {
    width: 20px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--vl-primary);
    flex-shrink: 0;
}

.sidebar-event-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-event-chevron {
    font-size: 0.6rem;
    opacity: 0.5;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.sidebar-event-dropdown.open + .sidebar-event-btn .sidebar-event-chevron,
.sidebar-event-dropdown.open ~ .sidebar-event-btn .sidebar-event-chevron {
    transform: rotate(180deg);
}

.sidebar-event-dropdown {
    display: none;
    flex-direction: column;
    gap: 1px;
    margin-top: 0.25rem;
    padding: 0.25rem;
    background: var(--vl-bg-card-solid);
    border: 1px solid var(--vl-glass-border);
    border-radius: var(--vl-radius-xs);
    max-height: 200px;
    overflow-y: auto;
}

.sidebar-event-dropdown.open {
    display: flex;
}

.sidebar-event-option {
    display: block;
    width: 100%;
    padding: 0.4rem 0.6rem;
    border: none;
    border-radius: var(--vl-radius-xs);
    background: none;
    color: var(--vl-text-muted);
    font-size: 0.8rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.1s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-event-option:hover {
    background: var(--vl-glass);
    color: var(--vl-text);
}

.sidebar-event-option.active {
    background: rgba(108, 92, 231, 0.15);
    color: var(--vl-accent);
    font-weight: 500;
}

/* ── Sidebar divider ── */
.sidebar-divider {
    height: 1px;
    background: var(--vl-glass-border);
    margin: 0.5rem 0.85rem;
}

.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--vl-glass-border);
}

.sidebar-switch {
    color: var(--vl-text-muted) !important;
    font-size: 0.825rem;
}

.sidebar-switch:hover {
    color: var(--vl-accent) !important;
}

/* ── Main area ── */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    padding: 0;
}

/* ── Topbar ── */
.app-topbar {
    height: var(--vl-topbar-height);
    min-height: var(--vl-topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.5rem;
    background: transparent;
    border: none;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar-back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--vl-radius-xs);
    color: var(--vl-text-muted);
    text-decoration: none;
    font-size: 0.8rem;
    transition: color 0.15s, background 0.15s;
}

.topbar-back:hover {
    color: var(--vl-text);
    background: var(--vl-glass);
}

.topbar-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.01em;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--vl-text-muted);
    font-size: 1.1rem;
    padding: 0.4rem;
    cursor: pointer;
    border-radius: var(--vl-radius-xs);
    transition: all 0.15s;
}

.sidebar-toggle:hover {
    color: var(--vl-text);
    background: var(--vl-glass);
}

.topbar-right {
    display: flex;
    align-items: center;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: none;
    border: 1px solid transparent;
    color: var(--vl-text);
    padding: 0.35rem 0.6rem;
    border-radius: var(--vl-radius-xs);
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.875rem;
}

.topbar-user:hover {
    background: var(--vl-glass);
    border-color: var(--vl-glass-border);
}

.topbar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.topbar-avatar-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    background: var(--vl-gradient-accent);
    color: #fff;
    flex-shrink: 0;
}

.topbar-username {
    font-weight: 500;
}

.topbar-icon-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--vl-radius-xs);
    color: var(--vl-text-muted);
    font-size: 1.1rem;
    text-decoration: none;
    transition: all 0.15s;
    margin-right: 0.5rem;
}

.topbar-icon-btn:hover {
    color: var(--vl-text);
    background: var(--vl-glass);
}

.topbar-badge {
    position: absolute;
    top: 2px;
    right: 0;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: var(--bs-danger, #dc3545);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}

.topbar-chevron {
    font-size: 0.65rem;
    color: var(--vl-text-muted);
}

/* ── Content area ── */
.app-content {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 1.5rem 1.5rem;
    /* Hold plass til rullefeltet ogsaa naar det ikke trengs. Uten dette
       skifter innholdsbredden i det en side blir hoeyere enn skjermen, og alt
       som er midtstilt rykker sideveis. */
    scrollbar-gutter: stable;
}

.app-content > * {
    max-width: var(--vl-content-width, 900px);
    margin-left: auto;
    margin-right: auto;
}

/* Content width modifiers — apply to the page root element */
.content-sm  { --vl-content-width: 640px; }
.content-md  { --vl-content-width: 900px; }   /* default */
.content-lg  { --vl-content-width: 1100px; }
.content-xl  { --vl-content-width: 1400px; }
.content-full { --vl-content-width: 100%; }

/* Compact card padding in editor sidebars */
.content-xl .col-lg-3 .card-body { padding: 1rem; }

/* ══════════════════════════════════════════
   FULLSCREEN PAGES (login, register, etc)
   ══════════════════════════════════════════ */

body.fullscreen-page {
    overflow: auto;
}

body.fullscreen-page #app-fullscreen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: radial-gradient(ellipse at 20% 50%, rgba(108, 92, 231, 0.12) 0%, transparent 50%),
                radial-gradient(ellipse at 80% 20%, rgba(0, 206, 201, 0.08) 0%, transparent 50%),
                radial-gradient(ellipse at 50% 100%, rgba(108, 92, 231, 0.06) 0%, transparent 50%),
                var(--vl-gradient);
    background-attachment: fixed;
}

/* Meeting pages — top-aligned, full width */
body.fullscreen-page #app-fullscreen:has(.meeting-page) {
    align-items: flex-start;
    justify-content: flex-start;
}
body.fullscreen-page #app-fullscreen:has(.meeting-page) #app-content-full {
    width: 100%;
}

/* Fullscreen pages that need full width.
   Glemmer du en klasse her, faar siden fortsatt #app-fullscreen sin sentrering
   og padding — den ser da ut som et smalt kort midt paa en tom skjerm. */
body.fullscreen-page #app-fullscreen:has(.checkin-station),
body.fullscreen-page #app-fullscreen:has(.pos-station),
body.fullscreen-page #app-fullscreen:has(.kitchen-station) {
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
}

body.fullscreen-page #app-fullscreen:has(.checkin-station) #app-content-full,
body.fullscreen-page #app-fullscreen:has(.pos-station) #app-content-full,
body.fullscreen-page #app-fullscreen:has(.kitchen-station) #app-content-full {
    width: 100%;
}

/* Embed pages — no padding, no centering, fill viewport exactly */
body.fullscreen-page #app-fullscreen:has(.sched-embed),
body.fullscreen-page #app-fullscreen:has(.pos-display),
body.fullscreen-page #app-fullscreen:has(.kiosk-embed) {
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
    min-height: 100vh;
    height: 100vh;
    overflow: hidden;
}
body.fullscreen-page #app-fullscreen:has(.sched-embed) #app-content-full,
body.fullscreen-page #app-fullscreen:has(.pos-display) #app-content-full,
body.fullscreen-page #app-fullscreen:has(.kiosk-embed) #app-content-full {
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

/* ══════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════ */

@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 1000;
        box-shadow: none;
    }

    .app-sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
    }
}

@media (max-width: 576px) {
    .app-content {
        padding: 1rem;
    }
}

/* ══════════════════════════════════════════
   /app UTEN SIDEBAR
   Hub-en paa /app er navigasjonen; undersider navigerer med tilbake-knappen
   i topbaren. /admin beholder sidebaren — der er arbeidet tett sidelengs.
   ══════════════════════════════════════════ */

.app-shell--plain .app-sidebar { display: none; }

/* Logo i topbaren paa hub-en. Sidebaren bar identiteten foer; naa er dette
   eneste stedet den bor i /app. */
.topbar-brand {
    display: flex;
    align-items: center;
    padding: 0 0.25rem;
    text-decoration: none;
}
.topbar-logo {
    height: 22px;
    width: auto;
    opacity: 0.95;
}

/* Tilbake-knappen navngir destinasjonen. Etiketten beholdes ogsaa paa mobil —
   den er hele poenget med knappen; det er tittelen som faar trunkere. */
.topbar-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    flex-shrink: 0;
    height: 34px;
    padding: 0 0.75rem 0 0.6rem;
    border-radius: 99px;
    border: 1px solid var(--vl-glass-border);
    background: var(--vl-glass);
    color: var(--vl-text-muted);
    font-size: 0.85rem;
    font-weight: 550;
    text-decoration: none;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.topbar-back-btn:hover {
    color: var(--vl-text);
    border-color: rgba(255, 255, 255, 0.2);
}
.topbar-back-btn i { font-size: 0.8rem; }

/* Uten min-width:0 kan ikke tittelen trunkere, og lange sidetitler dytter
   meldinger og avatar ut av topbaren paa smale skjermer. */
.topbar-left { min-width: 0; }
.topbar-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ══════════════════════════════════════════
   PANELIDENTITET — /app, /crew, /admin
   ══════════════════════════════════════════
   Tre huber med samme oppbygning ser like ut. Bakgrunnen gir et umiddelbart
   «hvor er jeg» uten aa lese noe, merkelappen i topbaren gir svaret i klartekst.

   Fargene er dempet med vilje: nok til aa merke skiftet i oyekroken, ikke nok
   til aa gjore panelet til et annet produkt. Kontrasten mot tekst er uendret —
   bare mellomstoppene i gradienten flyttes. */

body.panel-crew {
    /* Teal, samme familie som --vl-accent. Crew er «paa vakt». */
    --vl-gradient: linear-gradient(135deg, #0a1418 0%, #0e2027 40%, #0c1b22 70%, #0a1418 100%);
}

body.panel-admin {
    /* Lilla, samme familie som --vl-primary. Admin er «system». */
    --vl-gradient: linear-gradient(135deg, #0c0a17 0%, #171129 40%, #130f26 70%, #0c0a17 100%);
}

/* Merkelappen ved siden av logoen paa hub-ene. */
.topbar-panel-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    border-radius: 99px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border: 1px solid;
    line-height: 1.4;
}
body.panel-crew .topbar-panel-badge {
    color: var(--vl-accent);
    border-color: rgba(0, 206, 201, 0.35);
    background: rgba(0, 206, 201, 0.1);
}
body.panel-admin .topbar-panel-badge {
    color: #a29bfe;
    border-color: rgba(162, 155, 254, 0.35);
    background: rgba(162, 155, 254, 0.1);
}
