/**
 * Hand-written MUI v9 look-alike for leerverkauf.de (port of the @mui/material
 * theme + sx styles used by the legacy Next.js app). Theme: primary #6639B3,
 * secondary #A942B3. Breakpoints match MUI: sm 600px, md 900px.
 */

/* ------------------------------------------------------------------ fonts */
@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 300;
    font-display: swap;
    src: url('/assets/fonts/roboto-latin-300-normal.woff2') format('woff2');
}
@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/assets/fonts/roboto-latin-400-normal.woff2') format('woff2');
}
@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/assets/fonts/roboto-latin-500-normal.woff2') format('woff2');
}
@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/assets/fonts/roboto-latin-700-normal.woff2') format('woff2');
}

/* ------------------------------------------------------------------ base */
:root {
    --primary: #6639b3;
    --secondary: #a942b3;
    --error-dark: #c62828;
    --success-dark: #1b5e20;
    --warning-light: #ffb74d;
    --amber-300: #ffd54f;
    --text-primary: rgba(0, 0, 0, 0.87);
    --text-secondary: rgba(0, 0, 0, 0.6);
    --divider: rgba(0, 0, 0, 0.12);
    --paper-shadow: 0px 2px 1px -1px rgba(0, 0, 0, 0.2), 0px 1px 1px 0px rgba(0, 0, 0, 0.14), 0px 1px 3px 0px rgba(0, 0, 0, 0.12);
    --appbar-shadow: 0px 2px 4px -1px rgba(0, 0, 0, 0.2), 0px 4px 5px 0px rgba(0, 0, 0, 0.14), 0px 1px 10px 0px rgba(0, 0, 0, 0.12);
    --drawer-width: 220px;
}

* {
    box-sizing: border-box;
}

html,
body {
    padding: 0;
    margin: 0;
}

/* Legacy styles/globals.css: body uses the SYSTEM font stack. It wins over
   MUI's body rule because MUI styles are CSS-layered (enableCssLayer) and
   globals.css is not. Raw-HTML pages (dataprotection, about) therefore render
   in the system font; MUI components still get the theme font (Roboto). */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    letter-spacing: 0.00938em;
    color: var(--text-primary);
    background: #fff;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* MUI components use the theme fontFamily (Roboto) */
.h2, .h3, .h4, .h6, .body1, .body2, .subtitle1, .caption,
.appbar, .drawer, .footer, .table, .btn-cta, .chip, .dropdown-menu, .alert,
.switch-label, .sort-label, .search-dropdown {
    font-family: 'Roboto', 'Helvetica', 'Arial', sans-serif;
}
/* NOTE: the KPI boxes are raw <Box> in legacy (no Typography) -> system font */

a {
    color: var(--primary);
    text-decoration: underline;
}

a.unstyled {
    color: inherit;
    text-decoration: inherit;
}

.icon {
    vertical-align: middle;
}

/* ------------------------------------------------------------ typography */
.h2, .h3, .h4, .h6, .body1, .body2, .subtitle1, .caption {
    margin: 0;
}
.h2 { font-size: 3.75rem; font-weight: 300; line-height: 1.2; letter-spacing: -0.00833em; }
.h3 { font-size: 3rem; font-weight: 400; line-height: 1.167; letter-spacing: 0; }
.h4 { font-size: 2.125rem; font-weight: 400; line-height: 1.235; letter-spacing: 0.00735em; }
.h6 { font-size: 1.25rem; font-weight: 500; line-height: 1.6; letter-spacing: 0.0075em; }
.body1 { font-size: 1rem; font-weight: 400; line-height: 1.5; letter-spacing: 0.00938em; }
.body2 { font-size: 0.875rem; font-weight: 400; line-height: 1.43; letter-spacing: 0.01071em; }
.subtitle1 { font-size: 1rem; font-weight: 400; line-height: 1.75; letter-spacing: 0.00938em; }
.caption { font-size: 0.75rem; font-weight: 400; line-height: 1.66; letter-spacing: 0.03333em; }

.text-secondary { color: var(--text-secondary); }
.change-pos { color: var(--success-dark); }
.change-neg { color: var(--error-dark); }
.change-neutral { color: var(--text-secondary); }
.font-medium { font-weight: 500; }
.align-center { text-align: center; }

/* ---------------------------------------------------------------- layout */
.container {
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 16px;
    padding-right: 16px;
}
@media (min-width: 600px) {
    .container { padding-left: 24px; padding-right: 24px; }
}

.toolbar-spacer {
    min-height: 56px;
}
@media (min-width: 600px) {
    .toolbar-spacer { min-height: 64px; }
}

/* ---------------------------------------------------------------- appbar */
.appbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1201; /* legacy: theme.zIndex.drawer + 1, stays above the mobile drawer */
    background: var(--primary);
    color: #fff;
    box-shadow: var(--appbar-shadow);
}
.toolbar {
    display: flex;
    align-items: center;
    min-height: 56px;
    padding-left: 16px;
    padding-right: 16px;
}
@media (min-width: 600px) {
    .toolbar { min-height: 64px; padding-left: 24px; padding-right: 24px; }
}
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-left: -12px;
    padding: 8px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    cursor: pointer;
    transition: background-color 150ms;
}
.icon-btn:hover {
    background-color: rgba(255, 255, 255, 0.08);
}
.appbar-title {
    font-size: 1.25rem;
    font-weight: 500;
    line-height: 1.6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0; /* MuiTypography-noWrap: shrinks with ellipsis in the flex row */
}

/* ---------------------------------------------------------------- search */
.search {
    position: relative;
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.15);
    margin-left: auto;
    width: 224px; /* legacy MUI content basis: flex-shrinks proportionally with the title on mobile */
    min-width: 0;
    height: 2.25rem;
    transition: background-color 150ms;
}
.search:hover {
    background-color: rgba(255, 255, 255, 0.25);
}
@media (min-width: 600px) {
    .search { width: 16rem; } /* margin-left: auto wins (legacy !important) */
}
.search:focus-within .search-hint {
    display: none;
}
.search-icon {
    padding: 0 16px; /* MUI startAdornment: 16+24 */
    height: 100%;
    position: absolute;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}
#search-input {
    color: inherit;
    font: inherit;
    width: 100%;
    height: 1.4375em; /* MUI InputBase input */
    line-height: 1.4375em;
    box-sizing: content-box;
    padding: 8px 30px 8px calc(1em + 32px);
    border: 0;
    background: transparent;
    outline: none;
}
#search-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
    opacity: 1;
}
.search-hint {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    font-family: inherit;
    font-size: 0.7rem;
    color: inherit;
    opacity: 0.6;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 4px;
    padding: 0 4px;
    line-height: 1.4em;
    pointer-events: none;
    margin: 0 8px;
    white-space: nowrap;
}
.search-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 3200;
    background: #fff;
    color: var(--text-primary);
    border-radius: 4px;
    box-shadow: 0px 2px 1px -1px rgba(0, 0, 0, 0.2), 0px 1px 1px 0px rgba(0, 0, 0, 0.14), 0px 1px 3px 0px rgba(0, 0, 0, 0.12);
    overflow: hidden;
}
.search-option {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    min-height: 48px;
    box-sizing: border-box;
    padding: 6px 16px;
    cursor: pointer;
    overflow: hidden;
    /* legacy: the option link is className="unstyled" (inherit, no underline) */
    color: inherit;
    text-decoration: none;
}
.search-option:hover,
.search-option.active {
    background-color: rgba(0, 0, 0, 0.04);
}
.search-option .option-name {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.75;
    text-transform: uppercase;
    letter-spacing: 0.02857em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.search-option .option-id {
    display: block;
    font-size: 0.75rem;
    line-height: 1em;
    /* legacy color="text.secondary" prop is broken -> renders text.primary */
}
.search-nooptions {
    padding: 14px 16px;
    font-size: 0.875rem;
    line-height: 1.43;
    letter-spacing: 0.01071em;
}

/* ---------------------------------------------------------------- drawer */
.drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1100;
    width: var(--drawer-width);
    background: #fff;
    border-right: 1px solid var(--divider);
    overflow-x: hidden;
    overflow-y: auto;
    white-space: nowrap;
    transition: width 195ms cubic-bezier(0.4, 0, 0.6, 1), transform 225ms cubic-bezier(0, 0, 0.2, 1);
}
body.drawer-collapsed .drawer {
    width: 0;
    border-right: 0;
    transition: width 225ms cubic-bezier(0.4, 0, 0.6, 1);
}
.drawer-list {
    list-style: none;
    margin: 0;
    padding: 8px 0;
}
/* MUI ListItem keeps its vertical padding even with disableGutters */
.drawer-list li {
    padding: 8px 0;
}
.drawer-list a {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    color: var(--text-primary);
    text-decoration: none;
    transition: background-color 150ms;
}
/* MUI ListItemText margin */
.drawer-text {
    margin: 4px 0;
}
.drawer-list a:hover {
    background-color: rgba(0, 0, 0, 0.04);
}
.drawer-icon {
    display: inline-flex;
    min-width: 56px;
    color: rgba(0, 0, 0, 0.54);
}
.divider {
    margin: 0;
    border: 0;
    border-top: 1px solid var(--divider);
}
.drawer-overlay {
    position: fixed;
    inset: 0;
    z-index: 1199;
    background-color: rgba(0, 0, 0, 0.5);
}

/* Legacy quirk: #__next is display:flex, so <main> is a flex item with
   min-width:auto - long unbreakable content (URLs in the privacy policy)
   stretches the whole page instead of overflowing. Replicated on purpose. */
.layout-flex {
    display: flex;
}
.main {
    flex-grow: 1;
    margin-left: var(--drawer-width);
    padding: 24px;
    padding-left: 0;
    padding-right: 0;
    transition: margin-left 195ms cubic-bezier(0.4, 0, 0.6, 1);
}
body.drawer-collapsed .main {
    margin-left: 0;
}
@media (min-width: 600px) {
    .main { padding-left: 8px; padding-right: 8px; }
}
@media (min-width: 900px) {
    .main { padding-left: 24px; padding-right: 24px; }
}
@media (max-width: 599.95px) {
    .drawer {
        transform: translateX(-100%);
        /* legacy temporary drawer: paper width = max-content of the nav list,
           MuiPaper elevation 16 shadow instead of the permanent drawer's border */
        width: max-content !important;
        border-right: 0;
        box-shadow: 0px 8px 10px -5px rgba(0, 0, 0, 0.2), 0px 16px 24px 2px rgba(0, 0, 0, 0.14), 0px 6px 30px 5px rgba(0, 0, 0, 0.12);
        z-index: 1200; /* below the appbar (1201), like legacy */
    }
    body.drawer-mobile-open .drawer {
        transform: none;
    }
    .main {
        margin-left: 0;
    }
}

/* ------------------------------------------------------------------ grid */
.grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}
.grid-item {
    width: 100%;
}
@media (min-width: 900px) {
    .grid-item { width: calc(50% - 8px); }
}

/* ----------------------------------------------------------------- paper */
.paper {
    background: #fff;
    border-radius: 4px;
    box-shadow: var(--paper-shadow);
}

/* ----------------------------------------------------------------- table */
.table-container {
    overflow-x: auto;
}
table.table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
}
.table th,
.table td {
    padding: 6px 16px;
    font-size: 0.875rem;
    line-height: 1.43;
    letter-spacing: 0.01071em;
    text-align: left;
    border-bottom: 1px solid rgba(224, 224, 224, 1);
    vertical-align: inherit;
}
.table thead th {
    font-weight: 500;
    line-height: 1.5rem; /* MUI TableCell head */
    color: var(--text-primary);
}
/* MUI Table size="medium" (the default): 16px cell padding - the company
   holders table and shortseller positions table; home tables are size="small" */
.table-medium th,
.table-medium td {
    padding: 16px;
}
.table tbody tr {
    transition: background-color 150ms;
}
.table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.04);
}
.table tbody tr.clickable {
    cursor: pointer;
}
.table tbody tr:last-child td,
.table tbody tr:last-child th {
    border: 0;
}
.table .num {
    text-align: right;
}
.table .cell-ellipsis {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 13rem;
    display: inline-block;
    vertical-align: middle;
}

/* responsive column visibility (MUI sx display breakpoints) */
@media (max-width: 599.95px) {
    .hide-xs { display: none !important; }
}
@media (max-width: 899.95px) {
    .hide-below-md { display: none !important; }
}
@media (min-width: 900px) {
    .show-below-md { display: none !important; }
}

/* TableSortLabel */
.sort-label {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    user-select: none;
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    font-weight: inherit;
    color: inherit;
    letter-spacing: inherit;
}
.sort-label .icon {
    opacity: 0;
    transition: opacity 150ms, transform 150ms;
}
.sort-label:hover .icon,
.sort-label.active .icon {
    opacity: 0.6;
}
.sort-label.active {
    font-weight: 500;
}
.sort-label.asc .icon {
    transform: rotate(180deg);
}
th.num .sort-label {
    flex-direction: row;
}

/* ------------------------------------------------------------------- kpi */
.kpi-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
@media (min-width: 600px) {
    .kpi-row { gap: 16px; }
}
.kpi-box {
    background: #fff;
    box-shadow: var(--paper-shadow);
    border-radius: 4px;
    width: 100%;
    flex-grow: 1;
    padding: 16px;
    margin-top: 8px;
    margin-bottom: 8px;
}
@media (min-width: 600px) {
    .kpi-box { width: 220px; }
}
.kpi-title { color: var(--text-secondary); }
.kpi-value { color: var(--text-primary); font-size: 34px; font-weight: 500; }
.kpi-delta { display: inline; font-weight: 500; margin-left: 4px; margin-right: 4px; }
.kpi-delta-label { display: inline; font-size: 12px; color: var(--text-secondary); }

/* ------------------------------------------------------------------ chip */
.chip {
    display: inline-flex;
    align-items: center;
    height: 24px;
    padding: 0 8px;
    border: 0;
    border-radius: 16px;
    background-color: rgba(0, 0, 0, 0.08);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: background-color 150ms;
}
.chip:hover {
    background-color: rgba(0, 0, 0, 0.16);
}
.chip.chip-active {
    background-color: var(--primary);
    color: #fff;
}

/* ----------------------------------------------------------------- alert */
.alert {
    display: flex;
    align-items: center;
    padding: 6px 16px;
    border-radius: 4px;
    font-size: 0.875rem;
    line-height: 1.43;
    letter-spacing: 0.01071em;
    margin-top: 16px;
    margin-bottom: 16px;
}
/* MUI Alert message padding */
.alert-text {
    padding: 8px 0;
}
.alert-info {
    background-color: #e5f6fd;
    color: #014361;
    justify-content: center;
    text-align: center;
}
/* no .alert-info a color reset: the insider link is a MUI Link (primary purple) */
.alert-info .alert-icon { color: #0288d1; }
.alert-warning {
    background-color: #fff4e5;
    color: #663c00;
}
.alert-warning .alert-icon { color: #ed6c02; }
.alert .alert-icon {
    display: inline-flex;
    margin-right: 12px;
    opacity: 0.9;
}

/* ------------------------------------------------------------- dropdown */
.dropdown {
    position: relative;
    display: inline-block;
}
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1300;
    min-width: 160px;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0px 5px 5px -3px rgba(0, 0, 0, 0.2), 0px 8px 10px 1px rgba(0, 0, 0, 0.14), 0px 3px 14px 2px rgba(0, 0, 0, 0.12);
    padding: 8px 0;
}
.dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 1rem;
}
.dropdown-menu a:hover {
    background-color: rgba(0, 0, 0, 0.04);
}
.link-button {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: var(--primary);
    text-decoration: underline;
    cursor: pointer;
    vertical-align: baseline;
}

/* ------------------------------------------------------------------ cta */
.feedback-cta {
    margin-top: 24px;
    text-align: center;
}
.btn-cta {
    display: inline-flex;
    align-items: center;
    vertical-align: middle; /* MUI Button */
    gap: 0; /* legacy Stack spacing targets elements only; the raw text node gets none */
    margin-top: 0;
    padding: 4px 10px;
    border: 0;
    border-radius: 4px;
    background-color: var(--amber-300);
    color: #000;
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.75;
    letter-spacing: 0.02857em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: var(--paper-shadow);
    transition: background-color 150ms;
}
.btn-cta:hover {
    background-color: #ffca28;
}

/* ---------------------------------------------------------------- footer */
.footer {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
    margin-top: auto;
}
.footer-inner {
    display: flex;
    flex-direction: column;
    gap: 8px; /* MUI Stack spacing={1} */
    margin-top: 16px;
    max-width: 600px;
    text-align: center;
}
.footer-inner p {
    margin: 0;
}
/* Legacy passes color="warning.light"/"text.secondary" via the Typography
   color PROP, which is broken in MUI v9 (no rule is generated) - the text
   renders in text.primary. Only the sx-based fontStyle applies. */
.footer-disclaimer {
    font-style: italic;
}
.footer-links {
    display: flex;
    justify-content: center;
    gap: 8px;
}
.footer-divider {
    border-left: 1px solid var(--divider);
}

/* ------------------------------------------------------------------ misc */
.wikipediaExtract {
    overflow: hidden;
    text-overflow: ellipsis;
    hyphens: auto;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    font-style: italic;
    margin-top: 8px;
}
.wikipedia-links {
    display: flex;
    column-gap: 0.5rem;
}
.wikipedia-links a {
    font-style: italic;
    font-size: 10px;
    color: var(--text-secondary);
}

.apexcharts-svg {
    overflow: visible;
}

.chart-box {
    background: #fff;
    box-shadow: var(--paper-shadow);
    border-radius: 4px;
    padding: 16px;
    margin-top: 8px;
    margin-bottom: 8px;
}
.chart-box-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.chart-box .chips {
    display: flex;
    column-gap: 4px;
}

/* switch (MUI Switch look-alike) */
.switch-label {
    display: inline-flex;
    align-items: center;
    gap: 0;
    margin: 16px;
    cursor: pointer;
}
.switch {
    position: relative;
    display: inline-block;
    flex-shrink: 0; /* MUI Switch root keeps its 58px inside the flex label */
    width: 58px;
    height: 38px;
}
.switch input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
    z-index: 1;
}
.switch .track {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 34px;
    height: 14px;
    border-radius: 7px;
    background-color: rgba(0, 0, 0, 0.38);
    transition: background-color 150ms;
}
.switch .thumb {
    position: absolute;
    top: 9px;
    left: 9px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: #fff;
    box-shadow: var(--paper-shadow);
    transition: transform 150ms, background-color 150ms;
}
.switch input:checked ~ .track {
    background-color: rgba(102, 57, 179, 0.5);
}
.switch input:checked ~ .thumb {
    transform: translateX(20px);
    background-color: var(--primary);
}

/* Raw-HTML pages (privacy policy): legacy renders the legal text as plain
   HTML without MUI Link classes, so links get the browser default style. */
.raw-html a {
    color: LinkText;
}

/* spacing utilities come last so they win over component margins
   (legacy MUI sx margins, e.g. chart-box my:2 = 16px, beat the 8px default) */
.mb-2 { margin-bottom: 16px; }
.my-1 { margin-top: 8px; margin-bottom: 8px; }
.my-2 { margin-top: 16px; margin-bottom: 16px; }
.mt-4 { margin-top: 32px; }
.mt-6 { margin-top: 48px; }
