/* Oikolog CRM - Custom Styles auf Pico CSS */

:root {
    --kw-primary: #1565C0;
    --kw-primary-light: #42A5F5;
    --kw-bg: #f8f9fa;
    --kw-card-bg: #fff;
    --kw-border: #dee2e6;
    --kw-text: #212529;
    --kw-text-muted: #6c757d;
    --kw-success: #2e7d32;
    --kw-warning: #ef6c00;
    --kw-danger: #c62828;
    --kw-radius: 8px;
    --kw-org-bg: #e3f2fd;
}

/* Layout */
body {
    background: var(--kw-bg);
    min-height: 100vh;
}

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
    width: 220px;
    background: var(--kw-primary);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 1.25rem 1rem;
    font-size: 1.05rem;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    text-decoration: none;
    color: white;
    display: block;
}

.sidebar-brand:hover {
    color: white;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0;
    margin: 0;
    flex: 1;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.15s;
}

.sidebar-link:hover,
.sidebar-link.active {
    background: rgba(255,255,255,0.15);
    color: white;
}

.sidebar-link .nav-icon {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.sidebar-section {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255,255,255,0.5);
    padding: 1rem 1rem 0.3rem;
    margin: 0;
}

.sidebar-user {
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(255,255,255,0.15);
    font-size: 0.85rem;
    color: rgba(255,255,255,0.7);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 220px;
    display: flex;
    flex-direction: column;
}

/* Top Bar */
.top-bar {
    background: var(--kw-card-bg);
    border-bottom: 1px solid var(--kw-border);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.search-box {
    position: relative;
    flex: 1;
    max-width: 500px;
}

.search-box input {
    margin: 0;
    padding: 0.5rem 1rem 0.5rem 2.25rem;
    border-radius: 20px;
    background: var(--kw-bg);
    border: 1px solid var(--kw-border);
    font-size: 0.9rem;
}

.search-box input:focus {
    border-color: var(--kw-primary-light);
    box-shadow: 0 0 0 2px rgba(21,101,192,0.15);
}

.search-box::before {
    content: "🔍";
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85rem;
    z-index: 1;
}

.search-kbd {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: var(--kw-text-muted);
    background: var(--kw-card-bg);
    border: 1px solid var(--kw-border);
    border-radius: 3px;
    padding: 0.1rem 0.4rem;
}

#search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--kw-card-bg);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-height: 400px;
    overflow-y: auto;
    z-index: 200;
    margin-top: 4px;
}

#search-dropdown:empty {
    display: none;
}

.search-result-item {
    display: block;
    padding: 0.6rem 1rem;
    text-decoration: none;
    color: var(--kw-text);
    border-bottom: 1px solid var(--kw-border);
    transition: background 0.1s;
}

.search-result-item:hover {
    background: var(--kw-bg);
    color: var(--kw-text);
}

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

.search-result-type {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--kw-text-muted);
    letter-spacing: 0.03em;
}

.search-result-title {
    font-weight: 600;
    font-size: 0.9rem;
}

.search-result-sub {
    font-size: 0.8rem;
    color: var(--kw-text-muted);
}

/* Page Content */
.page-content {
    padding: 1.5rem;
    flex: 1;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    margin: 0;
    color: var(--kw-text);
}

/* Cards */
.card {
    background: var(--kw-card-bg);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

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

.card-header h2, .card-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

/* KPI Grid (Dashboard) */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: var(--kw-card-bg);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius);
    padding: 1.25rem;
    text-align: center;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--kw-primary);
    line-height: 1;
}

.kpi-label {
    font-size: 0.85rem;
    color: var(--kw-text-muted);
    margin-top: 0.25rem;
}

/* Kontakt-Karte */
.kontakt-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius);
    background: var(--kw-card-bg);
    text-decoration: none;
    color: var(--kw-text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.kontakt-card:hover {
    border-color: var(--kw-primary-light);
    box-shadow: 0 2px 8px rgba(21,101,192,0.1);
    color: var(--kw-text);
}

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

.kontakt-avatar.org {
    border-radius: var(--kw-radius);
    background: #ef6c00;
}

.kontakt-info {
    flex: 1;
    min-width: 0;
}

.kontakt-name {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kontakt-detail {
    font-size: 0.8rem;
    color: var(--kw-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kontakt-tags {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

/* Tag Chips */
.tag-chip {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    font-size: 0.7rem;
    border-radius: 12px;
    background: #e3f2fd;
    color: #1565c0;
    white-space: nowrap;
}

.tag-chip.removable {
    cursor: pointer;
}

.tag-chip.removable:hover {
    background: #ffcdd2;
    color: #c62828;
}

/* Gruppen Badges */
.gruppe-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 3px;
    color: white;
}

/* Aktivitaet Timeline */
.timeline {
    position: relative;
    padding-left: 2rem;
}

.timeline::before {
    content: "";
    position: absolute;
    left: 0.75rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--kw-border);
}

.timeline-item {
    position: relative;
    padding-bottom: 1rem;
}

.timeline-item::before {
    content: "";
    position: absolute;
    left: -1.5rem;
    top: 0.4rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--kw-primary-light);
    border: 2px solid var(--kw-card-bg);
}

.timeline-date {
    font-size: 0.75rem;
    color: var(--kw-text-muted);
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-wrap: wrap;
}

.timeline-content {
    font-size: 0.9rem;
}

.timeline-art {
    font-size: 0.75rem;
    color: var(--kw-primary);
    font-weight: 600;
}

/* Alphabet-Filter */
.alpha-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    margin-bottom: 1rem;
}

.alpha-filter a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: 4px;
    color: var(--kw-text-muted);
    transition: all 0.1s;
}

.alpha-filter a:hover,
.alpha-filter a.active {
    background: var(--kw-primary);
    color: white;
}

/* Detail Page Layout */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 1.5rem;
}

.detail-main {
    min-width: 0;
}

.detail-sidebar {
    min-width: 0;
}

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

/* Info Grid */
.info-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.3rem 1rem;
    font-size: 0.9rem;
}

.info-label {
    color: var(--kw-text-muted);
    font-size: 0.8rem;
}

.info-value {
    word-break: break-word;
}

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem 1.5rem;
}

.form-grid .full-width {
    grid-column: 1 / -1;
}

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

/* Buttons */
.btn-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.btn-group > * {
    line-height: 1.2;
    box-sizing: border-box;
    height: 2rem;
    display: inline-flex;
    align-items: center;
}

button.btn-sm,
a.btn-sm,
.btn-sm {
    padding: 0.3rem 0.75rem !important;
    font-size: 0.8rem !important;
    width: auto !important;
    min-width: 0 !important;
    margin: 0 !important;
    justify-content: center;
    height: 2rem;
    line-height: 1.2;
    display: inline-flex;
    align-items: center;
    box-sizing: border-box;
}

.btn-icon {
    padding: 0.3rem 0.5rem;
    font-size: 1rem;
    background: none;
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius);
    cursor: pointer;
    color: var(--kw-text-muted);
    display: inline-block;
    width: auto;
}

.btn-icon:hover {
    background: var(--kw-bg);
    color: var(--kw-text);
}

/* Tabelle */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--kw-text-muted);
    border-bottom: 2px solid var(--kw-border);
    font-weight: 600;
}

.data-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--kw-border);
}

.data-table tr:hover {
    background: var(--kw-bg);
}

/* Kompakte Filter-Zeile in Tabellenköpfen */
.tbl-filter-row {
    background: #eef1f5 !important;
    --pico-form-element-spacing-vertical: 0.07rem;
    --pico-form-element-spacing-horizontal: 0.22rem;
    --pico-font-size: 0.72rem;
    --pico-border-radius: 3px;
}
.tbl-filter-row td {
    padding: 0.15rem 0.35rem !important;
    vertical-align: top !important;
}
.tbl-filter-row input,
.tbl-filter-row select {
    font-size: 0.72rem !important;
    margin: 0 !important;
    height: auto !important;
    min-height: unset !important;
    line-height: 1.3 !important;
    width: 100%;
    box-sizing: border-box;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.75rem 1.25rem;
    border-radius: var(--kw-radius);
    background: #323232;
    color: white;
    font-size: 0.9rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    animation: slideIn 0.3s ease;
}

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

.toast-fade {
    opacity: 0;
    transition: opacity 0.3s;
}

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

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 1.5rem;
}

.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 0.5rem;
    font-size: 0.85rem;
    text-decoration: none;
    border: 1px solid var(--kw-border);
    border-radius: 4px;
    color: var(--kw-text);
}

.pagination a:hover {
    background: var(--kw-bg);
    color: var(--kw-text);
}

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

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--kw-text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Filter Bar */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: var(--kw-card-bg);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius);
}

.filter-bar select, .filter-bar input {
    margin: 0;
    font-size: 0.85rem;
    padding: 0.35rem 0.5rem;
}

/* Responsive Sidebar */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }

    .sidebar-brand span, .sidebar-link span:not(.nav-icon),
    .sidebar-section, .sidebar-user span {
        display: none;
    }

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

    .main-content {
        margin-left: 60px;
    }
}

/* Searchable Dropdown */
.search-dropdown {
    position: relative;
    margin-top: 0.5rem;
}

.search-dropdown-toggle {
    width: 100%;
    text-align: left;
    font-size: 0.85rem;
    padding: 0.3rem 0.5rem;
    margin: 0;
    background: var(--kw-card-bg);
    border: 1px solid var(--kw-border);
    border-radius: 4px;
    cursor: pointer;
    color: var(--kw-text-muted);
}

.search-dropdown-toggle:hover {
    border-color: var(--kw-primary-light);
}

.search-dropdown-menu {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    background: var(--kw-card-bg);
    border: 1px solid var(--kw-border);
    border-radius: var(--kw-radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 200;
    max-height: 280px;
    overflow-y: auto;
    margin-top: 2px;
}

.search-dropdown-menu.open {
    display: block;
}

.search-dropdown-menu input[type="text"] {
    width: 100%;
    margin: 0;
    padding: 0.4rem 0.5rem;
    font-size: 0.85rem;
    border: none;
    border-bottom: 1px solid var(--kw-border);
    border-radius: 0;
    outline: none;
    box-sizing: border-box;
}

.search-dropdown-menu input[type="text"]:focus {
    box-shadow: none;
    border-bottom-color: var(--kw-primary-light);
}

.search-dropdown-group {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--kw-text-muted);
    padding: 0.4rem 0.5rem 0.2rem;
    font-weight: 600;
}

.search-dropdown-item {
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.1s;
}

.search-dropdown-item:hover {
    background: var(--kw-bg);
    color: var(--kw-primary);
}

/* File Upload Button (label als Outline-Button) */
.file-upload-btn {
    display: inline-flex;
    align-items: center;
    height: 2rem;
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
    cursor: pointer;
    border: 1px solid var(--kw-primary);
    border-radius: var(--kw-radius);
    color: var(--kw-primary);
    background: transparent;
    box-sizing: border-box;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}
.file-upload-btn:hover {
    background: var(--kw-primary);
    color: white;
}

/* Print */
@media print {
    .sidebar, .top-bar, .no-print {
        display: none !important;
    }
    .main-content {
        margin-left: 0;
    }
}
