/*
 * Base styles for the CMS.
 *
 * The CMS uses CSS custom properties to support both light and dark
 * themes.  The ``:root`` selector defines the default (light) colors
 * while the ``.dark-theme`` class overrides them.  JavaScript toggles
 * the ``dark-theme`` class on the ``<body>`` element when the user
 * switches themes.  Persist the user’s preference in localStorage
 * (handled in script.js).
 */

/*
 * Colour palette and theme variables
 *
 * The base theme uses soft neutrals and a bright primary accent to give the
 * administration interface a clean, modern appearance. The dark theme
 * inverts these values to maintain contrast and readability at night. A
 * dedicated card background variable allows the content containers to be
 * separated from the page background with subtle depth and shadows.
 */
:root {
    --bg-color: #f5f6fa;
    --card-bg: #ffffff;
    --text-color: #333333;
    --nav-bg: #ffffff;
    --nav-text: #333333;
    --accent-color: #0d6efd;
    --table-header-bg: #f7f8fc;
    --table-row-bg: #ffffff;
    --table-row-alt-bg: #f3f4fa;
    --border-color: #e0e0e0;
    --shadow-color: rgba(0, 0, 0, 0.08);
}

.dark-theme {
    --bg-color: #181c24;
    --card-bg: #2a3038;
    --text-color: #f5f6fa;
    --nav-bg: #1f2430;
    --nav-text: #f5f6fa;
    --accent-color: #17a2b8;
    --table-header-bg: #1f2430;
    --table-row-bg: #2a3038;
    --table-row-alt-bg: #252a34;
    --border-color: #343a46;
    --shadow-color: rgba(0, 0, 0, 0.5);
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
}

header {
    background-color: var(--nav-bg);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 4px var(--shadow-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Menü‑Toggle standardmäßig verbergen. Auf mobilen Geräten (siehe Media Query
   unten) wird es eingeblendet. */
.nav-toggle {
    display: none;
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--nav-text);
}

nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

nav a {
    color: var(--nav-text);
    text-decoration: none;
    font-weight: 500;
    padding: 0.4rem 0.75rem;
    border-radius: 4px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

nav a.active, nav a:hover {
    background-color: var(--accent-color);
    color: #ffffff;
}

/* Style the theme toggle button */
.theme-toggle {
    cursor: pointer;
    padding: 0.4rem 0.75rem;
    background-color: var(--accent-color);
    color: #ffffff;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: opacity 0.2s ease;
}
.theme-toggle:hover {
    opacity: 0.85;
}

/*
 * Constrain content within a card-like container. The card background and
 * subtle drop shadow help to visually separate the main content from the
 * page background. A maximum width keeps lines of text readable on
 * large displays, while percentage‑based width allows the layout to
 * shrink gracefully on smaller screens.  Add generous padding for
 * comfortable spacing.
 */
.container {
    width: 95%;
    max-width: 1200px;
    margin: 2rem auto;
    background-color: var(--card-bg);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 6px var(--shadow-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    background-color: var(--card-bg);
    border-radius: 6px;
    overflow: hidden;
}

table th, table td {
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    text-align: left;
    font-size: 0.9rem;
}

table th {
    background-color: var(--table-header-bg);
    font-weight: 600;
    letter-spacing: 0.02em;
}

table tr:nth-child(odd) {
    background-color: var(--table-row-bg);
}
table tr:nth-child(even) {
    background-color: var(--table-row-alt-bg);
}

table tr:hover {
    background-color: var(--table-header-bg);
}

form {
    margin-top: 1rem;
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.2rem;
    font-weight: bold;
}

input[type="text"],
input[type="date"],
input[type="datetime-local"],
input[type="number"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--card-bg);
    color: var(--text-color);
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]:focus,
input[type="date"]:focus,
input[type="datetime-local"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}

input[type="submit"],
button,
.btn {
    padding: 0.5rem 1rem;
    color: #ffffff;
    background-color: var(--accent-color);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s ease, opacity 0.2s ease;
    display: inline-block;
    margin: 0.1rem 0.2rem 0.1rem 0;
}

input[type="submit"]:hover,
button:hover,
.btn:hover {
    opacity: 0.9;
}

.error {
    color: red;
    margin-top: 0.5rem;
}

.success {
    color: green;
    margin-top: 0.5rem;
}

.search-box {
    margin-top: 1rem;
}

/*
 * Responsive design adjustments
 *
 * Um die CMS‑Oberfläche auf kleineren Bildschirmen benutzerfreundlich zu halten,
 * werden in diesem Abschnitt Media Queries eingesetzt.  Diese Regeln greifen
 * nur bei einer maximalen Breite von 768 px und ändern das Layout so, dass
 * Inhalte vertikal gestapelt und Tabellen horizontal scrollbar werden.  Die
 * Desktop‑Ansicht bleibt unverändert, da die Media Queries nur auf kleine
 * Viewports wirken.
 */
@media (max-width: 768px) {
    /* Navigationsleiste als aufklappbares Menü: standardmäßig ausblenden */
    nav {
        display: none;
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
        margin-top: 0.5rem;
    }
    /* Wenn die Klasse nav-open gesetzt ist, wird die Navigation eingeblendet */
    nav.nav-open {
        display: flex;
    }
    /* Der Menü-Button wird auf mobilen Geräten sichtbar */
    .nav-toggle {
        display: inline-block;
        cursor: pointer;
        padding: 0.4rem 0.75rem;
        margin-left: auto;
        background-color: var(--accent-color);
        color: #ffffff;
        border: none;
        border-radius: 4px;
        font-size: 0.9rem;
    }
    /* Container schmaler und mit weniger Rand ausstatten */
    .container {
        width: 100%;
        margin: 1rem auto;
        padding: 1rem;
    }
    /* Tabellen horizontal scrollbar machen, damit Spalten nicht abgeschnitten werden */
    table {
        display: block;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
    }
    table th, table td {
        padding: 0.5rem;
        font-size: 0.85rem;
    }
    /* Such‑ und Formularelemente kleiner darstellen für mobile */
    input[type="text"],
    input[type="date"],
    input[type="datetime-local"],
    input[type="number"],
    input[type="password"],
    textarea,
    select {
        font-size: 0.9rem;
    }
    /* Überschrift kleiner, damit sie auf kleine Bildschirme passt */
    header h1 {
        font-size: 1.2rem;
        margin-bottom: 0.5rem;
    }
    /* Buttons kompakter darstellen */
    input[type="submit"],
    button,
    .btn {
        font-size: 0.85rem;
        padding: 0.4rem 0.8rem;
        margin-right: 0.3rem;
        margin-bottom: 0.3rem;
    }
}