/* FaxNode – NorthNode Design System */
:root {
    --bg-dark: #0a0e14;
    --bg-elevated: #111820;
    --bg-hover: #1a2230;
    --border: #1e2a3a;
    --accent: #39d353;
    --accent-dim: rgba(57, 211, 83, 0.15);
    --text: #e6edf3;
    --text-muted: #7d8590;
    --danger: #f85149;
    --warning: #d29922;
    --info: #58a6ff;
    --font-sans: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --radius: 8px;
    --transition: all 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-sans);
    background: var(--bg-dark);
    color: var(--text);
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
}

a { color: var(--accent); text-decoration: none; }

.mono-sm { font-family: var(--font-mono); font-size: 0.8125rem; }
.text-muted { color: var(--text-muted); }

/* Layout */
.app {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 220px;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-logo {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon { font-size: 1.5rem; }

.logo-text {
    font-weight: 700;
    font-size: 1.125rem;
    letter-spacing: -0.02em;
}

.sidebar-nav {
    padding: 0.75rem 0.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius);
    color: var(--text-muted);
    transition: var(--transition);
    font-size: 0.9375rem;
}

.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }
.nav-icon { font-size: 1.125rem; width: 1.25rem; text-align: center; }

.nav-badge {
    margin-left: auto;
    background: var(--accent);
    color: var(--bg-dark);
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: 10px;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
}

/* Content */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.page-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Search */
.search-form {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
    align-items: center;
}

.search-input {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 0.5rem 0.75rem;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    width: 280px;
    outline: none;
    transition: var(--transition);
}

.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-muted); }

/* Buttons */
.btn {
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--accent);
    background: var(--accent);
    color: var(--bg-dark);
    cursor: pointer;
    transition: var(--transition);
}

.btn:hover { opacity: 0.9; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-dim); }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: rgba(248, 81, 73, 0.15); }

/* Status Tabs */
.status-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}

.tab {
    padding: 0.625rem 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: var(--transition);
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-count { font-size: 0.75rem; opacity: 0.7; }

/* Fax List */
.fax-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.fax-card {
    display: block;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    transition: var(--transition);
    color: var(--text);
}

.fax-card:hover {
    border-color: var(--accent);
    transform: translateX(4px);
}

.fax-card.archived { opacity: 0.7; }

.fax-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.fax-sender {
    font-weight: 600;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.fax-card-meta {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.375rem;
}

.fax-card-preview {
    font-size: 0.8125rem;
    line-height: 1.4;
    margin-top: 0.375rem;
}

/* Badges */
.badge {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 500;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-neu { background: rgba(88, 166, 255, 0.15); color: var(--info); }
.badge-gelesen { background: rgba(210, 153, 34, 0.15); color: var(--warning); }
.badge-bearbeitet { background: var(--accent-dim); color: var(--accent); }
.badge-erledigt { background: rgba(125, 133, 144, 0.15); color: var(--text-muted); }

/* Category Badges */
.cat-badge {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 500;
    padding: 0.1875rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
    white-space: nowrap;
}
.cat-rezept { background: rgba(210, 118, 255, 0.15); color: #d276ff; }
.cat-bestellung { background: rgba(88, 166, 255, 0.15); color: var(--info); }
.cat-lieferschein { background: var(--accent-dim); color: var(--accent); }
.cat-rueckruf { background: rgba(248, 81, 73, 0.2); color: var(--danger); }
.cat-sonstiges { background: rgba(125, 133, 144, 0.15); color: var(--text-muted); }

/* Category Filter Tabs */
.category-tabs {
    display: flex;
    gap: 0.375rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}
.cat-tab {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 0.3rem 0.625rem;
    border-radius: 4px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-muted);
    transition: var(--transition);
}
.cat-tab:hover { border-color: var(--text-muted); color: var(--text); }
.cat-tab.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

/* Fax Card Row (with thumbnail) */
.fax-card-row {
    display: grid;
    grid-template-columns: 56px 1fr;
    grid-template-rows: auto auto;
    gap: 0 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.875rem 1.125rem;
    transition: var(--transition);
}
.fax-card-row:hover { border-color: var(--accent); }

.fax-card-thumb {
    grid-row: 1 / 3;
    width: 56px;
    display: flex;
    align-items: flex-start;
    padding-top: 0.125rem;
}
.fax-card-thumb img {
    width: 56px;
    height: auto;
    border-radius: 4px;
    border: 1px solid var(--border);
}
.thumb-placeholder {
    width: 56px;
    height: 74px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    color: var(--text-muted);
}

.fax-card-content {
    grid-column: 2;
    min-width: 0;
    color: var(--text);
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.fax-card-badges { display: flex; gap: 0.375rem; align-items: center; }

.fax-card-actions {
    grid-column: 2;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-top: 0.5rem;
    margin-top: 0.375rem;
    border-top: 1px solid var(--border);
}
.fax-card-actions .status-btns { flex-wrap: nowrap; }

/* Detail Layout */
.detail-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1.5rem;
    height: calc(100vh - 140px);
}

.detail-pdf {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.detail-pdf object { display: block; height: 100%; }

.detail-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
}

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

.card h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--accent);
}

/* Meta Rows */
.meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.meta-row:last-child { border-bottom: none; }
.meta-label { color: var(--text-muted); font-size: 0.8125rem; }

/* Status Select (legacy) */
.status-select {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    padding: 0.3rem 0.5rem;
    cursor: pointer;
    outline: none;
}

/* Status Buttons */
.status-btns {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}
.status-btn {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 500;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    border: 1px solid transparent;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all 0.15s ease;
    background: rgba(125, 133, 144, 0.08);
    color: var(--text-muted);
}
.status-btn:hover { opacity: 0.85; }
.status-btn.active, .status-btn[data-status="neu"].active { background: rgba(88, 166, 255, 0.15); color: var(--info); border-color: rgba(88, 166, 255, 0.3); }
.status-btn[data-status="gelesen"].active { background: rgba(210, 153, 34, 0.15); color: var(--warning); border-color: rgba(210, 153, 34, 0.3); }
.status-btn[data-status="bearbeitet"].active { background: var(--accent-dim); color: var(--accent); border-color: rgba(57, 211, 83, 0.3); }
.status-btn[data-status="erledigt"].active { background: rgba(125, 133, 144, 0.15); color: var(--text-muted); border-color: rgba(125, 133, 144, 0.3); }
/* Compact variant for list view */
.status-btns-sm .status-btn { font-size: 0.6875rem; padding: 0.1875rem 0.4rem; }

/* Print Indicator */
.print-indicator {
    font-size: 0.875rem;
    color: var(--accent);
    opacity: 0.85;
    flex-shrink: 0;
}

/* Action Button Row (Drucken/Archivieren nebeneinander) */
.fax-action-btns {
    display: flex;
    gap: 0.375rem;
    margin-left: auto;
}
.fax-action-btns .btn {
    font-size: 0.75rem;
}

/* Archived card row */
.fax-card-row.archived { opacity: 0.7; }
.fax-card-row.archived:hover { opacity: 1; }

/* OCR Text */
.ocr-text {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 200px;
    overflow-y: auto;
    line-height: 1.5;
}

/* Notes */
.note {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.note:last-child { border-bottom: none; }

.note-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}

.note-author { font-weight: 600; font-size: 0.875rem; }
.note-date { color: var(--text-muted); }
.note-message { font-size: 0.875rem; color: var(--text-muted); }

.note-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.note-author-input,
.note-input {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 0.5rem 0.75rem;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    outline: none;
    resize: vertical;
}

.note-author-input:focus,
.note-input:focus { border-color: var(--accent); }

/* Tables */
.table-container { overflow-x: auto; }

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

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

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

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

/* Forms */
.form-card { margin-bottom: 1.5rem; }

.form-row {
    margin-bottom: 1rem;
}

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

.form-row input,
.form-row select,
.form-row textarea {
    width: 100%;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 0.5rem 0.75rem;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    outline: none;
}

.form-row input:focus,
.form-row select:focus { border-color: var(--accent); }

.form-actions { display: flex; gap: 0.5rem; }

/* Settings */
.settings-section { margin-bottom: 1.5rem; }
.settings-section p { margin-bottom: 1rem; }
.settings-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }

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

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1.5rem 0;
}
.pagination-info {
    color: var(--text-muted);
}

/* Load More / Infinite Scroll */
.load-more {
    display: flex;
    justify-content: center;
    padding: 1.5rem 0;
}
.load-spinner {
    display: flex;
    justify-content: center;
    padding: 1.5rem 0;
}
.spinner-bar {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

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

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    min-width: 280px;
    animation: slideIn 0.3s ease;
    cursor: pointer;
}

.toast-title { font-weight: 600; font-size: 0.875rem; }
.toast-body { font-size: 0.8125rem; color: var(--text-muted); margin-top: 0.25rem; }

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

/* Statistics */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card { text-align: center; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.8125rem; color: var(--text-muted); margin-top: 0.25rem; }

.stats-sections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 1.5rem;
}

.bar-chart { display: flex; flex-direction: column; gap: 0.5rem; }
.bar-row { display: flex; align-items: center; gap: 0.75rem; }
.bar-label { width: 80px; text-align: right; flex-shrink: 0; }
.bar-track { flex: 1; height: 20px; background: var(--bg-dark); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 3px; min-width: 2px; transition: width 0.3s ease; }
.bar-fill-rezept { background: #d276ff; }
.bar-fill-bestellung { background: var(--info); }
.bar-fill-lieferschein { background: var(--accent); }
.bar-fill-rueckruf { background: var(--danger); }
.bar-fill-sonstiges { background: var(--text-muted); }
.bar-value { width: 30px; flex-shrink: 0; }

/* Responsive */
@media (max-width: 1024px) {
    .detail-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    .detail-pdf { height: 50vh; }
}

@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar .logo-text,
    .sidebar .nav-item span:not(.nav-icon),
    .sidebar .nav-badge,
    .sidebar-footer { display: none; }
    .sidebar-logo { justify-content: center; padding: 1rem 0.5rem; }
    .nav-item { justify-content: center; padding: 0.75rem; }

    .content { padding: 1rem; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .page-header h1 { font-size: 1.25rem; }
    .search-form { margin-left: 0; width: 100%; }
    .search-input { width: 100%; flex: 1; }

    /* Fax-Karten: kompakter */
    .fax-card-row { padding: 0.625rem 0.75rem; }
    .fax-card-actions { flex-wrap: wrap; }

    /* Status/Category-Tabs: horizontal scrollbar */
    .status-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .status-tabs::-webkit-scrollbar { display: none; }
    .category-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
    .category-tabs::-webkit-scrollbar { display: none; }

    /* Buttons: groessere Touch-Targets */
    .btn-sm { padding: 0.5rem 0.875rem; }
    .status-btn { padding: 0.25rem 0.5rem; }

    /* Detail: Meta-Rows wrappen */
    .meta-row { flex-wrap: wrap; gap: 0.25rem; }
}

@media (max-width: 480px) {
    .content { padding: 0.75rem; }
    .fax-card-row { grid-template-columns: 44px 1fr; gap: 0 0.625rem; padding: 0.625rem; }
    .fax-card-thumb { width: 44px; }
    .fax-card-thumb img { width: 44px; }
    .thumb-placeholder { width: 44px; height: 58px; }
    .fax-sender { font-size: 0.9rem; }
    .fax-card-preview { display: none; }
    .fax-card-actions { gap: 0.5rem; }
    .settings-row { flex-wrap: wrap; gap: 0.5rem; }
    .detail-sidebar { min-width: 0; }
    .toast { min-width: 220px; }
}
