/*
 * WebBI - Blazor Application Custom Styles
 * Based on Domiex Admin Template
 * Version 3.0 - Complete Layout Fix
 */

/* ============================================
   CSS Variables
   ============================================ */
:root {
    --dx-primary: #358ffc;
    --dx-primary-rgb: 53, 143, 252;
    --dx-primary-dark: #2563eb;
    --dx-secondary: #6b7280;
    --dx-success: #22c55e;
    --dx-danger: #ef4444;
    --dx-warning: #eab308;
    --dx-info: #0ea5e9;
    
    --dx-sidebar-width: 260px;
    --dx-sidebar-collapsed-width: 70px;
    --dx-topbar-height: 64px;
    
    --dx-body-bg: #f1f5f9;
    --dx-card-bg: #ffffff;
    --dx-border-color: #e2e8f0;
    --dx-text-color: #334155;
    --dx-text-muted: #64748b;
    
    --dx-font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --dx-transition: all 0.3s ease;
}

[data-bs-theme="dark"] {
    --dx-body-bg: #0f172a;
    --dx-card-bg: #1e293b;
    --dx-border-color: #334155;
    --dx-text-color: #e2e8f0;
    --dx-text-muted: #94a3b8;
}

/* ============================================
   Reset & Base
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    font-family: var(--dx-font-family);
    background-color: var(--dx-body-bg);
    color: var(--dx-text-color);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* ============================================
   Page Wrapper
   ============================================ */
.page-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
    padding:0px;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
    width: var(--dx-sidebar-width);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    background: var(--dx-card-bg);
    border-right: 1px solid var(--dx-border-color);
    z-index: 1040;
    transition: width 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar.sidebar-collapsed {
    width: var(--dx-sidebar-collapsed-width);
}

/* Shift sidebar down when Design Mode bar is active (44px bar height) */
.sidebar.sidebar-design-mode {
    top: 44px;
    height: calc(100vh - 44px);
}

.sidebar.sidebar-collapsed .logo-text,
.sidebar.sidebar-collapsed .sidebar-menu-text,
.sidebar.sidebar-collapsed .sidebar-menu-title,
.sidebar.sidebar-collapsed .submenu-arrow,
.sidebar.sidebar-collapsed .sidebar-submenu {
    display: none !important;
}

.sidebar.sidebar-collapsed .sidebar-menu-link {
    justify-content: center;
    padding: 0.75rem;
}

.sidebar.sidebar-collapsed .sidebar-menu-icon {
    margin-right: 0;
}

.sidebar-header {
    height: var(--dx-topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    border-bottom: 1px solid var(--dx-border-color);
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
}

.sidebar-logo .logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--dx-primary), var(--dx-primary-dark));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
}

.sidebar-logo .logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--dx-text-color);
}

.btn-sidebar-toggle {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--dx-text-muted);
    cursor: pointer;
    transition: var(--dx-transition);
}

.btn-sidebar-toggle:hover {
    background: rgba(var(--dx-primary-rgb), 0.1);
    color: var(--dx-primary);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.sidebar-content::-webkit-scrollbar {
    width: 4px;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: var(--dx-border-color);
    border-radius: 4px;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-menu-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--dx-text-muted);
    padding: 1.25rem 1.25rem 0.5rem;
    margin-top: 0.5rem;
}

.sidebar-menu-item {
    margin: 2px 8px;
}

.sidebar-menu-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    color: var(--dx-text-color);
    text-decoration: none;
    border-radius: 8px;
    transition: var(--dx-transition);
    font-size: 0.875rem;
    font-weight: 500;
}

.sidebar-menu-link:hover {
    background: rgba(32, 146, 236, 0.08);
    color: #2092EC;
}

/* Materio-Style Active State: Blauer Gradient + Schatten + weiße Schrift */
.sidebar-menu-link.active,
.sidebar-menu-link.active:hover {
    background: linear-gradient(72.47deg, #2092EC 22.16%, rgba(32, 146, 236, 0.7) 76.47%) !important;
    color: #ffffff !important;
    box-shadow: 0 0.125rem 0.375rem 0 rgba(32, 146, 236, 0.3);
    border-radius: 0.375rem;
    font-weight: 600;
}

.sidebar-menu-link.active .sidebar-menu-icon,
.sidebar-menu-link.active .sidebar-menu-text,
.sidebar-menu-link.active .submenu-arrow {
    color: #ffffff !important;
}

.sidebar-menu-icon {
    font-size: 1.25rem;
    width: 1.5rem;
    text-align: center;
    flex-shrink: 0;
}

.submenu-arrow {
    margin-left: auto;
    font-size: 1rem;
    transition: transform 0.2s ease;
}

.submenu-arrow.rotate {
    transform: rotate(180deg);
}

.sidebar-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.sidebar-submenu.show {
    max-height: 500px;
}

.sidebar-submenu-item {
    margin: 2px 0;
}

.sidebar-submenu-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem 0.5rem 2.75rem;
    color: var(--dx-text-muted);
    text-decoration: none;
    font-size: 0.8125rem;
    border-radius: 6px;
    transition: var(--dx-transition);
}

.sidebar-submenu-link:hover {
    color: #2092EC;
    background: rgba(32, 146, 236, 0.08);
}

/* Active sub-entity link: same blue gradient as parent items for clear visibility */
.sidebar-submenu-link.active {
    color: #fff !important;
    background: linear-gradient(72.47deg, #2092EC 22.16%, rgba(32, 146, 236, 0.7) 76.47%) !important;
    box-shadow: 0 0.125rem 0.25rem 0 rgba(32, 146, 236, 0.25);
    border-radius: 0.375rem;
    font-weight: 600;
}

.sidebar-submenu-icon {
    font-size: 1rem;
    width: 1.25rem;
    text-align: center;
}

/* ============================================
   Main Content - WICHTIG: margin-left statt padding!
   ============================================ */
.main-content {
    /*margin-left: var(--dx-sidebar-width);*/
    width: calc(100% - var(--dx-sidebar-width));
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /*background: var(--dx-body-bg);*/
    transition: margin-left 0.3s ease, width 0.3s ease;
}

.sidebar.sidebar-collapsed ~ .main-content {
    margin-left: var(--dx-sidebar-collapsed-width);
    width: calc(100% - var(--dx-sidebar-collapsed-width));
}

/* ============================================
   Topbar
   ============================================ */
.topbar {
    height: var(--dx-topbar-height);
    background: var(--dx-card-bg);
    border-bottom: 1px solid var(--dx-border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1045;
    flex-shrink: 0;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.topbar-search {
    position: relative;
    max-width: 400px;
    flex: 1;
}

.topbar-search .search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--dx-text-muted);
    pointer-events: none;
}

.topbar-search .form-control {
    padding-left: 2.75rem;
    height: 40px;
    border-radius: 8px;
    border: 1px solid var(--dx-border-color);
    background: var(--dx-body-bg);
    font-size: 0.875rem;
    width: 100%;
}

.topbar-search .form-control:focus {
    border-color: var(--dx-primary);
    box-shadow: 0 0 0 3px rgba(var(--dx-primary-rgb), 0.15);
    background: var(--dx-card-bg);
    outline: none;
}

.search-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--dx-card-bg);
    border: 1px solid var(--dx-border-color);
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    max-height: 320px;
    overflow-y: auto;
    z-index: 1050;
}

.search-dropdown-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid var(--dx-border-color);
}

.search-dropdown-item:last-child {
    border-bottom: none;
}

.search-dropdown-item:hover {
    background: rgba(var(--dx-primary-rgb), 0.05);
}

/* ============================================
   Page Content - Volle Breite!
   ============================================ */
.page-content {
    flex: 1;
    padding: 1.5rem;
    padding-bottom: 60px;
    width: 100%;
    max-width: 100%;
}

/* ============================================
   Design Mode Button + Bar
   ============================================ */
.designer-mode-btn {
    background: linear-gradient(135deg, #FF6B35 0%, #F7931E 100%);
    color: #fff !important;
    border: none;
    border-radius: 0.5rem;
    padding: 0.375rem 0.875rem;
    font-weight: 600;
    font-size: 0.8125rem;
    transition: all 0.2s;
    box-shadow: 0 2px 6px rgba(255, 107, 53, 0.3);
}
.designer-mode-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.4);
    color: #fff !important;
    background: linear-gradient(135deg, #E55A2B 0%, #D4800F 100%);
}
.designer-mode-btn.active {
    background: linear-gradient(135deg, #E55A2B 0%, #D4800F 100%);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.3), 0 2px 6px rgba(255, 107, 53, 0.3);
}

.design-mode-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #FFF3E0 0%, #FFE0B2 100%);
    border-bottom: 2px solid #FF9800;
    padding: 0 1.25rem;
    height: 44px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.15);
    position: sticky;
    top: 0;
    z-index: 1060;
}
.design-mode-bar-left {
    flex-shrink: 0;
}
.design-mode-title {
    font-weight: 700;
    color: #E65100;
    font-size: 0.875rem;
    white-space: nowrap;
    display: flex;
    align-items: center;
}
.design-mode-nav {
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
    margin: 0 1rem;
}
.design-mode-link {
    color: #BF360C;
    text-decoration: none;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    transition: all 0.15s;
    white-space: nowrap;
}
.design-mode-link:hover {
    background: rgba(255, 152, 0, 0.15);
    color: #E65100;
    text-decoration: none;
}
.design-mode-link.active {
    background: #FF9800;
    color: #fff !important;
    box-shadow: 0 2px 6px rgba(255, 152, 0, 0.3);
}
.design-mode-bar-right {
    flex-shrink: 0;
}
.design-mode-exit {
    background: rgba(191, 54, 12, 0.1);
    color: #BF360C;
    border: 1px solid rgba(191, 54, 12, 0.3);
    font-weight: 600;
    font-size: 0.75rem;
    white-space: nowrap;
}
.design-mode-exit:hover {
    background: #BF360C;
    color: #fff;
    border-color: #BF360C;
}

@media (max-width: 768px) {
    .design-mode-bar {
        height: auto;
        flex-wrap: wrap;
        padding: 0.5rem;
        gap: 0.5rem;
    }
    .design-mode-nav {
        margin: 0;
        width: 100%;
    }
}

/* ============================================
   App Footer - Copyright + Version Info
   ============================================ */
.app-footer {
    border-top: 1px solid #e7e7e8;
    background: #fff;
    color: #6f6b7d;
    font-size: 0.8125rem;
    flex-shrink: 0;
    margin-top: auto;
}
.app-footer .app-footer-copyright {
    font-weight: 500;
}
.app-footer .app-footer-version strong {
    color: #2092EC;
    font-weight: 600;
}
@media (max-width: 767px) {
    .app-footer .container-fluid {
        gap: 4px;
        text-align: center;
    }
}

/* Container-Fluid OHNE max-width */
.page-content .container-fluid,
.page-content > .container-fluid {
    width: 100%;
    max-width: 100%;
    padding: 0 0 0 10px;
    margin: 0;
    display:inherit;
}

/* ============================================
   Page Header - EINHEITLICHES LAYOUT
   Titel oben, Buttons rechts daneben oder darunter
   ============================================ */
.page-header,
.d-flex.justify-content-between.align-items-center.mb-4,
.container-fluid.mt-4 > .d-flex.justify-content-between {
    display: flex !important;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--dx-border-color);
    width: 100%;
}

.page-header h2,
.container-fluid h2,
.container-fluid.mt-4 h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--dx-text-color);
    flex: 1;
    min-width: 200px;
}

/* Reset mt-4 auf container-fluid */
.container-fluid.mt-4 {
    margin-top: 0 !important;
}

/* ============================================
   CARDS GRID - Für Rollen/Module Verwaltung
   ============================================ */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: -0.75rem;
    width: calc(100% + 1.5rem);
}

.row.g-3 {
    margin: -0.5rem;
    width: calc(100% + 1rem);
}

.row > [class*="col-"] {
    padding: 0.75rem;
}

.row.g-3 > [class*="col-"] {
    padding: 0.5rem;
}

/* Spalten-Breiten */
.col-12 { width: 100%; }
.col-md-6 { width: 100%; }
.col-lg-4 { width: 100%; }

@media (min-width: 768px) {
    .col-md-6 { width: 50%; }
}

@media (min-width: 992px) {
    .col-lg-4 { width: 33.333%; }
}

/* ============================================
   Cards
   ============================================ */
.card {
    background: var(--dx-card-bg);
    border: 1px solid var(--dx-border-color);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: var(--dx-transition);
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--dx-border-color);
    background: transparent;
}

.card-body {
    padding: 1.25rem;
    flex: 1;
}

.card-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--dx-border-color);
    background: transparent;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--dx-text-color);
}

.card-text {
    font-size: 0.875rem;
    color: var(--dx-text-muted);
    margin-bottom: 0.25rem;
}

.card-actions,
.module-card .card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--dx-border-color);
}

.h-100 {
    height: 100% !important;
}

/* ============================================
   Data List Container - Module Views
   ============================================ */
.data-list-container {
    width: 100%;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

    .data-list-container .page-container {
        width: 100%;
        
    }

.data-list-container .page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--dx-border-color);
}

.data-list-container .page-header > div:first-child {
    flex: 1;
    min-width: 200px;
}

.data-list-container .page-header h2 {
    margin: 0 0 0.25rem 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.data-list-container .page-content {
    padding: 0;
}

/* View Mode Buttons */
.view-mode-selector,
.btn-group.view-mode-selector {
    display: inline-flex;
}

.view-mode-selector .btn {
    border-radius: 0;
}

.view-mode-selector .btn:first-child {
    border-radius: 6px 0 0 6px;
}

.view-mode-selector .btn:last-child {
    border-radius: 0 6px 6px 0;
}

.btn-group {
    display: inline-flex;
}

/* ============================================
   KALENDER VIEW - 7-Spalten Grid!
   ============================================ */
.calendar-view {
    background: var(--dx-card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid var(--dx-border-color);
    width: 100%;
    max-height: calc(100vh - 250px);
    overflow-y: auto;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--dx-border-color);
}

.calendar-header h4 {
    margin: 0;
    font-weight: 600;
    flex: 1;
    text-align: center;
}

/* WICHTIG: Kalender Grid mit 7 Spalten */
.calendar-grid {
    display: grid !important;
    grid-template-columns: repeat(7, 1fr) !important;
    gap: 4px !important;
    width: 100% !important;
}

.calendar-weekday {
    text-align: center;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--dx-text-muted);
    padding: 0.75rem 0.5rem;
    background: var(--dx-body-bg);
    border-radius: 6px;
}

.calendar-day {
    aspect-ratio: 1;
    min-height: 80px;
    padding: 0.5rem;
    background: var(--dx-body-bg);
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    transition: var(--dx-transition);
}

.calendar-day:hover {
    border-color: var(--dx-primary);
    background: white;
}

.calendar-day.today {
    background: rgba(var(--dx-primary-rgb), 0.1);
    border-color: var(--dx-primary);
}

.calendar-day.other-month {
    opacity: 0.4;
}

.calendar-day .day-number {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--dx-text-color);
}

.calendar-day .day-events {
    flex: 1;
    margin-top: 0.25rem;
    overflow: hidden;
}

.calendar-event {
    font-size: 0.6875rem;
    padding: 2px 4px;
    background: var(--dx-primary);
    color: white;
    border-radius: 3px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   KARTEI VIEW - Links Buchstaben, Rechts Cards
   ============================================ */
.card-index-view {
    display: flex !important;
    flex-direction: row !important;
    gap: 1.5rem;
    background: var(--dx-card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid var(--dx-border-color);
    min-height: 500px;
    width: 100%;
}

.card-index-sidebar {
    width: 60px !important;
    min-width: 60px !important;
    flex-shrink: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 4px;
    background: var(--dx-body-bg);
    border-radius: 8px;
    padding: 0.5rem;
    max-height: calc(100vh - 300px);
    overflow-y: auto;
}

.card-index-tab {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0.5rem;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    min-height: 50px;
    transition: var(--dx-transition);
}

.card-index-tab:hover:not(:disabled) {
    background: rgba(var(--dx-primary-rgb), 0.1);
}

.card-index-tab.active {
    background: var(--dx-primary);
    color: white;
}

.card-index-tab:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.card-index-tab .letter {
    font-weight: 700;
    font-size: 1rem;
}

.card-index-tab .count {
    font-size: 0.625rem;
    opacity: 0.7;
}

.card-index-content {
    flex: 1 !important;
    overflow-y: auto;
    min-width: 0;
}

.card-index-content h4 {
    margin: 0 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--dx-primary);
    font-weight: 600;
    color: var(--dx-primary);
}

/* Cards in Kartei-Content */
.card-index-content .row.g-3 {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)) !important;
    gap: 1rem !important;
    margin: 0 !important;
    width: 100% !important;
}

.card-index-content .row.g-3 > [class*="col-"] {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
}

/* ============================================
   Tables
   ============================================ */
.table {
    width: 100%;
    margin-bottom: 0;
    background: var(--dx-card-bg);
    border-collapse: collapse;
}

.table th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--dx-text-muted);
    background: var(--dx-body-bg);
    border-bottom: 2px solid var(--dx-border-color);
    padding: 0.875rem 1rem;
    white-space: nowrap;
}

.table td {
    vertical-align: middle;
    border-bottom: 1px solid var(--dx-border-color);
    padding: 0.875rem 1rem;
}

.table tbody tr:hover {
    background: rgba(var(--dx-primary-rgb), 0.03);
}

.table-hover tbody tr:hover {
    background: rgba(var(--dx-primary-rgb), 0.05);
}

/* ============================================
   DESIGNER LAYOUT - Header oben, dann 3 Spalten
   ============================================ */
/* .designer-header is now styled inline on each page for unified toolbar look */

/* Designer 3-Spalten Layout */
.designer-header + .container-fluid,
.page-content .designer-header + .container-fluid {
    display: grid !important;
    grid-template-columns: 220px 1fr 280px !important;
    gap: 1.5rem !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
}

.toolbox {
    background: var(--dx-card-bg);
    border-radius: 12px;
    border: 1px solid var(--dx-border-color);
    padding: 1rem;
    height: fit-content;
    position: sticky;
    /*top: calc(var(--dx-topbar-height) + 1.5rem);*/
    max-height: calc(100vh - var(--dx-topbar-height) - 100px);
    overflow-y: auto;
}

.toolbox-section {
    margin-bottom: 1.5rem;
}

.toolbox-section:last-child {
    margin-bottom: 0;
}

.toolbox-section h2 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--dx-text-muted);
    margin: 0 0 0.75rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--dx-border-color);
}

.toolbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--dx-body-bg);
    border-radius: 6px;
    margin-bottom: 0.375rem;
    cursor: grab;
    font-size: 0.8125rem;
    border: 1px solid transparent;
    transition: var(--dx-transition);
}

.toolbox-item:hover {
    border-color: var(--dx-primary);
    background: rgba(var(--dx-primary-rgb), 0.05);
}

.toolbox-icon {
    font-size: 1rem;
    width: 1.25rem;
    text-align: center;
}

.canvas-container {
    background: var(--dx-card-bg);
    border-radius: 12px;
    border: 1px solid var(--dx-border-color);
    min-height: 500px;
    margin-left:40px;
}

.canvas {
    padding: 1.5rem;
    min-height: 400px;
}

.canvas-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: var(--dx-text-muted);
    text-align: center;
}

.canvas-empty i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.canvas-empty h3 {
    margin: 0 0 0.5rem 0;
    font-weight: 600;
}

.canvas-empty p {
    margin: 0;
    font-size: 0.875rem;
}

.properties {
    background: var(--dx-card-bg);
    border-radius: 12px;
    border: 1px solid var(--dx-border-color);
    padding: 1rem;
    height: fit-content;
    position: sticky;
    /*top: calc(var(--dx-topbar-height) + 1.5rem);*/
    max-height: calc(100vh - var(--dx-topbar-height) - 100px);
    overflow-y: auto;
    width: 280px;
    min-width: 280px;
    max-width: 280px;
}

.properties h2 {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0 0 1rem 0;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--dx-border-color);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--dx-transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--dx-primary);
    border-color: var(--dx-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--dx-primary-dark);
    border-color: var(--dx-primary-dark);
    color: white;
}

.btn-success {
    background: var(--dx-success);
    border-color: var(--dx-success);
    color: white;
}

.btn-success:hover {
    background: #16a34a;
    border-color: #16a34a;
    color: white;
}

.btn-danger {
    background: var(--dx-danger);
    border-color: var(--dx-danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
    color: white;
}

.btn-info {
    background: var(--dx-info);
    border-color: var(--dx-info);
    color: white;
}

.btn-info:hover {
    background: #0284c7;
    border-color: #0284c7;
    color: white;
}

.btn-outline-primary {
    color: var(--dx-primary);
    border-color: var(--dx-primary);
    background: transparent;
}

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

.btn-outline-secondary {
    color: var(--dx-secondary);
    border-color: var(--dx-border-color);
    background: transparent;
}

.btn-outline-secondary:hover {
    background: var(--dx-secondary);
    color: white;
    border-color: var(--dx-secondary);
}

.btn-outline-danger {
    color: var(--dx-danger);
    border-color: var(--dx-danger);
    background: transparent;
}

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

.btn-outline {
    color: var(--dx-text-color);
    border-color: var(--dx-border-color);
    background: transparent;
}

.btn-outline:hover {
    background: var(--dx-body-bg);
}

.btn-ghost {
    background: transparent;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    color: var(--dx-text-muted);
    cursor: pointer;
    transition: var(--dx-transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-ghost:hover {
    background: rgba(var(--dx-primary-rgb), 0.08);
    color: var(--dx-primary);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

/* ============================================
   Forms
   ============================================ */
.form-control, .form-select {
    display: block;
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--dx-border-color);
    padding: 0.5rem 0.875rem;
    font-size: 0.875rem;
    transition: var(--dx-transition);
    background: var(--dx-card-bg);
    color: var(--dx-text-color);
}

.form-control:focus, .form-select:focus {
    border-color: var(--dx-primary);
    box-shadow: 0 0 0 3px rgba(var(--dx-primary-rgb), 0.15);
    outline: none;
}

.form-label {
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.375rem;
    color: var(--dx-text-color);
    display: block;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-check-input {
    width: 1.25em;
    height: 1.25em;
    margin: 0;
    border: 2px solid #adb5bd;
    border-radius: 4px;
    background-color: #fff;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.form-check-input:checked {
    background-color: #fff;
    border-color: #198754;
}

.form-check-input:checked::after {
    content: '\2713';
    font-size: 1em;
    font-weight: 900;
    color: #198754;
    line-height: 1;
}

.form-check-input:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.15rem rgba(13, 110, 253, 0.25);
    outline: 0;
}

.form-check-label {
    margin: 0;
    font-size: 0.875rem;
}

/* Badge outline variants */
.badge.bg-outline-primary {
    background: transparent !important;
    color: #0d6efd;
    border: 1px solid #0d6efd;
}

.badge.bg-outline-success {
    background: transparent !important;
    color: #198754;
    border: 1px solid #198754;
}

.badge.bg-outline-warning {
    background: transparent !important;
    color: #ffc107;
    border: 1px solid #ffc107;
}

.badge.bg-outline-danger {
    background: transparent !important;
    color: #dc3545;
    border: 1px solid #dc3545;
}

/* ============================================
   Dropdowns
   ============================================ */
.dropdown {
    position: relative;
}

.dropdown-toggle::after {
    display: none;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 200px;
    background: var(--dx-card-bg);
    border: 1px solid var(--dx-border-color);
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    padding: 0.5rem 0;
    z-index: 1050;
    display: none;
    margin-top: 4px;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-header {
    padding: 0.75rem 1rem;
    background: var(--dx-body-bg);
}

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

.dropdown-item {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    color: var(--dx-text-color);
    text-decoration: none;
    font-size: 0.875rem;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    transition: background 0.15s;
}

.dropdown-item:hover {
    background: rgba(var(--dx-primary-rgb), 0.05);
}

.dropdown-item.active {
    background: rgba(var(--dx-primary-rgb), 0.1);
    color: var(--dx-primary);
}

.dropdown-item.text-danger {
    color: var(--dx-danger);
}

.dropdown-item.text-danger:hover {
    background: rgba(239, 68, 68, 0.08);
}

.user-menu {
    min-width: 240px;
}

.dropdown-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1040;
    display: none;
}

.dropdown-backdrop.active {
    display: block;
}

/* ============================================
   Avatar
   ============================================ */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 0.75rem;
}

.avatar-md {
    width: 40px;
    height: 40px;
    font-size: 0.875rem;
}

.avatar-text {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
}

/* ============================================
   Badges
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 4px;
}

.badge-notification {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.625rem;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
}

/* ============================================
   Alerts
   ============================================ */
.alert {
    padding: 0.875rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
    color: #b91c1c;
}

.alert-success {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.2);
    color: #15803d;
}

/* ============================================
   Auth Pages
   ============================================ */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, var(--dx-primary) 0%, var(--dx-primary-dark) 100%);
}

.auth-redirect-card {
    background: var(--dx-card-bg);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    padding: 3rem;
    max-width: 450px;
    width: 100%;
    text-align: center;
}

.auth-redirect-card h2 {
    color: var(--dx-text-color);
    margin-bottom: 0.5rem;
}

.auth-redirect-card .btn-lg {
    padding: 0.75rem 2rem;
    font-size: 1rem;
}

/* ============================================
   Mobile Sidebar
   ============================================ */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1035;
    opacity: 0;
    visibility: hidden;
    transition: var(--dx-transition);
}

.sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1199.98px) {
    .designer-header + .container-fluid {
        grid-template-columns: 180px 1fr 220px !important;
    }
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    .designer-header + .container-fluid {
        grid-template-columns: 1fr !important;
    }
    
    .toolbox, .properties {
        position: static;
        max-height: none;
    }
    
    .card-index-view {
        flex-direction: column !important;
    }
    
    .card-index-sidebar {
        width: 100% !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        max-height: none;
    }
    
    .card-index-tab {
        flex-direction: row !important;
        gap: 0.25rem;
        min-height: auto;
        padding: 0.375rem 0.5rem;
    }
}

@media (max-width: 767.98px) {
    .page-content {
        padding: 1rem;
    }
    
    .topbar {
        padding: 0 1rem;
    }
    
    .topbar-search {
        display: none;
    }
    
    .calendar-day {
        min-height: 60px;
        aspect-ratio: auto;
    }
    
    .designer-header {
        padding: 8px 12px !important;
    }
}

/* ============================================
   Utilities
   ============================================ */
.text-primary { color: var(--dx-primary) !important; }
.text-success { color: var(--dx-success) !important; }
.text-danger { color: var(--dx-danger) !important; }
.text-warning { color: var(--dx-warning) !important; }
.text-muted { color: var(--dx-text-muted) !important; }

.bg-primary { background-color: var(--dx-primary) !important; }
.bg-success { background-color: var(--dx-success) !important; }
.bg-danger { background-color: var(--dx-danger) !important; }
.bg-warning { background-color: var(--dx-warning) !important; }
.bg-info { background-color: var(--dx-info) !important; }
.bg-secondary { background-color: var(--dx-secondary) !important; }

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

.fw-medium { font-weight: 500; }
.fw-semibold { font-weight: 600; }

.gap-1 { gap: 0.25rem !important; }
.gap-2 { gap: 0.5rem !important; }
.gap-3 { gap: 1rem !important; }

.d-none { display: none !important; }
.d-flex { display: flex !important; }
.d-block { display: block !important; }
.d-inline-flex { display: inline-flex !important; }
.d-grid { display: grid !important; }

.d-lg-none { display: block !important; }
.d-lg-flex { display: none !important; }

@media (min-width: 992px) {
    .d-lg-none { display: none !important; }
    .d-lg-flex { display: flex !important; }
}

.d-md-inline { display: none !important; }
@media (min-width: 768px) {
    .d-md-inline { display: inline !important; }
}

.flex-wrap { flex-wrap: wrap !important; }
.align-items-center { align-items: center !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-center { justify-content: center !important; }

.w-100 { width: 100% !important; }
.h-100 { height: 100% !important; }

.position-relative { position: relative !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }

.me-1 { margin-right: 0.25rem !important; }
.me-2 { margin-right: 0.5rem !important; }
.ms-1 { margin-left: 0.25rem !important; }
.ms-2 { margin-left: 0.5rem !important; }

.p-0 { padding: 0 !important; }
.p-1 { padding: 0.25rem !important; }
.p-2 { padding: 0.5rem !important; }
.p-3 { padding: 1rem !important; }

.fs-5 { font-size: 1.25rem !important; }

.rotate-180 { transform: rotate(180deg); }

.container-fluid {
    width: 100%;
    max-width: 100%;
    padding: 0;
}

/* ============================================
   StatusBar
   ============================================ */
.status-bar {
    position: fixed;
    bottom: 0;
    left: var(--dx-sidebar-width);
    right: 0;
    z-index: 1020;
    transition: left 0.3s ease;
}

@media (max-width: 991.98px) {
    .status-bar {
        left: 0 !important;
    }
}

/* Fix: StatusBar Component */
statusbar {
    display: block;
}

/* ============================================
   Module-specific overrides - WICHTIG!
   ============================================ */
/* Data List Container darf NICHT max-width haben */

.data-list-container .page-container {
    padding: 0 0 0 20px;
}

.data-list-container,
.data-list-container .page-container,
.data-list-container .page-content {
    max-width: none !important;
    width: 100% !important;
    
}

/* Grid-View in Module-Ansichten nutzt jetzt .module-card-grid (siehe ModuleDataListView.razor).
   Die frueheren .row.g-3-Overrides wurden entfernt, weil sie faelschlicherweise im Formular
   (HorizontalLayout mit Group-Kindern) greifen und die horizontale Anordnung brechen. */
