/* Logo in Überschriften */
.logo {
    height: 1.5em;
    vertical-align: middle;
    margin-right: 0.4em;
}

/* Login Logo: Schwarz im Light Mode, Weiß im Dark Mode */
.logo-login {
    content: url('/static/logo-black.png');
}

@media (prefers-color-scheme: dark) {
    body:not(.light-mode) .logo-login {
        content: url('/static/logo-white.png');
    }
}

body.dark-mode .logo-login {
    content: url('/static/logo-white.png');
}
:root {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-header: #2e7d32;
    --text-primary: #333;
    --text-secondary: #666;
    --text-inverse: #ffffff;
    --border-color: #ddd;
    --shadow: rgba(0,0,0,0.1);
    --shadow-hover: rgba(0,0,0,0.15);
    --card-bg: #ffffff;
}

/* Auto Dark Mode basierend auf System-Einstellungen */
@media (prefers-color-scheme: dark) {
    body:not(.light-mode) {
        --bg-primary: #1a1a1a;
        --bg-secondary: #2d2d2d;
        --bg-header: #1b5e20;
        --text-primary: #e0e0e0;
        --text-secondary: #b0b0b0;
        --text-inverse: #ffffff;
        --border-color: #404040;
        --shadow: rgba(0,0,0,0.3);
        --shadow-hover: rgba(0,0,0,0.5);
        --card-bg: #2d2d2d;
    }
}

/* Manueller Dark Mode (überschreibt System) */
body.dark-mode {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-header: #1b5e20;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-inverse: #ffffff;
    --border-color: #404040;
    --shadow: rgba(0,0,0,0.3);
    --shadow-hover: rgba(0,0,0,0.5);
    --card-bg: #2d2d2d;
}

/* Manueller Light Mode (überschreibt System) */
body.light-mode {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-header: #2e7d32;
    --text-primary: #333;
    --text-secondary: #666;
    --text-inverse: #ffffff;
    --border-color: #ddd;
    --shadow: rgba(0,0,0,0.1);
    --shadow-hover: rgba(0,0,0,0.15);
    --card-bg: #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: rgba(0,0,0,0);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.3s, color 0.3s;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

/* Login Page */
.login-container {
    max-width: 400px;
    margin: 100px auto;
    background: var(--card-bg);
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--shadow);
}

.login-container h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #2e7d32;
}

/* Header */
header {
    background: var(--bg-header);
    color: var(--text-inverse);
    padding: 1rem;
    box-shadow: 0 2px 4px var(--shadow);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.theme-menu-container {
    position: relative;
}

.theme-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--shadow);
    padding: 0;
    min-width: 220px;
    display: none;
    z-index: 1000;
    border: 1px solid var(--border-color);
}

.theme-menu.active {
    display: block;
}

.settings-header {
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

.setting-item {
    padding: 1rem;
}

.setting-item label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.setting-item select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
}

.settings-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.5rem 0;
}

.settings-action {
    width: 100%;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s;
    border-radius: 0 0 8px 8px;
}

.settings-action:hover {
    background: rgba(211, 47, 47, 0.1);
    color: #d32f2f;
}

.header-content {
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Main Container */
.main-container {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    min-height: calc(100vh - 80px);
}

/* Sidebar */
.sidebar {
    width: 250px;
    background: var(--card-bg);
    padding: 2rem 0;
    box-shadow: 2px 0 4px var(--shadow);
}

.sidebar nav {
    display: flex;
    flex-direction: column;
}

.nav-link {
    padding: 1rem 2rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-icon {
    font-size: 1.25rem;
}

.nav-text {
    font-size: 1rem;
}

.nav-link:hover {
    background: rgba(46, 125, 50, 0.1);
    color: #2e7d32;
}

.nav-link.active {
    background: rgba(46, 125, 50, 0.15);
    color: #2e7d32;
    border-left-color: #2e7d32;
    font-weight: 600;
}

@media (prefers-color-scheme: dark) {
    body:not(.light-mode) .nav-link:hover {
        background: rgba(76, 175, 80, 0.2);
        color: #81c784;
    }

    body:not(.light-mode) .nav-link.active {
        background: rgba(76, 175, 80, 0.25);
        color: #81c784;
        border-left-color: #81c784;
    }
}

body.dark-mode .nav-link:hover {
    background: rgba(76, 175, 80, 0.2);
    color: #81c784;
}

body.dark-mode .nav-link.active {
    background: rgba(76, 175, 80, 0.25);
    color: #81c784;
    border-left-color: #81c784;
}

/* Content */
.content {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
}

.content-page {
    display: none;
}

.content-page.active {
    display: block;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 16px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

/* Buttons */
.btn {
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

/* Kompakte Buttons in Modals */
form .btn {
    padding: 0.75rem;
    min-width: 50px;
    font-size: 1.5rem;
    margin: 0.25rem;
}

form {
    display: flex;
    flex-direction: column;
}

form > .btn,
form > button[type="submit"],
form > button[type="button"] {
    align-self: stretch;
}

form .btn:not(:last-child) {
    margin-bottom: 0;
}

/* Button-Container für nebeneinander */
.button-group {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.button-group .btn {
    flex: 1;
    min-width: 0;
}

.btn-primary {
    background: #2e7d32;
    color: white;
}

.btn-primary:hover {
    background: #1b5e20;
}

.btn-secondary {
    background: #757575;
    color: white;
}

.btn-secondary:hover {
    background: #616161;
}

.btn-danger {
    background: #d32f2f;
    color: white;
}

.btn-danger:hover {
    background: #c62828;
}

.btn-success {
    background: #388e3c;
    color: white;
}

.btn-success:hover {
    background: #2e7d32;
}

.btn-success:disabled {
    background: #9e9e9e;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-small {
    padding: 0.625rem 1rem;
    font-size: 14px;
    min-height: 40px;
}

.btn-icon {
    padding: 0.5rem;
    min-width: 36px;
    min-height: 36px;
    font-size: 1.25rem;
    line-height: 1;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.btn-icon:hover {
    background: #f5f5f5;
    transform: scale(1.1);
    color: #333;
}

.btn-icon:active {
    transform: scale(0.95);
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1rem;
    padding: 0 1rem;
}

table {
    width: 100%;
    background: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px var(--shadow);
    min-width: 600px;
}

.table-compact {
    font-size: 0.875rem;
}

.table-compact th,
.table-compact td {
    padding: 0.4rem 0.5rem;
}

.table-compact tbody tr {
    height: auto;
}

/* Mobile Card List */
.mobile-list {
    display: none;
}

.mobile-item {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 1px 3px var(--shadow);
}

.mobile-item-compact {
    background: var(--card-bg);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.4rem;
    box-shadow: 0 1px 2px var(--shadow);
    font-size: 0.875rem;
}

.mobile-item-compact .mobile-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
    padding-bottom: 0;
    border-bottom: none;
}

.mobile-item-compact .mobile-item-title {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.mobile-item-compact .mobile-item-row {
    display: flex;
    margin-top: 0.25rem;
}

.mobile-item-compact .mobile-item-value {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    margin-top: 0.5rem;
}

.pagination-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.mobile-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    gap: 0.5rem;
}

.mobile-item-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mobile-item-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mobile-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
}

.mobile-item-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.mobile-item-value {
    color: var(--text-primary);
    text-align: right;
}

.mobile-item-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e0e0e0;
    flex-wrap: wrap;
}

.mobile-item-actions .btn {
    flex: 1;
    min-width: calc(50% - 0.25rem);
}

thead {
    background: #2e7d32;
    color: white;
}

@media (prefers-color-scheme: dark) {
    body:not(.light-mode) thead {
        background: #1b5e20;
    }
}

body.dark-mode thead {
    background: #1b5e20;
}

th, td {
    padding: 0.75rem;
    text-align: left;
    white-space: nowrap;
}

tbody tr:hover {
    background: #f5f5f5;
}

@media (prefers-color-scheme: dark) {
    body:not(.light-mode) tbody tr:hover {
        background: rgba(255, 255, 255, 0.05);
    }
}

body.dark-mode tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 2px 4px var(--shadow);
    margin-bottom: 1rem;
}

.card h2 {
    margin-bottom: 1rem;
    color: #2e7d32;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px var(--shadow);
    text-align: center;
}

.stat-card-link {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow-hover);
}

.stat-card h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: bold;
    color: #2e7d32;
}

/* Status Badges */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
}

.badge-success {
    background: #c8e6c9;
    color: #2e7d32;
}

.badge-warning {
    background: #ffe082;
    color: #f57f17;
}

.badge-danger {
    background: #ffcdd2;
    color: #c62828;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    max-width: 600px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.close {
    position: absolute;
    right: 0.5rem;
    top: 0.5rem;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.5rem;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close:hover {
    color: var(--text-primary);
}

/* Messages */
.error-message {
    color: #d32f2f;
    margin-top: 1rem;
}

.success-message {
    color: #2e7d32;
    margin-top: 1rem;
}

.warning-message {
    background: #fff3cd;
    color: #856404;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    border-left: 4px solid #ffc107;
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.search-box {
    flex: 1;
    max-width: 400px;
}

.search-box input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Responsive */
@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
        min-height: calc(100vh - 60px);
    }

    /* Bottom Navigation */
    .sidebar {
        width: 100%;
        padding: 0;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100;
        box-shadow: 0 -2px 8px var(--shadow);
        background: var(--card-bg);
        order: 2;
    }

    .sidebar nav {
        flex-direction: row;
        justify-content: space-around;
        padding: 0.5rem 0;
        gap: 0;
    }

    .nav-link {
        padding: 0.5rem 0.75rem;
        white-space: nowrap;
        border-left: none;
        border-bottom: none;
        border-radius: 0;
        font-size: 10px;
        min-height: 60px;
        flex-direction: column;
        gap: 0.25rem;
        flex: 1;
        justify-content: center;
        background: transparent;
    }

    .nav-icon {
        font-size: 1.75rem;
    }

    .nav-text {
        display: block;
        font-size: 0.625rem;
    }

    .nav-link.active {
        border-left: none;
        border-bottom: none;
        background: transparent;
        color: #2e7d32;
    }

    .nav-link.active .nav-icon {
        transform: scale(1.1);
    }

    /* Content with bottom nav spacing */
    .content {
        padding: 0.75rem;
        padding-bottom: 80px;
        order: 1;
    }

    /* Hide desktop tables, show mobile cards */
    .table-wrapper {
        display: none;
    }

    .mobile-list {
        display: block;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
        margin-bottom: 1rem;
    }

    .toolbar h1 {
        font-size: 1.5rem;
    }

    .search-box {
        max-width: 100%;
    }

    .btn:not(.btn-small) {
        width: 100%;
    }

    .card {
        padding: 0.875rem;
        margin-bottom: 0.875rem;
    }

    .card h2 {
        font-size: 1.125rem;
        margin-bottom: 0.875rem;
    }

    .stat-card .value {
        font-size: 1.75rem;
    }

    .login-container {
        margin: 2rem auto;
        padding: 1.5rem;
    }

    header {
        padding: 0.75rem 1rem;
    }

    .header-content h1 {
        font-size: 1.25rem;
    }

    .user-info {
        gap: 0.5rem;
        font-size: 0.875rem;
    }

    .user-info .btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
        width: auto;
    }
}
