/* WRS OrderTool - Main Stylesheet */
/* Professional color scheme */

:root {
    /* Primary colors - Professional blue-gray */
    --primary-color: #334155;
    --primary-dark: #1e293b;
    --primary-light: #475569;
    
    /* Accent colors */
    --accent-color: #3b82f6;
    --accent-dark: #2563eb;
    --accent-light: #60a5fa;
    
    /* Neutral colors */
    --gray-dark: #1f2937;
    --gray: #6b7280;
    --gray-light: #f3f4f6;
    --gray-border: #e5e7eb;
    --white: #ffffff;
    --black: #111827;
    
    /* Semantic colors */
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #d1d5db;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--gray-light);
}

a {
    color: var(--accent-color);
    text-decoration: none;
}

a:hover {
    color: var(--accent-dark);
    text-decoration: underline;
}

/* Container */
.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 20px;
    --container-padding: 20px;
}

.container h1 {
    text-align: left;
}

.orders-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* Navigation Bar */
.navbar {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--white);
    padding: 0 0.5rem 0 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    min-height: 70px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 1.25rem;
    font-weight: bold;
    padding: 0.75rem 0;
    margin-left: 0.5rem;
}

.navbar-brand .logo {
    height: 60px;
}

.navbar-menu {
    display: flex;
    list-style: none;
    gap: 0;
    align-items: stretch;
}

.navbar-menu li {
    display: flex;
    align-items: stretch;
}

.navbar-menu a {
    color: var(--white);
    text-decoration: none;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    transition: all 0.2s;
    position: relative;
}

.navbar-menu a:hover {
    background-color: rgba(0, 0, 0, 0.3);
    text-decoration: none;
}

.navbar-menu a.active {
    font-weight: 600;
}

.navbar-user {
    display: flex;
    gap: 0;
    align-items: stretch;
}


.navbar-user a {
    color: var(--white);
    text-decoration: none;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    transition: background-color 0.2s;
}

.navbar-user a:hover {
    background-color: rgba(0, 0, 0, 0.3);
    text-decoration: none;
}

.navbar-user a.active {
    font-weight: 600;
}

.navbar-user a[href="/logout"] {
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 6px;
    margin: auto 0.75rem;
    padding: 0.4rem 1rem;
    transition: all 0.2s;
    font-weight: 600;
}

.navbar-user a[href="/logout"]:hover {
    background-color: rgba(0, 0, 0, 0.65);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Mobile burger menu */
.navbar-burger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    align-self: center;
    width: 50px;
    height: 50px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    margin-right: 1rem;
}

.navbar-burger span {
    display: block;
    width: 25px;
    height: 3px;
    background-color: var(--white);
    margin: 3px 0;
    transition: all 0.3s;
    border-radius: 2px;
}

/* Mobile sidebar */
.navbar-sidebar {
    position: fixed;
    top: 0;
    right: -100%;
    width: 280px;
    height: 100vh;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.3);
    transition: right 0.3s ease-in-out;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.navbar-sidebar.active {
    right: 0;
}

.navbar-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.navbar-close {
    background: none;
    border: none;
    color: var(--white);
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    border-radius: 4px;
}

.navbar-close:hover {
    background-color: rgba(0, 0, 0, 0.3);
}

.navbar-sidebar-content {
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
}

.navbar-sidebar-content a {
    color: var(--white);
    text-decoration: none;
    padding: 1rem 1.5rem;
    transition: background-color 0.2s;
    border-left: 3px solid transparent;
}

.navbar-sidebar-content a:hover,
.navbar-sidebar-content a.active {
    background-color: rgba(0, 0, 0, 0.3);
    border-left-color: var(--white);
}

.navbar-sidebar-divider {
    height: 1px;
    background-color: rgba(255, 255, 255, 0.2);
    margin: 0.5rem 1rem;
}

/* Mobile overlay */
.navbar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
}

.navbar-overlay.active {
    display: block;
}

/* Authentication Pages */
.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.auth-box {
    background-color: var(--white);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.auth-header {
    background: linear-gradient(135deg, #475569 0%, #334155 100%);
    color: var(--white);
    padding: 2rem;
    text-align: center;
}

.auth-header .logo {
    height: 100px;
    margin-bottom: 1rem;
}

.auth-header h1 {
    font-size: 1.5rem;
    margin: 0;
    color: var(--white);
}

.auth-content {
    padding: 2rem;
}

.auth-content h2 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
}

.auth-links {
    text-align: center;
    margin-top: 1.5rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
    position: relative;
}

.password-wrapper {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.password-toggle:hover {
    color: var(--primary-color);
}

.password-toggle svg {
    width: 20px;
    height: 20px;
}

.password-wrapper input[type="password"],
.password-wrapper input[type="text"] {
    padding-right: 45px;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group input:disabled,
.form-group select:disabled,
.form-group textarea:disabled {
    background-color: #f3f4f6;
    color: #6b7280;
    cursor: not-allowed;
    border-color: #e5e7eb;
}

.form-group input[readonly],
.form-group textarea[readonly],
.field-with-history input[readonly],
.field-with-history textarea[readonly] {
    background-color: #f3f4f6;
    color: #6b7280;
    cursor: not-allowed;
    border-color: #e5e7eb;
}

/* Checkbox Label - proper alignment */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0 !important;
    font-weight: normal !important;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
    cursor: pointer;
}

.checkbox-label span {
    flex: 1;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    line-height: 1.5;
    box-sizing: border-box;
    vertical-align: middle;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--white);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    color: var(--white);
    text-decoration: none;
}

.btn-secondary {
    background-color: var(--gray);
    color: var(--white);
}

.btn-secondary:hover {
    background-color: var(--gray-dark);
    color: var(--white);
    text-decoration: none;
}

.btn-warning {
    background-color: var(--warning-color);
    color: var(--white);
}

.btn-warning:hover {
    background-color: #d97706;
}

.btn-danger {
    background-color: var(--error-color);
    color: var(--white);
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-block {
    display: block;
    width: 100%;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1.5rem;
}

.alert-success {
    background-color: #d1fae5;
    border: 1px solid #10b981;
    color: #065f46;
}

.alert-error {
    background-color: #fee2e2;
    border: 1px solid #ef4444;
    color: #991b1b;
}

.alert-warning {
    background-color: #fef3c7;
    border: 1px solid #f59e0b;
    color: #92400e;
}

/* Dashboard */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--white);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.stat-icon {
    font-size: 2.5rem;
    line-height: 1;
}

.stat-content {
    flex: 1;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-card-anfrage .stat-value {
    color: #1e3a8a;
}

.stat-card-reserviert .stat-value {
    color: #92400e;
}

.stat-card-bestellt .stat-value {
    color: #065f46;
}

.stat-card-geplant .stat-value {
    color: #3730a3;
}

/* Dashboard Charts */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.chart-card {
    background: var(--white);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.chart-card h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

.chart-container {
    position: relative;
    height: 300px;
}

/* Old dashboard styles (deprecated) */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.dashboard-card {
    background-color: var(--wrs-white);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.dashboard-card h3 {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.dashboard-stat {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--wrs-red);
}

/* Error Page */
.error-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: var(--wrs-gray-light);
}

.error-container {
    text-align: center;
    padding: 2rem;
}

.error-container h1 {
    font-size: 3rem;
    color: var(--wrs-red);
    margin-bottom: 1rem;
}

.error-container p {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .navbar {
        position: relative;
    }
    
    .navbar-burger {
        display: flex;
    }
    
    .navbar-menu,
    .navbar-user {
        display: none;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .chart-container {
        height: 250px;
    }
}

/* Logo styles */
.logo {
    width: auto;
}

.navbar .logo {
    max-height: 40px;
}

.auth-header .logo {
    height: 100px;
    max-height: 100px;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow-y: auto;
    padding: 2rem 1rem;
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.modal-content {
    background-color: var(--white);
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 600px;
    margin: auto;
}

.modal-large {
    max-width: 1000px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    gap: 1rem;
}

.modal-header h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.5rem;
    flex: 1;
}

.btn-reset-filters-icon {
    background: var(--gray-light);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    padding: 0;
    border-radius: 4px;
    font-size: 1.25rem;
    line-height: 1;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    align-self: flex-end;
    flex-shrink: 0;
}

.btn-reset-filters-icon:hover {
    background-color: var(--error-color);
    color: var(--white);
    border-color: var(--error-color);
}

.history-header-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
    opacity: 0.7;
}

.history-header-btn:hover {
    background-color: var(--gray-light);
    color: var(--primary-color);
    opacity: 1;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close:hover {
    background-color: var(--gray-light);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
    max-height: calc(100vh - 300px);
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--gray-light);
    border-radius: 0 0 8px 8px;
}

/* History modal footer should be right-aligned */
#history-modal .modal-footer {
    justify-content: flex-end;
}

.modal-footer .btn-group-right {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Form Sections */
.form-section {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.form-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.form-section h3 {
    color: var(--primary-color);
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent-color);
}

/* Form Grid */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-grid .form-group {
    margin-bottom: 0;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

/* Autocomplete Styles */
.autocomplete {
    position: relative;
}

.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--white);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: none;
}

.autocomplete-results.active {
    display: block;
}

.autocomplete-item {
    padding: 0.75rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.autocomplete-item:hover {
    background-color: var(--gray-light);
}

.autocomplete-item.active {
    background-color: var(--accent-light);
    color: var(--white);
}

/* Transport Unit Styles */
.transport-unit {
    background-color: #e5e7eb;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.transport-unit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.transport-unit-header h4 {
    color: var(--primary-color);
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

/* Cargo Items Section */
.cargo-items-section {
    background-color: #f9fafb;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.cargo-items-section h5 {
    color: var(--secondary-color);
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0 0 0.75rem 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.cargo-items-container {
    margin-bottom: 0.75rem;
}

.cargo-item {
    background-color: var(--white);
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
}

.cargo-item:last-child {
    margin-bottom: 0;
}

.cargo-item .form-grid {
    gap: 0.75rem;
}

.cargo-item .btn-danger {
    margin-bottom: 0;
    height: 38px;
    min-width: 38px;
    padding: 0.25rem 0.5rem;
}

.cargo-item .btn-danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-remove {
    background-color: var(--error-color);
    color: var(--white);
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-remove:hover {
    background-color: #dc2626;
}

/* Orders Toolbar */
.orders-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.orders-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: nowrap;
    width: auto;
}

.search-container {
    flex: 1;
    min-width: 200px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-group label {
    font-weight: 500;
    color: var(--text-primary);
}

.filter-group select {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    line-height: 1.5;
    box-sizing: border-box;
    background-color: var(--white);
    height: 48px;
}

/* Search Container */
.search-container {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
}

.search-input {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    line-height: 1.5;
    background-color: var(--white);
    transition: border-color 0.2s;
    height: 48px;
    box-sizing: border-box;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.search-clear {
    position: absolute;
    right: 0.5rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.search-clear:hover {
    background-color: var(--gray-light);
    color: var(--text-primary);
}

/* Sortable Table Headers */
.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-left: 2rem !important;
}

.sortable:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.sort-indicator {
    position: absolute;
    left: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    flex-direction: column;
    gap: 1px;
    line-height: 0.6;
    font-size: 0.65rem;
}

.sort-indicator::before,
.sort-indicator::after {
    color: #000000;
}

.sort-indicator::before {
    content: '▲';
}

.sort-indicator::after {
    content: '▼';
}

.sortable.sort-asc .sort-indicator::before {
    color: #ffffff;
}

.sortable.sort-asc .sort-indicator::after {
    color: #000000;
}

.sortable.sort-desc .sort-indicator::before {
    color: #000000;
}

.sortable.sort-desc .sort-indicator::after {
    color: #ffffff;
}

/* Data Table Styles */
.table-container {
    width: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: auto;
    margin: 0;
    border-collapse: collapse;
    background-color: var(--white);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    table-layout: auto;
}

.data-table thead {
    background-color: var(--primary-color);
    color: var(--white);
}

.data-table th,
.data-table td {
    padding: 1rem;
    text-align: left;
    vertical-align: middle;
}

.data-table th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.875rem;
    letter-spacing: 0.05em;
    white-space: normal;
}

.data-table td {
    white-space: nowrap;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s;
}

.data-table tbody tr:hover {
    background-color: var(--gray-light);
    cursor: pointer;
}

.data-table tbody tr:last-child {
    border-bottom: none;
}

.data-table td.loading {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}

/* Two-line table cells */
.two-line-row td {
    padding: 0.75rem 1rem;
}

.cell-main {
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.4;
}

.cell-sub {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-top: 0.25rem;
}

.cell-primary {
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.4;
}

.cell-secondary {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-top: 0.25rem;
}

.cell-centered {
    vertical-align: middle;
    text-align: center;
}

.cell-centered input[type="checkbox"] {
    margin-right: 0.5rem;
    transform: scale(1.3);
    cursor: pointer;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    margin: 0 0 0 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.btn-icon:hover {
    background-color: var(--gray-light);
}

/* Responsive Modal */
@media (max-width: 1024px) {
    .form-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    body {
        overflow-x: hidden;
    }
    
    .container {
        padding: 10px;
        --container-padding: 10px;
        overflow-x: hidden;
    }
    
    .modal {
        padding: 0;
    }
    
    .modal-content {
        border-radius: 0;
        max-width: 100%;
        min-height: 100vh;
        max-height: 100vh;
        display: flex;
        flex-direction: column;
    }
    
    .modal-body {
        flex: 1;
        overflow-y: auto;
        max-height: none;
        padding: 1rem;
    }
    
    .modal-large {
        max-width: 100%;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .orders-wrapper {
        width: 100%;
        overflow: visible;
        align-items: stretch;
        display: flex;
        flex-direction: column;
    }
    
    .orders-toolbar {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 0.75rem;
        margin-left: 0;
        margin-right: 0;
        padding: 0;
    }
    
    .orders-toolbar > * {
        width: 100%;
        margin: 0;
        max-width: 100%;
    }
    
    .orders-toolbar .btn {
        width: 100%;
        margin: 0;
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .table-container {
        width: 100vw;
        margin-left: calc(-1 * var(--container-padding, 10px));
        padding-left: var(--container-padding, 10px);
        padding-right: var(--container-padding, 10px);
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box;
    }
    
    .search-container {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        margin: 0;
        padding: 0;
    }
    
    .search-input {
        width: 100%;
        margin: 0;
    }
    
    .filter-group {
        width: 100%;
        max-width: 100%;
        display: flex;
        gap: 0.5rem;
        margin: 0;
    }
    
    .filter-group label {
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    .filter-group select {
        flex: 1;
        min-width: 0;
    }
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-anfrage {
    background-color: #dbeafe;
    color: #1e3a8a;
}

.status-vorreserviert {
    background-color: #fef3c7;
    color: #78350f;
}

.status-reserviert {
    background-color: #fed7aa;
    color: #92400e;
}

.status-bestellt {
    background-color: #d1fae5;
    color: #065f46;
}

.status-geplant {
    background-color: #e0e7ff;
    color: #3730a3;
}

.status-abgeschlossen {
    background-color: #f3f4f6;
    color: #374151;
}

.status-storniert {
    background-color: #fee2e2;
    color: #991b1b;
}

.status-unknown {
    background-color: var(--gray-light);
    color: var(--text-secondary);
}

/* Utility Classes */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

/* Calendar Styles */
.calendar-filters {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.month-navigation {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.month-navigation button {
    padding: 0.75rem;
    min-width: auto;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.current-month {
    min-width: 180px;
}

.current-month input[type="month"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    background-color: var(--white);
    box-sizing: border-box;
    height: 48px;
    line-height: 1.5;
}

/* Calendar Orders List */
.orders-list {
    min-height: 300px;
}

.calendar-date-group {
    margin-bottom: 2rem;
}

.calendar-date-header {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--gray-border);
}

.calendar-orders-table {
    background: var(--white);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.orders-table {
    width: 100%;
    border-collapse: collapse;
}

.orders-table thead {
    background: var(--gray-light);
}

.orders-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--gray-border);
}

.orders-table tbody tr {
    border-bottom: 1px solid var(--gray-border);
    cursor: pointer;
    transition: background-color 0.15s;
}

.orders-table tbody tr:hover {
    background-color: var(--gray-light);
}

.orders-table tbody tr:last-child {
    border-bottom: none;
}

.orders-table td {
    padding: 1rem;
    vertical-align: middle;
}

.order-time {
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.order-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
}

.order-status-indicator {
    width: 4px;
    height: 32px;
    border-radius: 2px;
    flex-shrink: 0;
}

.order-customer {
    color: var(--text-primary);
}

.order-route {
    color: var(--text-primary);
    font-family: monospace;
}

.order-units {
    text-align: center;
    font-weight: 500;
}

.order-status {
    text-align: center;
}

.order-status-badge {
    padding: 0.375rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    text-transform: uppercase;
    display: inline-block;
    white-space: nowrap;
}

.empty-state {
    background: var(--white);
    padding: 3rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    text-align: center;
    color: var(--text-secondary);
}

.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.status-legend {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-top: 1.5rem;
}

.status-legend h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    display: inline-block;
}

/* Responsive Calendar */
@media (max-width: 768px) {
    .calendar-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .month-navigation {
        width: 100%;
    }
    
    .current-month {
        flex: 1;
        min-width: auto;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .filter-group select {
        flex: 1;
    }
    
    /* Make table scrollable on mobile */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .data-table {
        min-width: 600px;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.5rem;
        font-size: 0.875rem;
        white-space: nowrap;
    }
    
    .calendar-orders-table {
        overflow-x: auto;
    }
    
    .orders-table {
        min-width: 600px;
    }
    
    .orders-table th,
    .orders-table td {
        padding: 0.5rem;
        font-size: 0.875rem;
    }
    
    .order-status-indicator {
        height: 24px;
    }
    
    /* History modal mobile optimization */
    .history-controls {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .history-controls .search-container {
        width: 100%;
    }
    
    .history-controls .filter-group {
        width: 100%;
        flex-direction: row;
        align-items: center;
    }
    
    .history-controls .filter-group label {
        font-size: 0.75rem;
        flex-shrink: 0;
    }
    
    .history-controls .filter-group select {
        flex: 1;
    }
    
    .history-stats {
        font-size: 0.875rem;
    }
    
    /* Prevent double scrollbars - table-container handles scrolling */
    .modal-body {
        overflow-y: visible;
        overflow-x: hidden;
    }
    
    /* History table in modal */
    .history-table {
        min-width: 700px;
        font-size: 0.75rem;
    }
    
    .history-table th,
    .history-table td {
        padding: 0.5rem 0.25rem;
    }
}

/* Message Styles */
.message {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.message-info {
    background-color: #dbeafe;
    color: #1e40af;
    border-left: 4px solid #3b82f6;
}

.message-error {
    background-color: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

.message-success {
    background-color: #d1fae5;
    color: #065f46;
    border-left: 4px solid #10b981;
}

.message button {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
}

.message button:hover {
    opacity: 1;
}

/* Hide admin-only elements from non-admin users */
.admin-only {
    display: none !important;
}

/* Show admin-only elements when body has admin class */
body.is-admin .admin-only,
body.is-superadmin .admin-only {
    display: block !important;
}

/* For inline elements like links */
body.is-admin a.admin-only,
body.is-superadmin a.admin-only {
    display: flex !important;
}

/* Hide edit/action elements for readonly users */
body.is-readonly .readonly-hide {
    display: none !important;
}

/* Disable inputs for readonly users */
body.is-readonly input:not([type="search"]),
body.is-readonly select,
body.is-readonly textarea,
body.is-readonly button.btn-primary,
body.is-readonly button[type="submit"] {
    pointer-events: none;
    opacity: 0.5;
    cursor: not-allowed;
}

/* Keep search and close buttons functional for readonly */
body.is-readonly input[type="search"],
body.is-readonly #month-filter,
body.is-readonly .btn-secondary,
body.is-readonly .close {
    pointer-events: auto;
    opacity: 1;
    cursor: pointer;
}

/* History / Audit Log Styles */
.field-with-history {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    width: 100%;
}

.field-with-history input,
.field-with-history select,
.field-with-history textarea {
    flex: 1;
}

.history-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.25rem 0.5rem;
    opacity: 0.6;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.history-btn:hover {
    opacity: 1;
}

.history-tooltip {
    position: fixed;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 1rem;
    z-index: 10001;
    max-width: 500px;
    min-width: 300px;
    pointer-events: auto;
}

.history-tooltip-header {
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-tooltip-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: all 0.2s;
}

.history-tooltip-close:hover {
    background-color: var(--gray-light);
    color: var(--danger);
}

.history-tooltip-table {
    width: 100%;
    font-size: 0.875rem;
}

.history-tooltip-table th,
.history-tooltip-table td {
    padding: 0.5rem;
    text-align: left;
}

.history-tooltip-table th {
    font-weight: 600;
    background-color: var(--gray-light);
}

.history-tooltip-footer {
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.history-tooltip-footer:hover {
    background-color: var(--gray-light);
    color: var(--primary);
    border-radius: 3px;
}

.history-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.history-controls .search-container {
    flex: 1;
    min-width: 200px;
    position: relative;
}

.history-controls .search-container input {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    line-height: 1.5;
    height: 48px;
    box-sizing: border-box;
}

.history-controls .search-clear {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
}

.history-controls .filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.history-controls .filter-group label {
    white-space: nowrap;
    font-size: 0.875rem;
}

.history-stats {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.history-table {
    width: 100%;
    font-size: 0.875rem;
}

.history-table th,
.history-table td {
    white-space: nowrap;
}

.history-table td:nth-child(6),
.history-table td:nth-child(7) {
    white-space: normal;
    max-width: 200px;
    word-wrap: break-word;
}

.old-value {
    color: var(--error-color);
}

.new-value {
    color: var(--success-color);
    font-weight: 500;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 3px;
    text-transform: uppercase;
}

.badge-success {
    background-color: #d1fae5;
    color: #065f46;
}

.badge-info {
    background-color: #dbeafe;
    color: #1e40af;
}

.badge-danger {
    background-color: #fee2e2;
    color: #991b1b;
}


