/* CAFM Custom Component Styles — kein @apply, Tailwind-Utilities via CDN */

/* ─── Design Tokens (Custom Properties) ─── */
:root {
    --transition-default: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-colors: color, background-color, border-color 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 2rem;
    --shadow-sm: 0 1px 2px 0 rgb(15 23 42 / 0.06), 0 1px 3px 0 rgb(15 23 42 / 0.06);
    --shadow-md: 0 4px 10px -2px rgb(15 23 42 / 0.10), 0 2px 4px -2px rgb(15 23 42 / 0.06);
    --shadow-lg: 0 12px 24px -8px rgb(15 23 42 / 0.18), 0 4px 8px -4px rgb(15 23 42 / 0.08);
}

/* ─── Button-Reset (wiederverwendbare Basis) ─── */
.btn-reset {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    border: none;
    outline: none;
    box-shadow: none;
    font-family: inherit;
    cursor: pointer;
}

/* ─── Sidebar Navigation Links ─── */
.sidebar-link {
    transition: var(--transition-colors);
    border-radius: var(--radius-md);
}
.sidebar-link:hover {
    background-color: oklch(var(--b3, 0.961151 0 0));
}
.sidebar-link.active {
    background: linear-gradient(135deg, oklch(var(--p, 0.6569 0.196 275.75) / 0.18), oklch(var(--p, 0.6569 0.196 275.75) / 0.08));
    color: oklch(var(--p, 0.6569 0.196 275.75));
    font-weight: 600;
}

/* ─── Stat Cards ─── */
.stat-card {
    background-color: oklch(var(--b1, 1 0 0));
    border: 1px solid oklch(var(--b3, 0.961151 0 0));
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition-default);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, oklch(var(--p, 0.6569 0.196 275.75)), oklch(var(--s, 0.6569 0.196 275.75)));
    opacity: 0;
    transition: opacity 200ms ease;
}
.stat-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-0.125rem);
    border-color: oklch(var(--p, 0.6569 0.196 275.75) / 0.4);
}
.stat-card:hover::before { opacity: 1; }

/* ─── Glass Card ─── */
.glass-card {
    background-color: oklch(var(--b2, 0.961151 0 0));
    border: 1px solid oklch(var(--b3, 0.961151 0 0));
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
}

/* ─── Page Header ─── */
.page-header {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2rem;
}
@media (min-width: 1024px) {
    .page-header {
        flex-direction: row;
        align-items: flex-start;
    }
}
.page-header-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.page-title {
    font-size: 1.875rem;
    font-weight: 700;
    line-height: 2.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.page-subtitle {
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: oklch(var(--bc, 0.278078 0.029596 256.847) / 0.5);
}

/* ─── Modal Structure ─── */
.modal-header {
    border-bottom: 1px solid oklch(var(--bc, 0.278078 0.029596 256.847) / 0.12);
    padding-bottom: 1rem;
    margin-bottom: 1.25rem;
}
.modal-footer {
    border-top: 1px solid oklch(var(--bc, 0.278078 0.029596 256.847) / 0.12);
    padding-top: 1rem;
    margin-top: 0.5rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* ─── Data Table ─── */
.data-table th {
    background-color: oklch(var(--b2, 0.961151 0 0));
    position: sticky;
    top: 0;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: oklch(var(--bc, 0.278078 0.029596 256.847) / 0.6);
    border-bottom: 2px solid oklch(var(--b3, 0.961151 0 0));
}
.data-table tbody tr:nth-child(even) td {
    background-color: oklch(var(--b2, 0.961151 0 0) / 0.4);
}
.data-table tr:hover td {
    background-color: oklch(var(--b2, 0.961151 0 0) / 0.8);
}

/* ─── Toast Animation ─── */
.toast-enter {
    animation: slideInRight 0.3s ease;
}

/* ─── Kontextmenü (Dateiablage) ─── */
.ctx-menu-wrap {
    width: 13rem;
    overflow: hidden;
    transform-origin: top left;
    -webkit-user-select: none;
    user-select: none;
}
.ctx-menu-header {
    padding: 0.625rem 0.75rem 0.5rem;
    border-bottom: 1px solid oklch(var(--b3, 0.961151 0 0));
}
.ctx-menu-label {
    display: block;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: oklch(var(--bc, 0.278078 0.029596 256.847) / 0.4);
    margin-bottom: 0.125rem;
}
.ctx-menu-name {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: oklch(var(--bc, 0.278078 0.029596 256.847));
}
.ctx-menu-body { padding: 0.375rem; }
.ctx-divider {
    margin: 0.25rem 0;
    border: 0;
    border-top: 1px solid oklch(var(--b3, 0.961151 0 0));
}
.ctx-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    width: 100%;
    padding: 0.45rem 0.625rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    cursor: pointer;
    border-radius: var(--radius-md);
    text-align: left;
    color: oklch(var(--bc, 0.278078 0.029596 256.847));
    transition: background-color 0.12s;
}
.ctx-item:hover { background-color: oklch(var(--b3, 0.961151 0 0)); }
.ctx-item-danger,
.ctx-item-danger svg { color: oklch(var(--er, 0.5722 0.2488 27.33)); }
.ctx-item-danger:hover {
    background-color: oklch(var(--er, 0.5722 0.2488 27.33) / 0.12);
}

/* ─── Keyframes ─── */
@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}
@keyframes blobPulse {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50%       { transform: scale(1.08); opacity: 0.8; }
}

/* ─── Auth-Page Dekorations-Blobs ─── */
.auth-blob {
    position: absolute;
    border-radius: 9999px;
    filter: blur(80px);
    pointer-events: none;
    animation: blobPulse 8s ease-in-out infinite;
}

/* ─── Base ─── */
body { font-family: 'Inter', system-ui, sans-serif; }
[x-cloak] { display: none !important; }

/* ───────────────────────────────────────────────────────────────────── */
/* ── FIX 2b-17: Reduced Motion (Prefer Reduced Motion) ──────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ── FIX 2b-18: oklch-Fallbacks (RGB-Fallback für kritische Farben) ── */
body {
    background-color: #f3f4f6; /* gray-100 Fallback */
    background-color: oklch(0.96 0.005 260);
    background-image: radial-gradient(circle, oklch(var(--bc, 0.278078 0.029596 256.847) / 0.04) 1px, transparent 1px);
    background-size: 24px 24px;
}
@supports (backdrop-filter: blur(8px)) {
    .glass-card { backdrop-filter: blur(2px); }
}
.stat-card {
    background-color: #ffffff; /* white Fallback */
    background-color: oklch(var(--b1, 1 0 0));
}
.glass-card {
    background-color: #f9fafb; /* gray-50 Fallback */
    background-color: oklch(var(--b2, 0.961151 0 0));
}
.sidebar-link:hover {
    background-color: #f3f4f6; /* gray-100 Fallback */
    background-color: oklch(var(--b3, 0.961151 0 0));
}
.data-table th {
    background-color: #f9fafb; /* gray-50 Fallback */
    background-color: oklch(var(--b2, 0.961151 0 0));
}
.ctx-item:hover {
    background-color: #f3f4f6; /* gray-100 Fallback */
    background-color: oklch(var(--b3, 0.961151 0 0));
}

/* ── FIX 2b-19: Responsive-Tabelle + Anpassungen ───────────────────── */
.data-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.page-title {
    font-size: clamp(1.25rem, 4vw, 1.875rem);
}
.stat-card {
    min-width: 0;
}
.modal-footer {
    flex-wrap: wrap;
}
@media (max-width: 640px) {
    .modal-footer {
        justify-content: stretch;
    }
    .modal-footer > * {
        flex: 1 1 auto;
    }
    .page-header {
        gap: 0.5rem;
        margin-bottom: 1.5rem;
    }
}

/* ── Optik-Feinschliff (Tiefe, Fokus, Interaktion) ─────────────────── */
.sidebar-link { position: relative; }
.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: -0.25rem; top: 20%; bottom: 20%;
    width: 3px;
    border-radius: 9999px;
    background: oklch(var(--p, 0.6569 0.196 275.75));
}
.page-header-icon { box-shadow: inset 0 0 0 1px currentColor; box-shadow: inset 0 0 0 1px color-mix(in oklab, currentColor 25%, transparent); }
.page-title { letter-spacing: -0.015em; }

.btn { transition: var(--transition-default); }
.btn:not(:disabled):not(.btn-disabled):hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:not(:disabled):not(.btn-disabled):active { transform: translateY(0); box-shadow: none; }
.btn-primary:not(:disabled):hover { box-shadow: 0 6px 14px -4px oklch(var(--p, 0.6569 0.196 275.75) / 0.5); }

:where(a, button, input, select, textarea, summary):focus-visible {
    outline: 2px solid oklch(var(--p, 0.6569 0.196 275.75) / 0.7);
    outline-offset: 2px;
}
.input:focus, .select:focus, .textarea:focus {
    border-color: oklch(var(--p, 0.6569 0.196 275.75));
    box-shadow: 0 0 0 3px oklch(var(--p, 0.6569 0.196 275.75) / 0.15);
    outline: none;
}

.modal-box { border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); }
.modal::backdrop, .modal-backdrop { backdrop-filter: blur(2px); }
.table tbody tr { transition: background-color 120ms ease; }
.table tbody tr:hover { background-color: oklch(var(--b2, 0.961151 0 0) / 0.7); }
.badge { font-weight: 600; letter-spacing: 0.01em; }
.alert { border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: '▸'; display: inline-block; width: 1rem; transition: transform 150ms ease; }
details[open] > summary::before { transform: rotate(90deg); }

/* Dezente Scrollbars */
* { scrollbar-width: thin; scrollbar-color: oklch(var(--bc, 0.278078 0.029596 256.847) / 0.25) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: oklch(var(--bc, 0.278078 0.029596 256.847) / 0.25); border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: oklch(var(--bc, 0.278078 0.029596 256.847) / 0.4); }
