:root {
    --main: #6699cc;
    --main-dark: #336699;
    --main-light: #99cccc;
    --accent: #ffcc66;
}

/* Grundlayout */
body {
    font-family: Arial, sans-serif;
    margin: 10px;
    background: #f7f9fc;
}

/* Überschriften */
h1 {
    color: var(--main-dark);
    margin-bottom: 10px;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 14px;
    background: var(--main);
    color: white;
    border-radius: 6px;
    text-decoration: none;
    font-size: 14px;
    transition: 0.2s;
    border: 1px solid var(--main-dark);
}

.btn:hover {
    background: var(--main-dark);
}

.btn-accent {
    background: var(--accent);
    color: black;
    border-color: #d4a843;
}

.btn-accent:hover {
    background: #e6b85c;
}

/* Filterbereich */
form.filterbar {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    align-items: center;
}

form.filterbar label {
    font-weight: bold;
    color: var(--main-dark);
}

form.filterbar input[type="text"],
form.filterbar select {
    padding: 6px;
    border: 1px solid var(--main-dark);
    border-radius: 4px;
}

/* Tabellen */
table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #999;
    background: white;
    table-layout: fixed;
}

th,
td {
    padding: 10px;
    border: 1px solid #ccc;
}

th {
    background: var(--main-light);
    color: #003355;
    cursor: pointer;
    font-weight: bold;
}

th:nth-child(1),
td:nth-child(1) {
    width: 20%;
} /* Autor */
th:nth-child(2),
td:nth-child(2) {
    width: 40%;
} /* Titel */
th:nth-child(3),
td:nth-child(3) {
    width: 5%;
} /* Exemplar */
th:nth-child(4),
td:nth-child(4) {
    width: 20%;
} /* Genre */
th:nth-child(5),
td:nth-child(5) {
    width: 10%;
} /* Status */
th:nth-child(6),
td:nth-child(6) {
    width: 5%;
} /* Links */

tr:hover {
    background: #eef6ff;
}

/* Feste Breite + Zentrierung für Exemplar-Spalte */
th.col-ex,
td.col-ex {
    width: 60px !important;
    min-width: 60px !important;
    max-width: 60px !important;
    text-align: center !important;
}

/* Feste Breite + Zentrierung für Bearbeiten-Spalte */
th.col-edit,
td.col-edit {
    width: 70px !important;
    min-width: 70px !important;
    max-width: 70px !important;
    text-align: center !important;
}

/* Link in der Bearbeiten-Spalte zentrieren */
td.col-edit a {
    display: inline-block;
    text-align: center;
    width: 100%;
}

/* Paging */
.paging {
    margin-top: 20px;
    text-align: center;
}

.paging a {
    margin: 0 5px;
}

/* Mobile */
@media (max-width: 800px) {
    table,
    thead,
    tbody,
    th,
    td,
    tr {
        display: block;
    }

    thead {
        display: none;
    }

    tr {
        margin-bottom: 15px;
        border: 1px solid #ccc;
        padding: 10px;
        border-radius: 6px;
        background: white;
    }

    td {
        border: none;
        padding: 6px 0;
    }

    td::before {
        content: attr(data-label);
        font-weight: bold;
        color: var(--main-dark);
        display: block;
    }
}

/* Buttons rechts in der Filterzeile ausrichten */
.filterbar {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
}

/* Drei-Punkte-Menü rechts */
.menu-wrapper {
    margin-left: auto;
    position: relative;
    margin-right: 10px; /* Abstand vom rechten Rand */
}

/* Icon */
.menu-icon {
    font-size: 20px;
    width: 36px;
    height: 36px;
    background: var(--main);
    color: white;
    border: 1px solid var(--main-dark);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-icon:hover {
    background: var(--main-dark);
}

/* Dropdown */
.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 35px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 6px;
    min-width: 180px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

/* Einträge */
.dropdown-menu a {
    display: block;
    padding: 10px;
    text-decoration: none;
    color: black;
}

.dropdown-menu a:hover {
    background: #eef6ff;
}

/* sichtbar */
.dropdown-menu.show {
    display: block;
}

/* Min-/Max-Breiten */
td[data-label="Autor"] {
    min-width: 180px;
}

td[data-label="Titel"] {
    max-width: 800px;
}

td[data-label="Genre"] {
    max-width: 300px;
}

/* verhindert Umbruch im Header (Autor + Pfeil) */
th:first-child a {
    white-space: nowrap;
}

/* Linkfarben in der Statusspalte */
.status-green {
    color: #008000;       /* Grün */
    font-weight: bold;
}

.status-orange {
    color: #d97a00;       /* Orange */
    font-weight: bold;
}

.status-red {
    color: #cc0000;       /* Rot */
    font-weight: bold;
}


/* Tooltip-Container */
.info-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    line-height: 1;
}

/* Icon */
.info-tooltip .icon {
    display: inline-block;
    font-size: 1em;
    line-height: 1;
    color: #1f5f99;
    cursor: pointer;
    transform: scale(1.15);
    transform-origin: center;
    font-weight: 600;
}

/* Tooltip */
.info-tooltip .tooltip-text {
    position: fixed;
    z-index: 10000;

    width: min(650px, calc(100vw - 30px));
    max-height: calc(100vh - 30px);
    overflow-y: auto;

    background: #eef6ff;
    border: 1px solid var(--main-light);
    border-left: 4px solid var(--main);
    border-radius: 6px;
    padding: 10px;

    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--main-dark);
    white-space: pre-wrap;
    overflow-wrap: anywhere;

    box-sizing: border-box;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    /*
     * Verhindert ein kurzes Aufblitzen an einer falschen Position,
     * bevor JavaScript die endgültige Position berechnet hat.
     */
    left: 0;
    top: 0;

    transition: opacity 0.2s ease;
}

/* Tooltip einblenden */
.info-tooltip.tooltip-open .tooltip-text {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Testsystem-Markierung */
.testsystem-banner {
    margin: 12px 0;
    padding: 10px 14px;
    background: #ffd9d9;
    border: 2px solid #a00000;
    color: #8b0000;
    font-weight: bold;
    text-align: center;
}

/* Anmeldung und angemeldeter Benutzer */
.title-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.title-row h1 {
    margin-right: auto;
}

.user-area {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.user-status {
    color: var(--main-dark);
    font-size: 14px;
}

.logout-form {
    margin: 0;
}

.user-link {
    display: inline-block;
    padding: 7px 12px;
    border: 1px solid var(--main-dark);
    border-radius: 6px;
    background: var(--main);
    color: white;
    font: inherit;
    font-size: 14px;
    text-decoration: none;
    cursor: pointer;
}

.user-link:hover {
    background: var(--main-dark);
}

.login-page {
    display: flex;
    justify-content: center;
    padding-top: 60px;
}

.login-card {
    width: min(420px, calc(100% - 40px));
    padding: 28px;
    border: 1px solid #ccd6e0;
    border-radius: 10px;
    background: white;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.login-form {
    display: grid;
    gap: 10px;
}

.login-form label {
    margin-top: 6px;
    color: var(--main-dark);
    font-weight: bold;
}

.login-form input[type="text"],
.login-form input[type="password"] {
    box-sizing: border-box;
    width: 100%;
    padding: 9px;
    border: 1px solid var(--main-dark);
    border-radius: 4px;
}

.login-form .btn {
    margin-top: 12px;
    cursor: pointer;
}

.login-error {
    margin-bottom: 14px;
    padding: 10px;
    border: 1px solid #b42318;
    border-radius: 6px;
    background: #fff1f0;
    color: #8a1c13;
}

@media (max-width: 800px) {
    .title-row {
        flex-wrap: wrap;
    }

    .user-area {
        flex-basis: 100%;
        justify-content: flex-end;
    }
}
