/*
 * FeWo-Recht — Apple-Style Minimalist Design
 * Light (default) + Dark Mode
 */

/* === Tokens === */
:root {
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    --sidebar-w: 260px;

    --accent: #007AFF;
    --accent-hover: #005ECB;
    --accent-soft: rgba(0,122,255,.08);
    --accent-ring: rgba(0,122,255,.25);

    --bg: #F5F5F7;
    --bg-card: #FFFFFF;
    --bg-card-hover: #FAFAFA;
    --bg-sidebar: #FBFBFD;
    --bg-input: #F0F0F2;
    --bg-input-focus: #FFFFFF;

    --border: #E5E5EA;
    --border-light: #F0F0F2;

    --text: #1D1D1F;
    --text-secondary: #86868B;
    --text-muted: #AEAEB2;
    --text-on-accent: #FFFFFF;

    --shadow-xs: 0 1px 2px rgba(0,0,0,.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,.08);
    --shadow-lg: 0 12px 40px rgba(0,0,0,.12);

    --radius: 10px;
    --radius-sm: 8px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --transition: .18s ease;

    --success: #34C759;
    --warning: #FF9500;
    --danger: #FF3B30;
    --info: #5AC8FA;
}

[data-theme="dark"] {
    --accent: #0A84FF;
    --accent-hover: #409CFF;
    --accent-soft: rgba(10,132,255,.12);
    --accent-ring: rgba(10,132,255,.35);

    --bg: #000000;
    --bg-card: #1C1C1E;
    --bg-card-hover: #2C2C2E;
    --bg-sidebar: #1C1C1E;
    --bg-input: #2C2C2E;
    --bg-input-focus: #3A3A3C;

    --border: #38383A;
    --border-light: #2C2C2E;

    --text: #F5F5F7;
    --text-secondary: #98989D;
    --text-muted: #636366;

    --shadow-xs: none;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,.4);
    --shadow-lg: 0 12px 40px rgba(0,0,0,.5);
}

*, *::before, *::after { box-sizing: border-box; }
body {
    font-family: var(--font); background: var(--bg); color: var(--text);
    margin: 0; line-height: 1.5; -webkit-font-smoothing: antialiased;
    transition: background var(--transition), color var(--transition);
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
h1,h2,h3,h4,h5,h6 { color: var(--text); font-weight: 600; letter-spacing: -.01em; }
::selection { background: var(--accent); color: #fff; }

/* === LOGIN === */
.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: var(--bg); padding: 20px;
}
.login-container { width: 100%; max-width: 400px; }
.login-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-xl); padding: 44px 36px 36px; box-shadow: var(--shadow-lg);
}
.login-header { text-align: center; margin-bottom: 32px; }
.login-logo { max-height: 64px; margin-bottom: 16px; }
.login-icon {
    width: 56px; height: 56px; border-radius: var(--radius-lg);
    background: var(--accent-soft); color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; margin: 0 auto 16px;
}
.login-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 2px; }
.login-subtitle { color: var(--text-secondary); font-size: .875rem; margin: 0; }
.login-form .form-label { font-weight: 500; font-size: .8rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .04em; }
.login-form .form-control {
    background: var(--bg-input); border: 1px solid var(--border); color: var(--text);
    border-radius: var(--radius-sm); font-size: .95rem; padding: 10px 14px; transition: all var(--transition);
}
.login-form .form-control:focus {
    background: var(--bg-input-focus); border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring); color: var(--text);
}
.login-form .form-control::placeholder { color: var(--text-muted); }
.login-form .btn { border-radius: var(--radius-sm); padding: 10px; font-weight: 600; font-size: .95rem; }
.login-footer { text-align: center; margin-top: 24px; color: var(--text-muted); font-size: .75rem; }
.login-footer p { margin-bottom: 2px; }

/* === SIDEBAR === */
.sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w);
    background: var(--bg-sidebar); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; z-index: 1040;
    transition: transform .25s ease, background var(--transition); overflow-y: auto; overflow-x: hidden;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 12px; }
.sidebar-logo { height: 32px; flex-shrink: 0; }
.sidebar-logo-icon {
    width: 34px; height: 34px; border-radius: var(--radius-sm);
    background: var(--accent-soft); color: var(--accent);
    display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0;
}
.sidebar-title { font-size: .9rem; font-weight: 700; color: var(--text); display: block; line-height: 1.2; }
.sidebar-subtitle { font-size: .7rem; color: var(--text-muted); display: block; }

.sidebar-search { padding: 0 16px 8px; }
.search-input-wrap { position: relative; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: .8rem; pointer-events: none; }
.search-input {
    width: 100%; background: var(--bg-input); border: 1px solid transparent;
    border-radius: var(--radius-sm); padding: 8px 12px 8px 32px; font-size: .8rem;
    color: var(--text); outline: none; transition: all var(--transition); font-family: var(--font);
}
.search-input:focus { background: var(--bg-input-focus); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.search-input::placeholder { color: var(--text-muted); }

.sidebar-nav { flex: 1; padding: 4px 12px; overflow-y: auto; }
.nav-section { margin-bottom: 16px; }
.nav-section-title { font-size: .65rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); padding: 0 8px; margin-bottom: 4px; display: block; }
.nav-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px;
    border-radius: var(--radius-sm); color: var(--text-secondary);
    font-size: .85rem; font-weight: 500; transition: all var(--transition); text-decoration: none;
}
.nav-item i { width: 20px; text-align: center; font-size: .85rem; flex-shrink: 0; }
.nav-item:hover { background: var(--accent-soft); color: var(--accent); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-badge { margin-left: auto; background: var(--bg-input); color: var(--text-secondary); font-size: .7rem; font-weight: 600; padding: 2px 8px; border-radius: 10px; min-width: 22px; text-align: center; }
.nav-badge.accent { background: var(--accent); color: var(--text-on-accent); }

.sidebar-footer { padding: 12px 16px 16px; border-top: 1px solid var(--border); margin-top: auto; }
.theme-toggle {
    display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px;
    border: none; border-radius: var(--radius-sm); background: var(--bg-input);
    color: var(--text-secondary); font-size: .8rem; font-weight: 500;
    cursor: pointer; transition: all var(--transition); font-family: var(--font); margin-bottom: 12px;
}
.theme-toggle:hover { background: var(--accent-soft); color: var(--accent); }
.sidebar-user { display: flex; align-items: center; gap: 10px; }
.user-avatar {
    width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: var(--text-on-accent);
    display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: .85rem; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { display: block; font-size: .8rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: block; font-size: .7rem; color: var(--text-muted); }
.user-actions { display: flex; gap: 4px; }
.user-actions a { width: 30px; height: 30px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; color: var(--text-muted); transition: all var(--transition); font-size: .8rem; }
.user-actions a:hover { background: var(--accent-soft); color: var(--accent); }

/* === MOBILE === */
.mobile-topbar {
    position: fixed; top: 0; left: 0; right: 0; height: 52px;
    background: var(--bg-card); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px; z-index: 1030; transition: background var(--transition);
}
.sidebar-toggle { background: none; border: none; color: var(--text); font-size: 1.1rem; padding: 6px; cursor: pointer; }
.mobile-brand { font-weight: 700; font-size: .95rem; color: var(--text); }
.mobile-notif { color: var(--text-secondary); font-size: 1rem; position: relative; }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); position: absolute; top: -2px; right: -2px; }
.sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 1035; opacity: 0; pointer-events: none; transition: opacity .25s ease; }
.sidebar-overlay.show { opacity: 1; pointer-events: auto; }

/* === MAIN === */
.main-content { margin-left: var(--sidebar-w); min-height: 100vh; transition: margin var(--transition); }
.content-wrapper { max-width: 1200px; margin: 0 auto; padding: 28px 32px; }
.content-wrapper.full-width { max-width: none; padding: 24px 28px; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .main-content { margin-left: 0; padding-top: 52px; }
    .content-wrapper { padding: 20px 16px; }
}

/* === CARDS === */
.card, .bg-card { background: var(--bg-card) !important; border: 1px solid var(--border) !important; border-radius: var(--radius-lg) !important; box-shadow: var(--shadow-xs); transition: all var(--transition); }
.card:hover { box-shadow: var(--shadow-sm); }
.card-header { background: transparent !important; border-bottom: 1px solid var(--border-light) !important; padding: 16px 20px; font-weight: 600; font-size: .9rem; }
.card-body { padding: 20px; }

/* === STAT CARDS === */
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; display: flex; align-items: center; gap: 16px; transition: all var(--transition); box-shadow: var(--shadow-xs); }
.stat-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.stat-icon { width: 44px; height: 44px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }
.bg-gold-soft, .bg-primary-soft { background: var(--accent-soft); color: var(--accent); }
.bg-danger-soft { background: rgba(255,59,48,.08); color: var(--danger); }
.bg-info-soft { background: rgba(90,200,250,.08); color: var(--info); }
.bg-success-soft { background: rgba(52,199,89,.08); color: var(--success); }
.bg-warning-soft { background: rgba(255,149,0,.08); color: var(--warning); }
.stat-info h3 { font-size: 1.6rem; font-weight: 700; margin: 0; line-height: 1; letter-spacing: -.02em; }
.stat-info p { font-size: .75rem; color: var(--text-secondary); margin: 4px 0 0; font-weight: 500; }

/* === APARTMENT & CATEGORY === */
.apartment-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; transition: all var(--transition); }
.apartment-card:hover { box-shadow: var(--shadow-sm); }
.apartment-header { font-weight: 600; color: var(--text); font-size: .9rem; }
.apartment-status { margin-top: 8px; }
.category-card { display: flex; align-items: center; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; gap: 10px; transition: all var(--transition); font-size: .85rem; color: var(--text); }
.category-card:hover { background: var(--accent-soft); border-color: var(--accent); }
.category-card-link { text-decoration: none; color: inherit; display: block; }
.category-card .badge { margin-left: auto; }

/* === BUTTONS === */
.btn-gold, .btn-primary { background: var(--accent) !important; border-color: var(--accent) !important; color: var(--text-on-accent) !important; font-weight: 600; border-radius: var(--radius-sm); transition: all var(--transition); }
.btn-gold:hover, .btn-primary:hover { background: var(--accent-hover) !important; border-color: var(--accent-hover) !important; }
.btn-outline-gold, .btn-outline-primary { border-color: var(--accent) !important; color: var(--accent) !important; background: transparent !important; font-weight: 600; border-radius: var(--radius-sm); transition: all var(--transition); }
.btn-outline-gold:hover, .btn-outline-primary:hover { background: var(--accent) !important; color: var(--text-on-accent) !important; }
.text-gold { color: var(--accent) !important; }
.border-gold { border-color: var(--accent) !important; }

/* === TABLES === */
.table { color: var(--text); border-color: var(--border); }
.table-dark { --bs-table-bg: var(--bg-card); --bs-table-border-color: var(--border); --bs-table-color: var(--text); --bs-table-hover-bg: var(--bg-card-hover); --bs-table-hover-color: var(--text); }
.table thead th { background: var(--bg-card-hover); color: var(--text-secondary); font-weight: 600; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--border); padding: 10px 16px; }
.table tbody td { padding: 12px 16px; vertical-align: middle; border-color: var(--border-light); }
.table-hover tbody tr:hover { background: var(--bg-card-hover); }
.dataTables_wrapper .dataTables_length, .dataTables_wrapper .dataTables_filter, .dataTables_wrapper .dataTables_info, .dataTables_wrapper .dataTables_paginate { color: var(--text-secondary) !important; font-size: .8rem; }
.dataTables_wrapper .dataTables_filter input, .dataTables_wrapper .dataTables_length select { background: var(--bg-input) !important; border: 1px solid var(--border) !important; color: var(--text) !important; border-radius: var(--radius-sm) !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button { color: var(--text-secondary) !important; background: transparent !important; border: 1px solid var(--border) !important; border-radius: var(--radius-sm) !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current { background: var(--accent) !important; color: #fff !important; border-color: var(--accent) !important; }

/* === FORMS === */
.form-control, .form-select { background: var(--bg-input); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm); transition: all var(--transition); font-size: .9rem; }
.form-control:focus, .form-select:focus { background: var(--bg-input-focus); border-color: var(--accent); color: var(--text); box-shadow: 0 0 0 3px var(--accent-ring); }
.form-control::placeholder { color: var(--text-muted); }
.form-label { font-weight: 500; font-size: .8rem; color: var(--text-secondary); margin-bottom: 6px; }
.input-group .btn { border-color: var(--border); }

/* === CHAT === */
.chat-preview { border-bottom: 1px solid var(--border-light); padding-bottom: 12px; }
.chat-message { display: flex; gap: 10px; margin-bottom: 16px; animation: fadeIn .3s ease; }
.chat-message.own { flex-direction: row-reverse; }
.chat-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: .8rem; flex-shrink: 0; }
.chat-bubble { background: var(--bg-card-hover); border: 1px solid var(--border-light); border-radius: 16px 16px 16px 4px; padding: 10px 14px; max-width: 75%; font-size: .88rem; line-height: 1.5; }
.chat-message.own .chat-bubble { background: var(--accent); color: var(--text-on-accent); border-color: transparent; border-radius: 16px 16px 4px 16px; }
.chat-timestamp { font-size: .7rem; color: var(--text-muted); align-self: flex-end; }

/* === TIMELINE === */
.timeline-item-mini { border-left: 2px solid var(--border); padding-left: 16px; position: relative; }
.timeline-item-mini::before { content: ''; width: 8px; height: 8px; background: var(--accent); border-radius: 50%; position: absolute; left: -5px; top: 6px; }
.timeline-date { min-width: 40px; }
.timeline-event { position: relative; padding-left: 40px; margin-bottom: 2rem; border-left: 2px solid var(--border); }
.timeline-dot { position: absolute; left: -8px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid; background: var(--bg); }
.dot-dokument { border-color: #007AFF; } .dot-frist { border-color: #FF3B30; } .dot-termin { border-color: #34C759; }
.dot-bescheid { border-color: #FF9500; } .dot-klage { border-color: #AF52DE; } .dot-sonstiges { border-color: #8E8E93; }

/* === MISC === */
.alert { border-radius: var(--radius-sm); border: none; font-size: .88rem; }
.badge { font-weight: 600; font-size: .7rem; padding: 3px 8px; border-radius: 20px; }
.list-group-item { background: transparent; border-color: var(--border-light); color: var(--text); transition: background var(--transition); }
.list-group-item:hover, .list-group-item-action:hover { background: var(--bg-card-hover); color: var(--text); }
.notification-unread { border-left: 3px solid var(--accent); background: var(--accent-soft); }
mark, .search-highlight { background: rgba(0,122,255,.15); color: var(--text); padding: 1px 4px; border-radius: 3px; }
.drag-area { border: 2px dashed var(--border); border-radius: var(--radius-lg); padding: 40px 20px; text-align: center; color: var(--text-secondary); transition: all var(--transition); cursor: pointer; }
.drag-area:hover { border-color: var(--accent); background: var(--accent-soft); }
.drag-area.dragover { border-color: var(--accent); background: var(--accent-soft); border-style: solid; }
.drag-area i { font-size: 2rem; margin-bottom: 8px; color: var(--text-muted); }
.file-preview { background: var(--bg-card-hover); border: 1px solid var(--border-light); padding: 8px 14px; border-radius: var(--radius-sm); margin-top: 8px; font-size: .82rem; }
.page-link { background: var(--bg-card); border-color: var(--border); color: var(--text); }
.page-link:hover { background: var(--accent-soft); color: var(--accent); }
.page-item.active .page-link { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-item.disabled .page-link { background: var(--bg-card-hover); color: var(--text-muted); }
.modal-content { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-xl); }
.modal-header { border-bottom-color: var(--border); }
.modal-footer { border-top-color: var(--border); }
[data-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }
code { background: var(--bg-input); color: var(--accent); padding: 2px 6px; border-radius: 4px; font-size: .82em; }
.dropdown-menu { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 4px; }
.dropdown-item { color: var(--text); border-radius: var(--radius-sm); padding: 7px 12px; font-size: .85rem; }
.dropdown-item:hover { background: var(--accent-soft); color: var(--accent); }
.dropdown-divider { border-color: var(--border); }

/* === CATEGORY TILES === */
.cat-tiles { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: thin; }
.cat-tile {
    flex: 0 0 auto; min-width: 160px; background: var(--bg-card); border: 2px solid var(--border);
    border-radius: var(--radius-lg); padding: 16px 18px; text-decoration: none; color: var(--text);
    display: flex; align-items: center; gap: 12px; transition: all var(--transition); cursor: pointer;
}
.cat-tile:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); color: var(--text); transform: translateY(-1px); }
.cat-tile.active { border-color: var(--accent); background: var(--accent-soft); }
.cat-tile-icon {
    width: 40px; height: 40px; border-radius: var(--radius); display: flex;
    align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0;
}
.cat-tile-info { min-width: 0; }
.cat-tile-name { font-weight: 600; font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.cat-tile-count { font-size: .7rem; color: var(--text-secondary); }

/* === PDF VIEWER === */
.pdf-viewer-wrap { position: relative; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.pdf-toolbar {
    display: flex; align-items: center; gap: 8px; padding: 8px 14px;
    background: var(--bg-card-hover); border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.pdf-toolbar .btn { padding: 5px 10px; font-size: .8rem; }
.pdf-toolbar .form-control { max-width: 50px; text-align: center; font-size: .8rem; padding: 4px 6px; }
.pdf-toolbar .page-info { font-size: .8rem; color: var(--text-secondary); white-space: nowrap; }
.pdf-toolbar .search-wrap { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.pdf-toolbar .search-wrap input { max-width: 200px; font-size: .8rem; padding: 4px 10px; }
.pdf-canvas-container { overflow: auto; background: #525659; text-align: center; padding: 10px 0; position: relative; }
[data-theme="dark"] .pdf-canvas-container { background: #1a1a1a; }
.pdf-canvas-container canvas { box-shadow: 0 2px 8px rgba(0,0,0,.3); display: inline-block; }

/* === DOCUMENT VIEW LAYOUT === */
.doc-view-grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; }
.doc-view-sidebar { position: sticky; top: 20px; align-self: start; }
@media (max-width: 1199.98px) { .doc-view-grid { grid-template-columns: 1fr; } .doc-view-sidebar { position: static; } }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
