/* Modern Professional Dark Mode - Mobile First */
:root {
    /* Background Colors - Modern Dark Theme */
    --bg-primary: #1e1e1e;
    --bg-secondary: #252525;
    --bg-tertiary: #2d2d2d;
    --bg-card: #2a2a2a;
    --bg-hover: #353535;
    --bg-input: #2a2a2a;
    --bg-table-header: #2d2d2d;
    --bg-table-row: #2a2a2a;
    --bg-table-row-hover: #353535;
    
    /* Text Colors - High Contrast */
    --text-primary: #e4e4e4;
    --text-secondary: #b4b4b4;
    --text-muted: #8a8a8a;
    --text-inverse: #1e1e1e;
    
    /* Accent Colors - Modern & Vibrant */
    --accent-primary: #4a9eff;
    --accent-primary-hover: #6bb0ff;
    --accent-success: #4caf50;
    --accent-warning: #ff9800;
    --accent-danger: #f44336;
    --accent-info: #00bcd4;
    
    /* Border and Divider */
    --border-color: #404040;
    --border-light: #353535;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.5);
    
    /* Highlight Colors */
    --highlight-bg: #3d5a80;
    --highlight-text: #e4e4e4;

    /* Glass surfaces (used by page header/tabs/mobile topbar) */
    --glass-bg: rgba(37, 37, 37, 0.75);
    --glass-bg-soft: rgba(37, 37, 37, 0.55);
    --glass-border: rgba(64, 64, 64, 0.85);
    --glass-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);

    --page-header-bg-top: rgba(45, 45, 45, 0.92);
    --page-header-bg-bottom: rgba(37, 37, 37, 0.78);
    --page-header-border: rgba(64, 64, 64, 0.9);
    --page-header-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);

    /* Stream/Timeline surfaces (dark) */
    --stream-line: rgba(64, 64, 64, 0.75);
    --stream-item-bg-top: rgba(45, 45, 45, 0.85);
    --stream-item-bg-bottom: rgba(42, 42, 42, 0.85);
    --stream-item-border: rgba(64, 64, 64, 0.9);
    --stream-item-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

/* Light theme (toggle via html[data-theme="light"]) */
html[data-theme="light"] {
    --bg-primary: #f7f8fb;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f3f7;
    --bg-card: #ffffff;
    --bg-hover: #eef2f9;
    --bg-input: #ffffff;
    --bg-table-header: #f1f3f7;
    --bg-table-row: #ffffff;
    --bg-table-row-hover: #f6f8fd;

    --text-primary: #111827;
    --text-secondary: #374151;
    --text-muted: #6b7280;
    --text-inverse: #ffffff;

    --border-color: #e5e7eb;
    --border-light: #edf2f7;

    --shadow-sm: 0 2px 6px rgba(17, 24, 39, 0.06);
    --shadow-md: 0 6px 14px rgba(17, 24, 39, 0.10);
    --shadow-lg: 0 16px 30px rgba(17, 24, 39, 0.14);

    --highlight-bg: #dbeafe;
    --highlight-text: #111827;

    /* Glass surfaces (light) */
    --glass-bg: rgba(255, 255, 255, 0.78);
    --glass-bg-soft: rgba(255, 255, 255, 0.62);
    --glass-border: rgba(17, 24, 39, 0.10);
    --glass-shadow: 0 10px 28px rgba(17, 24, 39, 0.12);

    --page-header-bg-top: rgba(255, 255, 255, 0.92);
    --page-header-bg-bottom: rgba(255, 255, 255, 0.72);
    --page-header-border: rgba(17, 24, 39, 0.10);
    --page-header-shadow: 0 16px 34px rgba(17, 24, 39, 0.12);

    /* Stream/Timeline surfaces (light) */
    --stream-line: rgba(17, 24, 39, 0.12);
    --stream-item-bg-top: rgba(255, 255, 255, 0.92);
    --stream-item-bg-bottom: rgba(255, 255, 255, 0.78);
    --stream-item-border: rgba(17, 24, 39, 0.12);
    --stream-item-shadow: 0 10px 28px rgba(17, 24, 39, 0.12);
}

html[data-theme="light"] .btn-close {
    filter: none;
}

html[data-theme="light"] .navbar {
    background: var(--bg-secondary) !important;
}

html[data-theme="light"] .navbar-dark .navbar-toggler-icon {
    /* make hamburger visible on light */
    filter: none;
}

/* Reset and Base */
* {
    box-sizing: border-box;
}

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

body {
    background: var(--bg-primary) !important;
}

/* Navbar */
.navbar {
    background: var(--bg-secondary) !important;
    border-bottom: 1px solid var(--border-color) !important;
    padding: 0.75rem 0 !important;
}

.navbar-brand {
    font-weight: 600;
    font-size: 1.25rem;
    color: var(--text-primary) !important;
    text-decoration: none;
}

.navbar-brand:hover {
    color: var(--text-primary) !important;
    text-decoration: none;
}

.nav-link {
    color: var(--text-secondary) !important;
    font-weight: 500;
    padding: 0.5rem 1rem !important;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.nav-link:hover {
    color: var(--text-primary) !important;
    background: var(--bg-hover) !important;
}

.nav-link.active {
    color: var(--accent-primary) !important;
    background: rgba(74, 158, 255, 0.15) !important;
}

.navbar-toggler {
    border-color: var(--border-color) !important;
}

.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28228, 228, 228, 1%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") !important;
}

/* Cards */
.card {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 1rem;
}

.card-header {
    background: var(--bg-table-header) !important;
    border-bottom: 1px solid var(--border-color) !important;
    padding: 1rem 1.25rem;
    font-weight: 600;
    color: var(--text-primary) !important;
}

.card-body {
    padding: 1.25rem;
    color: var(--text-primary) !important;
    background: var(--bg-card) !important;
}

.card-title {
    color: var(--text-primary) !important;
}

/* Buttons */
.btn {
    border-radius: 8px;
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--accent-primary) !important;
    color: white !important;
    border-color: var(--accent-primary) !important;
}

.btn-primary:hover {
    background: var(--accent-primary-hover) !important;
    border-color: var(--accent-primary-hover) !important;
    color: white !important;
}

.btn-outline-primary {
    border: 1px solid var(--accent-primary) !important;
    color: var(--accent-primary) !important;
    background: transparent !important;
}

.btn-outline-primary:hover {
    background: var(--accent-primary) !important;
    color: white !important;
}

.btn-success {
    background: var(--accent-success) !important;
    color: white !important;
    border-color: var(--accent-success) !important;
}

.btn-danger {
    background: var(--accent-danger) !important;
    color: white !important;
    border-color: var(--accent-danger) !important;
}

.btn-warning {
    background: var(--accent-warning) !important;
    color: var(--text-inverse) !important;
    border-color: var(--accent-warning) !important;
}

.btn-info {
    background: var(--accent-info) !important;
    color: white !important;
    border-color: var(--accent-info) !important;
}

.btn-secondary {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

.btn-secondary:hover {
    background: var(--bg-hover) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

.btn-outline-danger {
    border: 1px solid var(--accent-danger) !important;
    color: var(--accent-danger) !important;
    background: transparent !important;
}

.btn-outline-danger:hover {
    background: var(--accent-danger) !important;
    color: white !important;
}

.btn-outline-secondary {
    border: 1px solid var(--border-color) !important;
    color: var(--text-secondary) !important;
    background: transparent !important;
}

.btn-outline-secondary:hover {
    background: var(--bg-hover) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* Forms */
.form-control, .form-select {
    background: var(--bg-input) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
}

.form-control:focus, .form-select:focus {
    background: var(--bg-input) !important;
    border-color: var(--accent-primary) !important;
    color: var(--text-primary) !important;
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.15) !important;
    outline: none;
}

.form-control::placeholder {
    color: var(--text-muted) !important;
}

.form-label {
    color: var(--text-secondary) !important;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-control-plaintext {
    color: var(--text-primary) !important;
}

/* Tables - Desktop Only */
.table {
    color: var(--text-primary) !important;
    background: var(--bg-card) !important;
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}

.table thead th {
    background: var(--bg-table-header) !important;
    border-bottom: 2px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.75rem 1rem;
    vertical-align: middle;
}

.table tbody {
    background: var(--bg-card) !important;
}

.table tbody tr {
    background: var(--bg-table-row) !important;
    border-bottom: 1px solid var(--border-light) !important;
    transition: background-color 0.2s ease;
}

.table tbody tr:hover {
    background: var(--bg-table-row-hover) !important;
}

.table tbody tr:last-child {
    border-bottom: none !important;
}

.table td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    color: var(--text-primary) !important;
    background: transparent !important;
}

/* Table checkbox column: give enough room so the checkbox isn't clipped */
.table th.col-check,
.table td.col-check {
    width: 64px;
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
    text-align: center;
}

/* Absolute fallback: if anything messes with bootstrap checkbox rendering, force a visible box in table cells */
.table td.col-check input[type="checkbox"] {
    -webkit-appearance: auto !important;
    appearance: auto !important;
    width: 20px !important;
    height: 20px !important;
    opacity: 1 !important;
    visibility: visible !important;
    display: inline-block !important;
    background-color: rgba(0, 0, 0, 0.25) !important;
    border: 2px solid rgba(228, 228, 228, 0.65) !important;
    border-radius: 6px !important;
    vertical-align: middle !important;
}

.table td.col-check input[type="checkbox"]:checked {
    background-color: var(--accent-primary) !important;
    border-color: var(--accent-primary) !important;
}

.table-hover tbody tr:hover {
    background: var(--bg-table-row-hover) !important;
}

.table-hover tbody tr:hover td {
    background: var(--bg-table-row-hover) !important;
    color: var(--text-primary) !important;
}

.table-info {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
}

.table-info th {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

.table-info td {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
}

.table-responsive {
    background: var(--bg-card) !important;
}

/* Mobile Card View
   WICHTIG: Tabellen NICHT global auf Mobile verstecken, sonst sind Listen (Offerten/Rechnungen) unsichtbar.
   Falls eine Seite eine Card-View hat, kann sie optional die Tabelle mit .hide-on-mobile ausblenden. */
@media (max-width: 768px) {
    .table-responsive.hide-on-mobile {
        display: none;
    }

    .mobile-card-view {
        display: block;
    }
}

@media (min-width: 769px) {
    .mobile-card-view {
        display: none;
    }
}

/* Mobile Card Styles */
.mobile-card-view .list-item-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    transition: all 0.2s ease;
}

.mobile-card-view .list-item-card:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-md);
}

.mobile-card-view .list-item-card a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 600;
}

.mobile-card-view .list-item-card a:hover {
    text-decoration: underline;
}

.mobile-card-view .list-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
    font-size: 0.875rem;
}

.mobile-card-view .list-item-meta-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--text-secondary);
}

.mobile-card-view .list-item-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Badges */
.badge {
    padding: 0.375rem 0.625rem;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.75rem;
    letter-spacing: 0.3px;
}

.bg-success {
    background: var(--accent-success) !important;
    color: white !important;
}

.bg-danger {
    background: var(--accent-danger) !important;
    color: white !important;
}

.bg-warning {
    background: var(--accent-warning) !important;
    color: var(--text-inverse) !important;
}

.bg-primary {
    background: var(--accent-primary) !important;
    color: white !important;
}

.bg-info {
    background: var(--accent-info) !important;
    color: white !important;
}

.bg-secondary {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
}

/* Badge mit bg-secondary sollte besser sichtbar sein */
html[data-theme="dark"] .badge.bg-secondary {
    background: #4a5568 !important;
    color: var(--text-primary) !important;
    border: 1px solid #5a6578;
}

/* Light mode: improve badge contrast */
html[data-theme="light"] .bg-warning {
    color: var(--text-primary) !important;
}
html[data-theme="light"] .bg-info {
    color: var(--text-primary) !important;
}
html[data-theme="light"] .bg-secondary {
    color: var(--text-secondary) !important;
}

/* Generic: force readable text when a badge uses Bootstrap bg-* on light */
html[data-theme="light"] .badge.bg-info,
html[data-theme="light"] .badge.bg-primary,
html[data-theme="light"] .badge.bg-dark,
html[data-theme="light"] .badge.bg-secondary {
    color: var(--text-inverse) !important;
}

html[data-theme="light"] .badge.bg-warning {
    color: var(--text-primary) !important;
}

/* Ausnahme: bg-secondary ist im Light sehr hell -> Text darf NICHT weiss sein */
html[data-theme="light"] .badge.bg-secondary {
    color: var(--text-secondary) !important;
    background: rgba(17, 24, 39, 0.08) !important;
    border: 1px solid rgba(17, 24, 39, 0.10) !important;
}

/* Small overlay labels used in detail previews (light) */
html[data-theme="light"] .bg-info.text-white,
html[data-theme="light"] .bg-primary.text-white,
html[data-theme="light"] .bg-dark.text-white {
    color: var(--text-inverse) !important;
}

/* Bootstrap 5.3 subtle/emphasis tokens can become too pale on light */
html[data-theme="light"] .bg-success-subtle { background: rgba(76, 175, 80, 0.18) !important; }
html[data-theme="light"] .bg-danger-subtle { background: rgba(244, 67, 54, 0.16) !important; }
html[data-theme="light"] .bg-warning-subtle { background: rgba(255, 152, 0, 0.20) !important; }
html[data-theme="light"] .bg-info-subtle { background: rgba(0, 188, 212, 0.16) !important; }
html[data-theme="light"] .bg-primary-subtle { background: rgba(74, 158, 255, 0.16) !important; }
html[data-theme="light"] .bg-secondary-subtle { background: rgba(17, 24, 39, 0.10) !important; }

html[data-theme="light"] .text-success-emphasis { color: #1b5e20 !important; }
html[data-theme="light"] .text-danger-emphasis { color: #7f1d1d !important; }
html[data-theme="light"] .text-warning-emphasis { color: #7a4a00 !important; }
html[data-theme="light"] .text-info-emphasis { color: #0e4a57 !important; }
html[data-theme="light"] .text-primary-emphasis { color: #0b3a91 !important; }
html[data-theme="light"] .text-secondary-emphasis { color: #374151 !important; }



.bg-light {
    background: var(--bg-hover) !important;
    color: var(--text-primary) !important;
}

.bg-dark {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
}

.badge.bg-light.text-dark {
    background: var(--bg-hover) !important;
    color: var(--text-primary) !important;
}

/* Alerts */
.alert {
    border-radius: 8px;
    border: none;
    border-left: 4px solid;
    padding: 1rem 1.25rem;
    background: transparent !important;
}

.alert-success {
    background: rgba(76, 175, 80, 0.1) !important;
    color: var(--accent-success) !important;
    border-left-color: var(--accent-success) !important;
}

.alert-danger {
    background: rgba(244, 67, 54, 0.1) !important;
    color: var(--accent-danger) !important;
    border-left-color: var(--accent-danger) !important;
}

.alert-warning {
    background: rgba(255, 152, 0, 0.1) !important;
    color: var(--accent-warning) !important;
    border-left-color: var(--accent-warning) !important;
}

.alert-info {
    background: rgba(0, 188, 212, 0.1) !important;
    color: var(--accent-info) !important;
    border-left-color: var(--accent-info) !important;
}

/* List Groups */
.list-group {
    background: var(--bg-card) !important;
}

.list-group-item {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    padding: 0.75rem 1rem;
}

.list-group-item:hover {
    background: var(--bg-hover) !important;
    border-color: var(--border-color) !important;
}

.list-group-item-action {
    cursor: pointer;
    color: var(--text-primary) !important;
}

.list-group-item-action:hover {
    background: var(--bg-hover) !important;
    color: var(--text-primary) !important;
}

.list-group-item-action:focus {
    background: var(--bg-hover) !important;
    color: var(--text-primary) !important;
}

/* Dropdowns */
.dropdown-menu {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
}

.dropdown-item {
    color: var(--text-primary) !important;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
}

.dropdown-item:hover {
    background: var(--bg-hover) !important;
    color: var(--text-primary) !important;
}

.dropdown-item:focus {
    background: var(--bg-hover) !important;
    color: var(--text-primary) !important;
}

/* Offcanvas (Bootstrap) - Dark Mode */
.offcanvas {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
    box-shadow: var(--shadow-lg);
}

.offcanvas.offcanvas-bottom {
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
}

.offcanvas-header {
    border-bottom: 1px solid var(--border-color) !important;
    background: var(--bg-secondary) !important;
}

.offcanvas-title {
    color: var(--text-primary) !important;
    font-weight: 650;
}

.offcanvas-body {
    background: var(--bg-secondary) !important;
}

.offcanvas-backdrop.show {
    opacity: 0.65;
}

/* Modals */
.modal-content {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

/* Ensure scroll works in scrollable modals */
.modal-dialog-scrollable {
    height: calc(100vh - 2rem);
}
.modal-dialog-scrollable .modal-content {
    max-height: 100%;
}
.modal-dialog-scrollable .modal-body {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
}

.modal-header {
    border-bottom: 1px solid var(--border-color) !important;
    padding: 1.25rem;
    background: var(--bg-card) !important;
}

.modal-title {
    color: var(--text-primary) !important;
    font-weight: 600;
}

.modal-body {
    padding: 1.25rem;
    color: var(--text-primary) !important;
    background: var(--bg-card) !important;
}

.modal-footer {
    border-top: 1px solid var(--border-color) !important;
    padding: 1.25rem;
    background: var(--bg-card) !important;
}

.btn-close {
    filter: invert(1);
    opacity: 0.7;
}

.btn-close:hover {
    opacity: 1;
}

/* Input Groups */
.input-group-text {
    background: var(--bg-tertiary) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
}

/* Links */
a {
    color: var(--accent-primary) !important;
    text-decoration: none;
}

a:hover {
    color: var(--accent-primary-hover) !important;
    text-decoration: underline;
}

a.text-decoration-none {
    text-decoration: none !important;
}

a.text-decoration-none:hover {
    text-decoration: underline !important;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-color);
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary) !important;
    font-weight: 600;
}

h1 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
}

h5, h6 {
    color: var(--text-primary) !important;
}

/* Text Colors */
.text-muted {
    color: var(--text-muted) !important;
}

.text-secondary {
    color: var(--text-secondary) !important;
}

.text-primary {
    color: var(--accent-primary) !important;
}

.text-dark {
    color: var(--text-primary) !important;
}

.text-light {
    color: var(--text-secondary) !important;
}

/* Border */
.border {
    border-color: var(--border-color) !important;
}

.border-top {
    border-top-color: var(--border-color) !important;
}

.border-bottom {
    border-bottom-color: var(--border-color) !important;
}

/* Pagination */
.pagination .page-link {
    background: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

.pagination .page-link:hover {
    background: var(--bg-hover) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

.pagination .page-item.active .page-link {
    background: var(--accent-primary) !important;
    border-color: var(--accent-primary) !important;
    color: white !important;
}

/* Stream Highlight */
.event-highlighted {
    background: var(--highlight-bg) !important;
    color: var(--highlight-text) !important;
    border-left: 4px solid var(--accent-primary) !important;
    padding-left: 1rem !important;
    transition: all 0.3s ease;
}

.event-highlighted * {
    color: var(--highlight-text) !important;
}

.event-highlighted strong {
    color: var(--highlight-text) !important;
}

.event-highlighted small {
    color: var(--highlight-text) !important;
}

.event-highlighted .badge {
    background: rgba(255, 255, 255, 0.2) !important;
    color: var(--highlight-text) !important;
}

/* Quill Editor Dark Mode */
.ql-container {
    background: var(--bg-input) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
    border-radius: 0 0 8px 8px;
}

.ql-toolbar {
    background: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    border-radius: 8px 8px 0 0;
}

.ql-stroke {
    stroke: var(--text-primary) !important;
}

.ql-fill {
    fill: var(--text-primary) !important;
}

.ql-picker-label {
    color: var(--text-primary) !important;
}

.ql-picker-options {
    background: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    box-shadow: var(--shadow-lg);
}

.ql-editor {
    color: var(--text-primary) !important;
}

.ql-editor.ql-blank::before {
    color: var(--text-muted) !important;
}

/* TinyMCE Dark Mode */
.tox-tinymce {
    background: var(--bg-input) !important;
    border-color: var(--border-color) !important;
    border-radius: 8px;
}

.tox .tox-toolbar,
.tox .tox-toolbar__overflow,
.tox .tox-toolbar__primary {
    background: var(--bg-card) !important;
}

.tox .tox-edit-area__iframe {
    background: var(--bg-input) !important;
}

.tox .tox-menubar {
    background: var(--bg-card) !important;
    border-bottom-color: var(--border-color) !important;
}

.tox .tox-menu {
    background: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    box-shadow: var(--shadow-lg);
}

.tox .tox-menu__label {
    color: var(--text-primary) !important;
}

.tox .tox-button {
    color: var(--text-primary) !important;
}

/* Container */
.container-fluid {
    padding: 1rem;
}

/* Mobile First - Responsive Design */
@media (max-width: 576px) {
    .container-fluid {
        padding: 0.75rem;
    }
    
    h1 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }
    
    .card {
        margin-bottom: 0.75rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .card-header {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
    
    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
        min-height: 44px;
        min-width: 44px;
    }
    
    .navbar-brand {
        font-size: 1.125rem;
    }
    
    .nav-link {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.875rem;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .list-group-item {
        padding: 0.75rem;
    }
    
    .form-control, .form-select {
        font-size: 0.875rem;
        padding: 0.5rem;
    }
    
    .badge {
        font-size: 0.65rem;
        padding: 0.25rem 0.5rem;
    }
    
    .modal-dialog {
        margin: 0.5rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .row {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
    }
    
    .row > * {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    /* NICHT global alle justify-content-between stacks erzwingen.
       Das zerstört Detail-Header/Toolbars. Verwende stattdessen gezielt flex-wrap/gap in den Views. */
    
    .btn-group {
        width: 100%;
        flex-direction: column;
    }
    
    .btn-group .btn {
        flex: 1;
        margin-bottom: 0.25rem;
    }
    
    .row.g-3 > * {
        margin-bottom: 0.75rem;
    }
}

@media (min-width: 577px) and (max-width: 768px) {
    .container-fluid {
        padding: 1rem;
    }
    
    h1 {
        font-size: 1.75rem;
    }
}

@media (min-width: 769px) {
    .container-fluid {
        padding: 1.5rem;
    }
}

/* Ensure tables are always dark */
.table-responsive .table {
    background: var(--bg-card) !important;
}

.table-responsive {
    background: var(--bg-card) !important;
    border-radius: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Fix for any white backgrounds */
.white, .bg-white {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
}

/* Ensure all text is readable */
p, span, div, td, th, li {
    color: inherit;
}

/* Fix for rounded circles in navbar */
.rounded-circle.bg-primary {
    background: var(--accent-primary) !important;
    color: white !important;
}

/* Override Bootstrap defaults */
.table-striped tbody tr:nth-of-type(odd) {
    background-color: var(--bg-table-row) !important;
}

.table-striped tbody tr:nth-of-type(even) {
    background-color: var(--bg-table-row) !important;
}

/* Force dark backgrounds everywhere */
tbody, thead, tfoot {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
}

/* Invalid feedback */
.invalid-feedback {
    color: var(--accent-danger) !important;
}

/* Valid feedback */
.valid-feedback {
    color: var(--accent-success) !important;
}

/* Input group */
.input-group > .form-control,
.input-group > .form-select {
    background: var(--bg-input) !important;
    color: var(--text-primary) !important;
}

/* Ensure all select options are dark */
select option {
    background: var(--bg-input) !important;
    color: var(--text-primary) !important;
}

/* Textarea */
textarea.form-control {
    background: var(--bg-input) !important;
    color: var(--text-primary) !important;
}

/* Small text */
small {
    color: var(--text-muted) !important;
}

/* Checkbox visibility (dark theme): ensure checkboxes are visible/clickable in tables and lists */
input[type="checkbox"] {
    accent-color: var(--accent-primary);
}

.form-check-input[type="checkbox"] {
    background-color: var(--bg-input) !important;
    border: 1px solid var(--border-color) !important;
}

.table .form-check-input[type="checkbox"],
.table-responsive .form-check-input[type="checkbox"] {
    /* In Tabellen sind Checkboxen sonst zu wenig kontrastreich */
    -webkit-appearance: auto !important;
    appearance: auto !important;
    opacity: 1 !important;
    visibility: visible !important;
    display: inline-block !important;
    width: 1.15rem;
    height: 1.15rem;
    border-width: 2px !important;
    border-color: rgba(228, 228, 228, 0.55) !important;
    background-color: rgba(0, 0, 0, 0.20) !important;
}

.table .form-check-input[type="checkbox"]:hover,
.table-responsive .form-check-input[type="checkbox"]:hover {
    border-color: rgba(74, 158, 255, 0.65) !important;
}

.form-check-input[type="checkbox"]:checked {
    background-color: var(--accent-primary) !important;
    border-color: var(--accent-primary) !important;
}

.form-check-input[type="checkbox"]:focus {
    box-shadow: 0 0 0 0.2rem rgba(74, 158, 255, 0.25) !important;
}

/* Strong text */
strong {
    color: var(--text-primary) !important;
    font-weight: 600;
}

/* Mobile table improvements */
@media (max-width: 768px) {
    .table-responsive {
        border-radius: 0;
        margin: 0 -1rem;
        padding: 0 1rem;
    }
    
    .table {
        min-width: 600px;
    }
}

/* Ensure Quill editor is dark on mobile */
@media (max-width: 768px) {
    .ql-container {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* NOTE: No global column overrides on mobile.
   Bootstrap already stacks columns < md; global overrides break complex layouts. */

/* Tasks: Mobile polish (Filter + Header) */
.btn-icon {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 12px;
}

.page-mobile-topbar {
    position: sticky;
    top: 4.25rem; /* unter der globalen App-Topbar */
    z-index: 1020;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 14px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    backdrop-filter: blur(10px);
}

.page-mobile-title {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    line-height: 1.2;
}

.page-mobile-title .page-mobile-title-main {
    font-weight: 650;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.page-mobile-title .page-mobile-title-sub {
    color: var(--text-muted);
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Page header (desktop): modern 2026 style */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-radius: 16px;
    background: linear-gradient(180deg, var(--page-header-bg-top), var(--page-header-bg-bottom));
    border: 1px solid var(--page-header-border);
    box-shadow: var(--page-header-shadow);
    backdrop-filter: blur(10px);
}

.page-header .breadcrumb {
    margin-bottom: 0.35rem;
    font-size: 0.875rem;
}

.page-header .breadcrumb a {
    color: var(--text-secondary) !important;
}

.page-header .breadcrumb .active {
    color: var(--text-muted) !important;
}

.page-header h1 {
    margin: 0;
}

.page-header-subtitle {
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Page tabs (modern, mobile-first): pill/segmented + scroll */
.page-tabs {
    display: flex;
    gap: 0.35rem;
    padding: 0.4rem;
    border-radius: 16px;
    background: var(--glass-bg-soft);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
}

.page-tabs::-webkit-scrollbar {
    display: none;
}

.page-tabs .nav-link {
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 0.5rem 0.85rem;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--text-secondary) !important;
    font-weight: 600;
    white-space: nowrap;
    background: transparent !important;
}

.page-tabs .nav-link:hover {
    background: rgba(255, 255, 255, 0.06) !important;
    color: var(--text-primary) !important;
}

.page-tabs .nav-link.active {
    background: rgba(74, 158, 255, 0.18) !important;
    border-color: rgba(74, 158, 255, 0.55) !important;
    color: var(--text-primary) !important;
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.12);
}

.page-tabs.nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.page-tabs.nav::-webkit-scrollbar {
    display: none;
}

.page-tabs .nav-item {
    flex: 0 0 auto;
}

/* Generic: Active filters bar (mobile friendly) */
.page-active-filters .page-reset-btn {
    white-space: nowrap;
}

/* List toolbars (state-of-the-art) */
.page-list-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    border-radius: 16px;
    background: rgba(37, 37, 37, 0.55);
    border: 1px solid rgba(64, 64, 64, 0.85);
    backdrop-filter: blur(10px);
}

.page-list-toolbar .toolbar-left {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.page-list-toolbar .toolbar-title {
    font-weight: 700;
    font-size: 1.15rem;
    line-height: 1.2;
}

.page-list-toolbar .toolbar-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.page-list-toolbar .toolbar-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.page-filter-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.page-filter-card .filter-hint {
    color: var(--text-muted);
    font-size: 0.85rem;
}

@media (max-width: 576px) {
    .page-active-filters {
        flex-direction: column;
        align-items: stretch !important;
    }

    .page-active-filters .page-reset-btn {
        width: 100%;
        margin-left: 0 !important;
    }

    .page-list-toolbar {
        padding: 0.75rem;
        border-radius: 14px;
    }
}

/* (migrated) tasks mobile header now uses .page-mobile-topbar */

@media (max-width: 576px) {
    .tasks-index-header {
        gap: 0.75rem;
    }

    .tasks-index-header h1 {
        font-size: 1.35rem;
        min-width: 0;
    }

    .tasks-index-actions {
        width: 100%;
    }

    .tasks-index-actions .btn {
        flex: 1 1 0;
        justify-content: center;
    }

    .tasks-active-filters {
        flex-direction: column;
        align-items: stretch !important;
    }

    .tasks-active-filters .tasks-reset-btn {
        width: 100%;
        margin-left: 0 !important;
    }
}
