/**
 * PraxisCloud - Stylesheet
 *
 * Modern, clean, mobile-first Design
 * Inspiriert von Stripe/Square
 */

/* ============================================================================
   FONT - Inter (4 Schnitte)
   ============================================================================ */
@font-face {
    font-family: 'Inter';
    src: url('fonts/inter-regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Inter';
    src: url('fonts/inter-medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Inter';
    src: url('fonts/inter-semibold.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Inter';
    src: url('fonts/inter-bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* ============================================================================
   CSS VARIABLES
   ============================================================================ */
:root {
    /* Hintergrund */
    --bg-page: #F5F6FA;
    --bg-card: #FFFFFF;
    --bg-sidebar: #053462;
    --bg-sidebar-hover: #0A478A;
    --bg-sidebar-active: #1565B8;

    /* Akzentfarbe - Praxis Blau */
    --primary: #0A478A;
    --primary-light: #1565B8;
    --primary-dark: #053462;
    --primary-bg: #E6F0F8;

    /* Status-Farben */
    --success: #22C55E;
    --success-bg: #DCFCE7;
    --warning: #F59E0B;
    --warning-bg: #FEF3C7;
    --danger: #EF4444;
    --danger-bg: #FEE2E2;
    --info: #3B82F6;
    --info-bg: #DBEAFE;

    /* Text */
    --text-primary: #1E293B;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;
    --text-inverse: #FFFFFF;

    /* Rahmen & Trenner */
    --border: #E2E8F0;
    --border-hover: #CBD5E1;
    --divider: #F1F5F9;

    /* Schatten */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 40px rgba(0,0,0,0.15);

    /* Abstände */
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --header-height: 64px;
    --bottom-nav-height: 65px;

    /* Übergänge */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
}

/* Dark Mode */
.dark {
    --bg-page: #0A1628;
    --bg-card: #0F2137;
    --bg-sidebar: #051525;
    --bg-sidebar-hover: #0A2540;
    --bg-sidebar-active: #0A478A;

    --text-primary: #E2E8F0;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;

    --border: #1A3A5C;
    --border-hover: #2A4A6C;
    --divider: #0F2137;

    --primary-bg: rgba(10, 71, 138, 0.25);
    --success-bg: rgba(34, 197, 94, 0.15);
    --warning-bg: rgba(245, 158, 11, 0.15);
    --danger-bg: rgba(239, 68, 68, 0.15);
}

/* ============================================================================
   RESET & BASE
   ============================================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-page);
    min-height: 100vh;
    overflow-x: hidden;
}

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

::-webkit-scrollbar-track {
    background: var(--bg-page);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-hover);
    border-radius: 4px;
    transition: background 0.2s ease;
}

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

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-hover) var(--bg-page);
}

/* Sidebar Scrollbar */
.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.4);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-light);
}

img {
    max-width: 100%;
    height: auto;
}

/* ============================================================================
   LAYOUT
   ============================================================================ */
.app-container {
    display: flex;
    min-height: 100vh;
}

.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition-normal);
}

.sidebar-collapsed .main-wrapper {
    margin-left: var(--sidebar-collapsed);
}

.main-content {
    flex: 1;
    padding: 24px;
    padding-top: calc(var(--header-height) + 24px);
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
}

/* ============================================================================
   SIDEBAR
   ============================================================================ */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: var(--text-inverse);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width var(--transition-normal), transform var(--transition-normal);
    overflow: hidden;
}

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

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    min-height: 70px;
}

.sidebar-logo-link {
    display: block;
    width: 100%;
}

.sidebar-logo-img {
    width: 100%;
    height: auto;
    filter: brightness(0) invert(1);
    transition: opacity var(--transition-fast);
}

.sidebar-collapsed .sidebar-logo-img {
    width: 40px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 0 12px;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-collapsed .nav-section-title {
    opacity: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    color: rgba(255,255,255,0.7);
    transition: all var(--transition-fast);
    margin-bottom: 4px;
    cursor: pointer;
    white-space: nowrap;
}

.nav-item:hover {
    background: var(--bg-sidebar-hover);
    color: white;
}

.nav-item.active {
    background: var(--bg-sidebar-active);
    color: white;
}

.nav-item .icon {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
}

.nav-item-text {
    flex: 1;
    transition: opacity var(--transition-fast);
}

.sidebar-collapsed .nav-item-text {
    opacity: 0;
    width: 0;
}

.nav-item-badge {
    background: var(--danger);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.sidebar-collapsed .nav-item-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    padding: 2px 6px;
    min-width: 16px;
}

/* Parent Nav Item (collapsible) */
.nav-parent {
    position: relative;
}

.nav-parent .nav-toggle {
    margin-left: auto;
    transition: transform var(--transition-fast);
    opacity: 0.6;
}

.nav-parent:hover .nav-toggle {
    opacity: 1;
}

.nav-parent.open .nav-toggle {
    transform: rotate(180deg);
    opacity: 1;
}

/* Submenu */
.nav-submenu {
    max-height: 0;
    overflow: hidden;
    padding-left: 20px;
    transition: max-height var(--transition-normal) ease-out;
}

.nav-submenu.open {
    max-height: 400px;
}

.nav-submenu .nav-item {
    padding: 10px 12px;
    font-size: 13px;
    margin-bottom: 2px;
}

.nav-submenu .nav-item .icon {
    width: 18px;
    height: 18px;
}

/* Collapsed sidebar - hide submenus */
.sidebar-collapsed .nav-submenu {
    display: none;
}

.sidebar-collapsed .nav-toggle {
    display: none;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.sidebar-user:hover {
    background: var(--bg-sidebar-hover);
}

.sidebar-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    overflow: hidden;
}

.sidebar-user-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.sidebar-collapsed .sidebar-user-info {
    display: none;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    position: absolute;
    right: -16px;
    top: 80px;
    width: 32px;
    height: 32px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 101;
    transition: all var(--transition-fast);
    color: var(--text-secondary);
}

.sidebar-toggle .icon {
    width: 16px;
    height: 16px;
    transition: transform var(--transition-fast);
}

.sidebar-toggle:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(10, 71, 138, 0.3);
}

.sidebar-collapsed .sidebar-toggle .icon {
    transform: rotate(180deg);
}

/* ============================================================================
   HEADER BAR
   ============================================================================ */
.header-bar {
    position: fixed;
    top: 0;
    right: 0;
    left: var(--sidebar-width);
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    z-index: 90;
    transition: left var(--transition-normal);
}

.sidebar-collapsed .header-bar {
    left: var(--sidebar-collapsed);
}

.header-left {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-burger {
    display: none;
    padding: 8px;
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.header-burger:hover {
    background: var(--bg-page);
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-title .icon {
    color: var(--primary);
    flex-shrink: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-btn {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    color: var(--text-secondary);
    background: transparent;
    border: none;
}

.header-btn:hover {
    background: var(--bg-page);
    color: var(--text-primary);
}

.header-btn .badge {
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 18px;
    height: 18px;
    background: var(--danger);
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

/* Search Box */
.header-search {
    position: relative;
    width: 280px;
    margin-right: 16px;
}

.header-search input {
    width: 100%;
    padding: 10px 16px 10px 42px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-page);
    font-family: inherit;
    font-size: 14px;
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.header-search input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.header-search .icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.header-search-shortcut {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-card);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

/* ============================================================================
   CARDS
   ============================================================================ */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-fast);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-body {
    padding: 24px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* KPI Card */
.kpi-card {
    padding: 24px;
}

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.kpi-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.kpi-icon.primary { background: var(--primary-bg); color: var(--primary); }
.kpi-icon.success { background: var(--success-bg); color: var(--success); }
.kpi-icon.warning { background: var(--warning-bg); color: var(--warning); }
.kpi-icon.danger { background: var(--danger-bg); color: var(--danger); }

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    margin-bottom: 8px;
}

.kpi-trend {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 500;
}

.kpi-trend.up { color: var(--success); }
.kpi-trend.down { color: var(--danger); }
.kpi-trend.neutral { color: var(--text-muted); }

/* ============================================================================
   BUTTONS
   ============================================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-light);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

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

.btn-success:hover:not(:disabled) {
    background: #16a34a;
}

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

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-page);
    color: var(--text-primary);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
}

.btn-icon.btn-sm {
    width: 32px;
    height: 32px;
}

/* ============================================================================
   FORMS
   ============================================================================ */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-label.required::after {
    content: ' *';
    color: var(--danger);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 15px;
    color: var(--text-primary);
    background: var(--bg-card);
    transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.form-input.error,
.form-select.error {
    border-color: var(--danger);
}

.form-input.error:focus {
    box-shadow: 0 0 0 3px var(--danger-bg);
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-error {
    font-size: 12px;
    color: var(--danger);
    margin-top: 4px;
}

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

/* Checkbox & Radio */
.form-check {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.form-check input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.form-check-label {
    font-size: 14px;
    color: var(--text-primary);
}

/* Input Group */
.input-group {
    display: flex;
}

.input-group .form-input {
    border-radius: 0;
}

.input-group .form-input:first-child {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.input-group .form-input:last-child {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.input-group-text {
    padding: 11px 14px;
    background: var(--bg-page);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 14px;
    white-space: nowrap;
}

/* ============================================================================
   TABLES
   ============================================================================ */
.table-container {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
}

.table-header {
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    gap: 16px;
    flex-wrap: wrap;
}

.table-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.table-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.table-search {
    position: relative;
}

.table-search input {
    padding: 8px 14px 8px 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 14px;
    width: 220px;
    background: var(--bg-page);
}

.table-search input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-card);
}

.table-search .icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 16px;
    height: 16px;
}

.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 14px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
    background: var(--bg-page);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: color var(--transition-fast);
}

th:hover {
    color: var(--primary);
}

th .sort-icon {
    margin-left: 4px;
    opacity: 0.3;
    vertical-align: middle;
}

th.sorted .sort-icon {
    opacity: 1;
    color: var(--primary);
}

th.no-sort {
    cursor: default;
}

th.no-sort:hover {
    color: var(--text-secondary);
}

td {
    padding: 14px 16px;
    font-size: 14px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--divider);
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: var(--primary-bg);
}

/* Numeric columns */
td.num, th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Table Footer */
.table-footer {
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 16px;
}

.table-info {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ============================================================================
   PAGINATION
   ============================================================================ */
.pagination {
    display: flex;
    gap: 4px;
    align-items: center;
}

.pagination-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.pagination-btn:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

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

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============================================================================
   BADGES
   ============================================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-success {
    background: var(--success-bg);
    color: #166534;
}

.badge-warning {
    background: var(--warning-bg);
    color: #92400E;
}

.badge-danger {
    background: var(--danger-bg);
    color: #991B1B;
}

.badge-info {
    background: var(--primary-bg);
    color: var(--primary);
}

.badge-neutral {
    background: var(--divider);
    color: var(--text-secondary);
}

.dark .badge-success { color: #4ade80; }
.dark .badge-warning { color: #fbbf24; }
.dark .badge-danger { color: #f87171; }

/* ============================================================================
   TOASTS
   ============================================================================ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-md);
    color: white;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    max-width: 380px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }
.toast-info { background: var(--info); }

.toast-close {
    margin-left: auto;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity var(--transition-fast);
}

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

@keyframes toastIn {
    from {
        transform: translateX(100px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.hiding {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
    to {
        transform: translateX(100px);
        opacity: 0;
    }
}

/* ============================================================================
   MODAL
   ============================================================================ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.modal.active .modal-backdrop {
    opacity: 1;
}

.modal-dialog {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.95) translateY(20px);
    opacity: 0;
    transition: all var(--transition-normal);
    z-index: 1;
}

.modal.active .modal-dialog {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.modal-dialog.modal-lg,
.modal-lg .modal-dialog { max-width: 700px; }

.modal-dialog.modal-xl,
.modal-xl .modal-dialog { max-width: 900px; }

.modal-dialog.modal-sm,
.modal-sm .modal-dialog { max-width: 400px; }

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 600;
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-page);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(90vh - 140px);
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Search Modal */
.modal-dialog.modal-search {
    max-width: 550px;
    max-height: 500px;
}

.search-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.search-modal-header svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-modal-header input {
    flex: 1;
    border: none;
    background: none;
    font-size: 16px;
    color: var(--text-primary);
    outline: none;
}

.search-modal-header input::placeholder {
    color: var(--text-muted);
}

.search-modal-header kbd {
    padding: 4px 8px;
    font-size: 11px;
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
}

.search-modal-results {
    padding: 12px 0;
    max-height: 400px;
    overflow-y: auto;
}

.search-section {
    padding: 0 8px;
    margin-bottom: 8px;
}

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

.search-section-title {
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.search-result {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    text-decoration: none;
    transition: background var(--transition-fast);
}

.search-result:hover {
    background: var(--bg-page);
}

.search-result svg {
    color: var(--text-secondary);
}

/* ============================================================================
   BOTTOM NAV (Mobile)
   ============================================================================ */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 8px 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

.bottom-nav-items {
    display: flex;
    justify-content: space-around;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 16px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
    transition: color var(--transition-fast);
}

.bottom-nav-item .icon {
    width: 24px;
    height: 24px;
}

.bottom-nav-item.active {
    color: var(--primary);
}

/* ============================================================================
   LOGIN PAGE
   ============================================================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--bg-sidebar) 0%, #252840 100%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

.login-header {
    padding: 40px 40px 30px;
    text-align: center;
}

.login-logo {
    text-align: center;
    margin: 0 auto 40px;
}

.login-logo-img {
    width: 200px;
    height: auto;
}

.login-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 15px;
}

.login-body {
    padding: 0 40px 40px;
}

.login-btn {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    margin-top: 10px;
}

.login-error {
    background: var(--danger-bg);
    color: var(--danger);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ============================================================================
   GRID SYSTEM
   ============================================================================ */
.grid {
    display: grid;
    gap: 24px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }
.col-span-4 { grid-column: span 4; }

/* ============================================================================
   UTILITIES
   ============================================================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

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

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }

.p-0 { padding: 0; }
.p-1 { padding: 8px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }

.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }

.hidden { display: none !important; }
.visible { visibility: visible; }
.invisible { visibility: hidden; }

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================================================
   SKELETON LOADING
   ============================================================================ */
.skeleton {
    background: linear-gradient(90deg, var(--divider) 25%, var(--bg-page) 50%, var(--divider) 75%);
    background-size: 200% 100%;
    animation: skeleton 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
}

.skeleton-title {
    height: 28px;
    width: 60%;
    margin-bottom: 16px;
}

.skeleton-box {
    height: 100px;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */
@media (max-width: 1200px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }

    .sidebar.open {
        transform: translateX(0);
    }

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

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 99;
        display: none;
    }

    .sidebar.open + .sidebar-overlay {
        display: block;
    }

    .main-wrapper {
        margin-left: 0;
    }

    .sidebar-collapsed .main-wrapper {
        margin-left: 0;
    }

    .header-bar {
        left: 0;
    }

    .sidebar-collapsed .header-bar {
        left: 0;
    }

    .header-burger {
        display: flex;
    }

    .sidebar-toggle {
        display: none;
    }

    .header-search {
        display: none;
    }

    .bottom-nav {
        display: block;
    }

    .main-content {
        padding-bottom: calc(var(--bottom-nav-height) + 24px);
    }
}

@media (max-width: 768px) {
    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .col-span-2,
    .col-span-3,
    .col-span-4 {
        grid-column: span 1;
    }

    .main-content {
        padding: 16px;
        padding-top: calc(var(--header-height) + 16px);
        padding-bottom: calc(var(--bottom-nav-height) + 16px);
    }

    .card-body {
        padding: 16px;
    }

    .kpi-value {
        font-size: 1.5rem;
    }

    .table-header {
        padding: 12px 16px;
    }

    th, td {
        padding: 10px 12px;
    }

    .page-title {
        font-size: 1.25rem;
    }

    .modal-dialog {
        margin: 10px;
        max-height: calc(100vh - 20px);
    }

    .login-header,
    .login-body {
        padding-left: 24px;
        padding-right: 24px;
    }
}

@media (max-width: 480px) {
    .grid-4 {
        grid-template-columns: 1fr;
    }

    .table-actions {
        width: 100%;
    }

    .table-search input {
        width: 100%;
    }

    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* Touch optimization */
@media (hover: none) {
    .btn {
        min-height: 44px;
    }

    .nav-item {
        min-height: 48px;
    }

    td {
        min-height: 48px;
    }

    .form-input,
    .form-select {
        font-size: 16px; /* Prevents iOS zoom */
        min-height: 48px;
    }
}

/* Journal - Artikel-Zelle */
.artikel-cell {
    max-width: 300px;
}

.artikel-liste {
    display: inline-block;
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

.artikel-cell .badge {
    margin-left: 6px;
    vertical-align: middle;
}

/* Print */
@media print {
    .sidebar,
    .header-bar,
    .bottom-nav,
    .btn,
    .toast-container {
        display: none !important;
    }

    .main-wrapper {
        margin-left: 0;
    }

    .main-content {
        padding: 0;
        padding-top: 0;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
