/* ============================================================
   KDB Design System - Minimalism & Swiss Style
   Based on UI/UX Pro Max reasoning engine
   Bootstrap 5.3.0 + Bootstrap Icons 1.10.0
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fira+Sans:wght@300;400;500;600;700&family=Fira+Code:wght@400;500;600&display=swap');

/* ---------- Design Tokens ---------- */
:root {
    --ap-primary: #2563EB;
    --ap-primary-hover: #1D4ED8;
    --ap-secondary: #3B82F6;
    --ap-accent: #EA580C;
    --ap-accent-hover: #C2410C;
    --ap-success: #16A34A;
    --ap-warning: #F59E0B;
    --ap-danger: #DC2626;
    --ap-info: #0EA5E9;

    --ap-bg: #F8FAFC;
    --ap-fg: #1E293B;
    --ap-card: #FFFFFF;
    --ap-card-fg: #1E293B;
    --ap-muted: #E9EFF8;
    --ap-muted-fg: #475569;
    --ap-border: #E2E8F0;

    --ap-radius: 0.375rem;
    --ap-radius-lg: 0.5rem;
    --ap-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --ap-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --ap-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --ap-transition: 200ms ease;
}

/* ---------- Base ---------- */
body {
    font-family: 'Fira Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--ap-bg);
    color: var(--ap-fg);
    -webkit-font-smoothing: antialiased;
}

/* ---------- Karten ---------- */
.dashboard-card,
.table-card,
.workplan-card {
    background: var(--ap-card);
    border: 1px solid var(--ap-border);
    border-radius: var(--ap-radius-lg);
    transition: box-shadow var(--ap-transition);
}

.dashboard-card:hover,
.workplan-card:hover {
    box-shadow: var(--ap-shadow-md);
}

.stats-card {
    background: var(--ap-card);
    border: 1px solid var(--ap-border);
    border-radius: var(--ap-radius-lg);
    transition: box-shadow var(--ap-transition);
}

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

.stat-card {
    background: var(--ap-card);
    border: 1px solid var(--ap-border);
    border-radius: var(--ap-radius-lg);
    transition: box-shadow var(--ap-transition);
}

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

/* ---------- Welcome Banner ---------- */
.welcome-banner,
.welcome-card {
    background: var(--ap-primary);
    color: #fff;
    border: none;
    border-radius: var(--ap-radius-lg);
}

/* ---------- Buttons ---------- */
.btn-primary {
    background: var(--ap-primary);
    border: 1px solid var(--ap-primary);
    color: #fff;
    font-weight: 500;
    transition: all var(--ap-transition);
}

.btn-primary:hover {
    background: var(--ap-primary-hover);
    border-color: var(--ap-primary-hover);
    color: #fff;
}

.btn-primary:focus-visible {
    outline: 2px solid var(--ap-primary);
    outline-offset: 2px;
}

.btn-accent {
    background: var(--ap-accent);
    border: 1px solid var(--ap-accent);
    color: #fff;
    font-weight: 500;
    transition: all var(--ap-transition);
}

.btn-accent:hover {
    background: var(--ap-accent-hover);
    border-color: var(--ap-accent-hover);
    color: #fff;
}

.btn-login {
    background: var(--ap-primary);
    border: 1px solid var(--ap-primary);
    color: #fff;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    transition: all var(--ap-transition);
}

.btn-login:hover {
    background: var(--ap-primary-hover);
    border-color: var(--ap-primary-hover);
    color: #fff;
}

.btn-outline-primary {
    color: var(--ap-primary);
    border-color: var(--ap-primary);
}

.btn-outline-primary:hover {
    background: var(--ap-primary);
    border-color: var(--ap-primary);
    color: #fff;
}

/* ---------- Tabellen ---------- */
.table-card .table,
.table-responsive .table {
    margin-bottom: 0;
}

.table-hover tbody tr:hover {
    background-color: var(--ap-muted);
}

.table thead th {
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ap-muted-fg);
    border-bottom: 2px solid var(--ap-border);
}

.table tbody td {
    border-bottom: 1px solid var(--ap-border);
    vertical-align: middle;
}

.table-bordered td,
.table-bordered th {
    border-color: var(--ap-border);
}

/* ---------- Stat-Zahlen ---------- */
.stat-number {
    font-family: 'Fira Code', monospace;
    font-size: 2rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--ap-fg);
}

/* ---------- Avatare ---------- */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--ap-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
}

/* ---------- Badges ---------- */
.badge-admin {
    background: var(--ap-danger);
    color: #fff;
    padding: 0.25rem 0.625rem;
    border-radius: var(--ap-radius);
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-mitarbeiter {
    background: var(--ap-primary);
    color: #fff;
    padding: 0.25rem 0.625rem;
    border-radius: var(--ap-radius);
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-extern {
    background: var(--ap-secondary);
    color: #fff;
    padding: 0.25rem 0.625rem;
    border-radius: var(--ap-radius);
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-kundennummer {
    background: var(--ap-muted);
    color: var(--ap-muted-fg);
    padding: 0.25rem 0.625rem;
    border-radius: var(--ap-radius);
    font-size: 0.75rem;
    font-weight: 500;
}

/* ---------- Prioritaeten ---------- */
.priority-low { border-left: 3px solid var(--ap-success); }
.priority-medium { border-left: 3px solid var(--ap-warning); }
.priority-high { border-left: 3px solid var(--ap-accent); }
.priority-critical { border-left: 3px solid var(--ap-danger); }

/* ---------- Status-Badges ---------- */
.status-badge {
    min-width: 120px;
}

/* ---------- Filter-Navigation ---------- */
.filter-nav .nav-link {
    color: var(--ap-muted-fg);
    border: none;
    padding: 0.5rem 1rem;
    font-weight: 500;
    font-size: 0.875rem;
    transition: color var(--ap-transition);
    border-bottom: 2px solid transparent;
}

.filter-nav .nav-link:hover {
    color: var(--ap-fg);
}

.filter-nav .nav-link.active {
    color: var(--ap-primary);
    border-bottom-color: var(--ap-primary);
}

/* ---------- Pagination ---------- */
.pagination .page-link {
    color: var(--ap-primary);
    border: 1px solid var(--ap-border);
    border-radius: var(--ap-radius);
    margin: 0 2px;
    font-size: 0.875rem;
    transition: all var(--ap-transition);
}

.pagination .page-item.active .page-link {
    background: var(--ap-primary);
    border-color: var(--ap-primary);
    color: #fff;
}

.pagination .page-item.disabled .page-link {
    color: var(--ap-muted-fg);
    background: var(--ap-muted);
    border-color: var(--ap-border);
}

/* ---------- Quick-Action-Karten ---------- */
.quick-action-card {
    transition: box-shadow var(--ap-transition);
    border: 1px solid var(--ap-border);
    border-radius: var(--ap-radius-lg);
    background: var(--ap-card);
}

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

/* ---------- Einsatz-Items ---------- */
.einsatz-item {
    transition: all var(--ap-transition);
    border-left: 3px solid var(--ap-border);
    padding: 0.75rem 1rem;
    border-radius: var(--ap-radius);
    margin-bottom: 0.5rem;
    background: var(--ap-card);
}

.einsatz-item:hover {
    border-left-color: var(--ap-primary);
    background: var(--ap-muted);
}

/* ---------- Action-Buttons ---------- */
.action-buttons .btn {
    margin: 0 2px;
}

/* ---------- Zeile hover ---------- */
.customer-row,
.task-item {
    transition: background var(--ap-transition);
}

.customer-row:hover,
.task-item:hover {
    background: var(--ap-muted);
}

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

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--ap-border);
}

/* ---------- Login-Seite ---------- */
.login-card {
    border: 1px solid var(--ap-border);
    border-radius: var(--ap-radius-lg);
    box-shadow: var(--ap-shadow-md);
    max-width: 400px;
    margin: 0 auto;
    overflow: hidden;
}

.login-card .card-header {
    background: var(--ap-primary);
    padding: 2rem;
    text-align: center;
    border: none;
}

.login-card .logo {
    color: #fff;
    font-weight: 700;
    font-size: 1.5rem;
}

.password-container {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--ap-muted-fg);
    z-index: 10;
}

/* ---------- Formular-Fokus ---------- */
.form-control:focus {
    border-color: var(--ap-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-select:focus {
    border-color: var(--ap-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* ---------- Sidebar-Hinweis ---------- */
.system-status {
    border-left: 3px solid var(--ap-success);
}

/* ---------- Badge fuer Zaehler ---------- */
.stats-badge {
    padding: 0.25rem 0.625rem;
    border-radius: var(--ap-radius);
    font-size: 0.8125rem;
    font-weight: 500;
}

/* ---------- Device-Zaehler ---------- */
.device-counts {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.device-types {
    background: var(--ap-muted);
    color: var(--ap-muted-fg);
    padding: 0.125rem 0.5rem;
    border-radius: var(--ap-radius);
    font-size: 0.75rem;
    font-weight: 500;
}

.device-total {
    background: var(--ap-success);
    color: #fff;
    padding: 0.125rem 0.5rem;
    border-radius: var(--ap-radius);
    font-size: 0.75rem;
    font-weight: 500;
}

/* ---------- Table-Aktionen ---------- */
.table-actions {
    white-space: nowrap;
}

/* ---------- Zeitraum-Badges ---------- */
.zeitraum-badge {
    background: var(--ap-primary);
    color: #fff;
    padding: 0.25rem 0.625rem;
    border-radius: var(--ap-radius);
    font-size: 0.75rem;
    font-weight: 500;
}

.zeitraum-aktiv {
    background: rgba(37, 99, 235, 0.08);
}

.recurring-badge {
    background: #7C3AED;
    color: #fff;
    padding: 0.25rem 0.625rem;
    border-radius: var(--ap-radius);
    font-size: 0.75rem;
    font-weight: 500;
}

/* ---------- Kategorie-Badges ---------- */
.kategorie-badge {
    background: var(--ap-muted);
    color: var(--ap-muted-fg);
    font-size: 0.8125rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--ap-radius);
    font-weight: 500;
}

.vertretung-badge {
    background: var(--ap-primary);
    color: #fff;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--ap-radius);
    font-weight: 500;
}

.today-badge {
    background: var(--ap-warning);
    color: #000;
    padding: 0.25rem 0.625rem;
    border-radius: var(--ap-radius);
    font-size: 0.75rem;
    font-weight: 600;
}

/* ---------- Sortier-Handle ---------- */
.handle {
    cursor: move;
    color: var(--ap-muted-fg);
}

.bg-faded {
    background: var(--ap-muted);
}

/* ---------- Quick-Action-Buttons ---------- */
.quick-action-btn {
    transition: all var(--ap-transition);
    border: 1px solid var(--ap-border);
    border-radius: var(--ap-radius-lg);
    padding: 1rem;
    text-align: center;
    background: var(--ap-card);
}

.quick-action-btn:hover {
    border-color: var(--ap-primary);
    box-shadow: var(--ap-shadow-md);
}

/* ---------- Teil-Karten ---------- */
.teil-card {
    transition: box-shadow var(--ap-transition);
    height: 100%;
    border: 1px solid var(--ap-border);
    border-radius: var(--ap-radius-lg);
    background: var(--ap-card);
}

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

.kunden-badge {
    background: var(--ap-muted);
    color: var(--ap-muted-fg);
    padding: 0.25rem 0.625rem;
    border-radius: var(--ap-radius);
    font-size: 0.75rem;
    font-weight: 500;
}

/* ---------- Zeitinfo ---------- */
.time-info {
    color: var(--ap-muted-fg);
    font-size: 0.875rem;
}

/* ---------- Alert-Animation ---------- */
.alert-dismissible {
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------- Focus States (A11y) ---------- */
*:focus-visible {
    outline: 2px solid var(--ap-primary);
    outline-offset: 2px;
}

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .stat-number {
        font-size: 1.5rem;
    }

    .dashboard-card .card-body,
    .stats-card .card-body {
        padding: 1rem !important;
    }
}

/* ---------- Code / Monospace ---------- */
code,
.font-monospace {
    font-family: 'Fira Code', monospace;
}

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

::-webkit-scrollbar-track {
    background: var(--ap-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--ap-border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--ap-muted-fg);
}
