/*
 * Material Design 3 theme, via Google's official "Material Web" component
 * library (see assets/app.js for the imports, README.md "UI kit" for why).
 *
 * This file itself only ever does two things: (1) map our brand colors onto
 * Material's own design tokens (the --md-sys-color-* custom properties
 * below), which is exactly the hook a real design kit/theme plugs into
 * later — swap the values, not the markup; and (2) lay out our own
 * page structure (sidebar, cards, grids) around the Material components,
 * which style themselves internally and are not touched here.
 *
 * The values below are a placeholder brand (indigo), not a real design —
 * the client will provide the actual Material 3 color scheme separately.
 */

/* Material Web's own components fall back to the literal font name "Roboto"
 * internally (see --md-ref-typeface-plain in the vendored component CSS),
 * regardless of what font-family we set on the page. Without it actually
 * being available, our own text (via the "Roboto" below) and the Material
 * components' text silently used two different fallback fonts, which is
 * why they looked inconsistent. Self-hosted (not loaded live from Google,
 * see README.md "UI kit"), same as the icons and the component library. */
@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/roboto-400-xRBWAAv.woff2") format('woff2');
}

@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/roboto-500-_EFgm1W.woff2") format('woff2');
}

@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/roboto-700-hVJMMUj.woff2") format('woff2');
}

:root {
    /* Our own shorthand names, used only by the plain layout below. */
    --color-background: #f4f5f7;
    --color-surface: #ffffff;
    --color-primary: #3f51b5;
    --color-text: #1c1c1e;
    --color-text-muted: #5f6368;
    --color-border: #e0e0e0;
    --color-error: #b3261e;
    --color-error-background: #fdecea;

    --elevation-1: 0 1px 2px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.10);
    --radius: 12px;

    /* Material 3 system color tokens: every md-* component reads these
     * (through the Shadow DOM boundary — custom properties pierce it by
     * design). This is the actual "theme" as far as Material is concerned.
     */
    --md-sys-color-primary: var(--color-primary);
    --md-sys-color-on-primary: #ffffff;
    --md-sys-color-primary-container: #e0e3fa;
    --md-sys-color-on-primary-container: #1a237e;

    --md-sys-color-secondary: var(--color-text-muted);
    --md-sys-color-secondary-container: #eceff1;
    --md-sys-color-on-secondary-container: #263238;

    --md-sys-color-tertiary: var(--color-text-muted);
    --md-sys-color-tertiary-container: #eceff1;

    --md-sys-color-error: var(--color-error);
    --md-sys-color-on-error-container: var(--color-error);

    --md-sys-color-surface-container: var(--color-background);
    --md-sys-color-on-surface: var(--color-text);
    --md-sys-color-on-surface-variant: var(--color-text-muted);

    --md-sys-color-outline: var(--color-border);
    --md-sys-color-shadow: #000000;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    height: 100%;
    font-family: 'Roboto', system-ui, sans-serif;
    color: var(--color-text);
    background-color: var(--color-background);
}

.hangar-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.hangar-tabbar {
    background-color: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 32px;
    flex-shrink: 0;
}

.hangar-tabbar__brand {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    color: var(--color-primary);
    text-decoration: none;
    padding: 16px 0;
}

/* Material Design icons as inline SVG (no icon font to host); they take the
 * text colour of the element around them. */
.hangar-icon {
    display: block;
    width: 24px;
    height: 24px;
    fill: currentColor;
}

/* flex: 1 + min-width: 0 lets this shrink below its content's natural
 * width instead of pushing .hangar-tabbar__actions off-screen; overflow-x
 * then turns "too many tabs" into a horizontal scroll within this nav
 * alone, so the settings/avatar icons on the right stay in a fixed spot
 * and are never covered, no matter the window width or tab count. */
.hangar-tabbar__tabs {
    display: flex;
    align-items: stretch;
    gap: 4px;
    height: 100%;
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
}

/* Material 3 "primary tab" styling: a filled state-layer pill that only
 * appears on hover/active (rounded top corners, like the tab is a card
 * sitting on top of the content below it), plus a bold bottom indicator
 * for the active tab — closer to how Material's own <md-tabs> looks than
 * the plain underline this used to be. */
.hangar-tabbar__tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 14px;
    margin-top: 8px;
    border-radius: var(--radius) var(--radius) 0 0;
    color: var(--color-text-muted);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    /* Behaves like any other link on hover (hand cursor) — dragging is
     * its own explicit gesture (click-and-hold), signaled by the grip
     * icon below, not by the hover cursor. */
    transition: color 120ms ease, border-color 120ms ease, background-color 120ms ease;
}

.hangar-tabbar__tab:hover {
    color: var(--color-text);
    background-color: var(--color-background);
}

.hangar-tabbar__tab.is-active {
    color: var(--color-primary);
    background-color: var(--md-sys-color-primary-container);
    border-bottom-color: var(--color-primary);
    font-weight: 700;
}

/* Always present but faint, so the tabs read as "draggable segments"
 * even before touching one — brightens on hover, and is the one part of
 * the tab with its own explicit grab cursor. */
.hangar-tabbar__tab-grip {
    color: var(--color-text-muted);
    opacity: 0.35;
    font-size: 0.85rem;
    cursor: grab;
    transition: opacity 120ms ease;
}

.hangar-tabbar__tab:hover .hangar-tabbar__tab-grip {
    opacity: 0.8;
}

/* The dragged tab itself stays in the DOM (it's what's being moved), just
 * faded out — the browser already shows its own drag ghost image. */
.hangar-tabbar__tab.is-dragging {
    opacity: 0.4;
    cursor: grabbing;
}

.hangar-tabbar__tab.is-dragging .hangar-tabbar__tab-grip {
    cursor: grabbing;
}

/* Never shrinks (see .hangar-tabbar__tabs above) — always stays visible,
 * right-aligned, at a fixed width. */
.hangar-tabbar__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.hangar-tabbar__icon-button {
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.1rem;
    line-height: 1;
    text-decoration: none;
    transition: background-color 120ms ease;
}

.hangar-tabbar__icon-button:hover {
    background-color: var(--color-background);
}

/* The clickable avatar circle (a <summary>, so the browser's own
 * disclosure marker is switched off). */
.hangar-tabbar__avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.hangar-tabbar__avatar-image {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.hangar-tabbar__avatar::-webkit-details-marker {
    display: none;
}

.hangar-usermenu {
    position: relative;
}

.hangar-usermenu__panel {
    position: absolute;
    z-index: 20;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    padding: 12px 16px;
    border-radius: var(--radius);
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.hangar-usermenu__name {
    font-weight: 700;
}

.hangar-usermenu__email {
    margin-bottom: 12px;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    overflow-wrap: anywhere;
}

.hangar-usermenu__logout {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: none;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--color-text);
    cursor: pointer;
}

.hangar-usermenu__logout:hover {
    background-color: var(--color-background);
}

.hangar-tabbar__empty {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.hangar-content {
    flex: 1;
    padding: 24px 32px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.card {
    background-color: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--elevation-1);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card__title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
}

.card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.card__header-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.card__footer {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* "display: flex" above beats the browser's own [hidden] rule, so without
 * this the footer (the name of the imported file) stayed on screen after it
 * was hidden, e.g. after "Neu". */
.card__footer[hidden] {
    display: none;
}

/* Fixed, centered popup instead of an inline block, so it is impossible to
 * miss regardless of where on the page or how far scrolled the editor is. */
.error-message {
    position: fixed;
    left: 50%;
    bottom: 32px;
    transform: translateX(-50%);
    z-index: 1000;
    max-width: min(90vw, 480px);
    margin: 0;
    padding: 14px 20px;
    border-radius: var(--radius);
    background-color: var(--color-error-background);
    color: var(--color-error);
    font-size: 0.9rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.error-message[hidden] {
    display: none;
}

.login-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* The build that is running, deliberately quiet. */
.app-version {
    margin: 16px 0 0;
    font-size: 0.75rem;
    color: #6b7075;
    text-align: center;
}

.login-card {
    width: 100%;
    max-width: 360px;
    align-items: stretch;
    text-align: center;
}

.login-card__brand {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 8px;
}

.login-card__azure-button {
    width: 100%;
}

.login-card__local {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
}

.login-card__local-hint {
    margin: 0 0 8px;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.login-card__local form {
    margin: 0;
}

.login-card__local md-outlined-button {
    width: 100%;
}
