/* 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;
}

/* ─── 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: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    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: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    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));
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

/* ─── 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;
}

/* ─── Loading Spinner ─── */
.spinner {
    border: 4px solid oklch(var(--b3, 0.961151 0 0));
    border-top-color: oklch(var(--p, 0.6569 0.196 275.75));
    border-radius: 9999px;
    width: 1.5rem;
    height: 1.5rem;
    animation: spin 1s linear infinite;
}

/* ─── 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 spin {
    to { transform: rotate(360deg); }
}
@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;
    }
}
