﻿/* ═══════════════════════════════════════════════════════════════
   KAI Platform — Base CSS (companion to Tailwind)
   Only things Tailwind cannot handle: animations, scrollbar,
   Blazor-specific elements, gradient utilities
   ═══════════════════════════════════════════════════════════════ */

/* ─── Animations ─────────────────────────────────────────────── */

/* Reset browser default button background (Tailwind preflight only removes border/outline) */
/*button { background-color: transparent; }*/

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
    from { opacity: 0; transform: translateX(-15px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: .6; }
}
@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
@keyframes glow {
    0%, 100% { box-shadow: 0 0 5px rgba(108,159,255,.2); }
    50%      { box-shadow: 0 0 20px rgba(108,159,255,.4); }
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-6px); }
}
@keyframes borderGlow {
    0%, 100% { border-color: rgba(108,159,255,.2); }
    50%      { border-color: rgba(108,159,255,.5); }
}
@keyframes gradientShift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
@keyframes slideInRight {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}
@keyframes toastIn {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

/* ─── Animation classes ──────────────────────────────────────── */
.animate-fade-in   { animation: fadeIn .4s ease-out both; }
.animate-slide-up  { animation: slideUp .5s ease-out both; }
.animate-slide-in  { animation: slideIn .3s ease-out both; }
.animate-slide-in-right { animation: slideInRight .25s ease-out both; }
.animate-slide-down{ animation: slideDown .3s ease-out both; }
.animate-scale-in  { animation: scaleIn .2s ease-out both; }
.animate-toast-in  { animation: toastIn .3s cubic-bezier(.21,1.02,.73,1) both; }
.animate-pulse     { animation: pulse 2s ease-in-out infinite; }
.animate-shimmer   { animation: shimmer 2s linear infinite; }
.animate-glow      { animation: glow 2s ease-in-out infinite; }
.animate-spin      { animation: spin 1s linear infinite; }
.animate-float     { animation: float 3s ease-in-out infinite; }
.animate-border-glow { animation: borderGlow 2s ease-in-out infinite; }

/* ─── Stagger delays ─────────────────────────────────────────── */
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 50ms; }
.stagger > *:nth-child(3) { animation-delay: 60ms; }
.stagger > *:nth-child(4) { animation-delay: 90ms; }
.stagger > *:nth-child(5) { animation-delay: 120ms; }
.stagger > *:nth-child(6) { animation-delay: 150ms; }
.stagger > *:nth-child(7) { animation-delay: 180ms; }
.stagger > *:nth-child(8) { animation-delay: 210ms; }
.stagger > *:nth-child(9) { animation-delay: 240ms; }
.stagger > *:nth-child(10) { animation-delay: 270ms; }
.stagger > *:nth-child(11) { animation-delay: 300ms; }
.stagger > *:nth-child(12) { animation-delay: 330ms; }

/* ─── Base ───────────────────────────────────────────────────── */
html, body {
    font-family: 'Inter', 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: #0a0a14;
    color: #e8e8f5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: #6c9fff; transition: color .2s; }
a:hover { color: #a0c4ff; }

/* ─── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.15); }

/* ─── Blazor specifics ───────────────────────────────────────── */
.content { padding-top: 1.1rem; animation: fadeIn .4s ease-out; }
h1:focus { outline: none; }
.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid #e50000; }
.validation-message { color: #e50000; }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}
.blazor-error-boundary::after { content: "An error has occurred." }

/* ─── Global Input Dark (Tailwind @layer base) ──────────────── */
input, select, textarea {
    background: #1c1c38;
    color: #e8e8f5;
    border: none;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    transition: border-color .2s, box-shadow .2s;
    box-sizing: border-box;
    max-width: 100%;
    min-width: 0;
}
input:focus, select:focus, textarea:focus {
    border-color: #6c9fff;
    box-shadow: 0 0 0 3px rgba(108,159,255,.12);
}
input::placeholder, textarea::placeholder { color: #7878aa; }
select option { background: #13132a; color: #e8e8f5; }

/* ─── Gradient utilities ─────────────────────────────────────── */
.bg-gradient-accent { background: linear-gradient(135deg, #5b8dff, #a78bfa); }
.bg-gradient-green  { background: linear-gradient(135deg, #22c55e, #06b6d4); }
.bg-gradient-warm   { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.bg-gradient-card   { background: linear-gradient(145deg, rgba(255,255,255,.03), rgba(255,255,255,.0)); }
.text-gradient-accent {
    background: linear-gradient(135deg, #5b8dff, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ─── Glass morphism ─────────────────────────────────────────── */
.glass {
    background: rgba(19,19,42,.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,.06);
}

/* ─── Page enter animation (wrap page content) ───────────────── */
.page-enter {
    animation: fadeIn .4s ease-out both, slideUp .5s ease-out both;
}

/* ─── Skeleton loading ───────────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, rgba(255,255,255,.03) 25%, rgba(255,255,255,.08) 50%, rgba(255,255,255,.03) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 8px;
}

/* ─── Focus ring for accessibility ───────────────────────────── */
.focus-ring:focus-visible {
    outline: 2px solid rgba(108,159,255,.5);
    outline-offset: 2px;
}

/* ─── Tooltip base ───────────────────────────────────────────── */
[data-tooltip] {
    position: relative;
}
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    padding: 4px 10px;
    background: #1a1a2e;
    color: #e8e8f5;
    font-size: 0.72rem;
    border-radius: 6px;
    border: 1px solid #333350;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
}
[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* ─── Mobile & Viewport ──────────────────────────────────────── */
@supports (height: 100dvh) {
    .h-dvh-fallback { height: 100dvh; }
}

@media (max-width: 768px) {
    .content { padding: 0 .5rem; }
}

/* Safe-area padding for notched devices */
.pb-safe { padding-bottom: env(safe-area-inset-bottom, 0px); }
.pt-safe { padding-top: env(safe-area-inset-top, 0px); }

/* ═══════════════════════════════════════════════════════════
   THEME SYSTEM — overrides Tailwind CSS variables per theme
   ═══════════════════════════════════════════════════════════ */

/* Smooth theme transitions (only color-related properties) */
html, html * {
    transition-property: background-color, border-color, color, box-shadow, opacity;
    transition-duration: 0.25s;
    transition-timing-function: ease;
}
/* Leave transforms/keyframe animations alone */
.animate-float, .animate-pulse, .animate-spin, .animate-shimmer,
.animate-glow, .animate-border-glow, [class*="hover:-translate"],
[class*="hover:translate"], [class*="duration-"] {
    transition: all 0.2s ease !important;
}

/* ── Light Theme ─────────────────────────────────────────── */
html[data-theme="light"] {
    --color-base:         #f8f9fc;
    --color-card:         #ffffff;
    --color-input:        #f0f2f8;
    --color-hover:        #ebeef6;
    --color-surface:      #f3f5fb;
    --color-border:       rgba(0,0,0,0.07);
    --color-border-light: rgba(0,0,0,0.04);
    --color-txt:          #1a1a35;
    --color-muted:        #6b6b9a;
    --color-accent:       #4a7eff;
    --color-accent-dim:   rgba(74,126,255,0.10);
    --color-accent-glow:  rgba(74,126,255,0.18);
    --color-success:      #16a34a;
    --color-danger:       #dc2626;
    --color-warning:      #d97706;
    --color-purple:       #7c3aed;
    --color-cyan:         #0891b2;
}
html[data-theme="light"] body {
    background: linear-gradient(135deg, #f8f9fc 0%, #f0f4ff 50%, #f8f9fc 100%);
    color: #1a1a35;
}
html[data-theme="light"] input,
html[data-theme="light"] select,
html[data-theme="light"] textarea {
    background: #edf0f9;
    color: #1a1a35;
    border-bottom-color: rgba(0,0,0,0.10);
}
html[data-theme="light"] .glass {
    background: rgba(255,255,255,0.85);
    border-color: rgba(0,0,0,0.07);
}
html[data-theme="light"] .text-gradient-accent {
    background: linear-gradient(135deg, #3a6fff, #7c3aed);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
html[data-theme="light"] .bg-gradient-accent { background: linear-gradient(135deg, #3a6fff, #7c3aed); }
html[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); }
html[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.22); }

/* ── Light theme: Invert white-alpha overlays to dark-alpha ─── */
/* bg-white/X → rgba(0,0,0,X) */
html[data-theme="light"] .bg-white\/5,
html[data-theme="light"] .bg-white\/\[\.05\]  { background-color: rgba(0,0,0,.04)  !important; }
html[data-theme="light"] .bg-white\/\[\.02\]  { background-color: rgba(0,0,0,.014) !important; }
html[data-theme="light"] .bg-white\/\[\.03\]  { background-color: rgba(0,0,0,.02)  !important; }
html[data-theme="light"] .bg-white\/\[\.04\]  { background-color: rgba(0,0,0,.03)  !important; }
html[data-theme="light"] .bg-white\/6         { background-color: rgba(0,0,0,.05)  !important; }
html[data-theme="light"] .bg-white\/\[\.08\]  { background-color: rgba(0,0,0,.05)  !important; }
html[data-theme="light"] .bg-white\/10        { background-color: rgba(0,0,0,.06)  !important; }
html[data-theme="light"] .bg-white\/20        { background-color: rgba(0,0,0,.08)  !important; }
/* hover:bg-white/X */
html[data-theme="light"] .hover\:bg-white\/\[\.03\]:hover { background-color: rgba(0,0,0,.025) !important; }
html[data-theme="light"] .hover\:bg-white\/5:hover        { background-color: rgba(0,0,0,.04)  !important; }
/* border-white/X → rgba(0,0,0,X) */
html[data-theme="light"] .border-white\/\[\.02\] { border-color: rgba(0,0,0,.02)  !important; }
html[data-theme="light"] .border-white\/\[\.04\] { border-color: rgba(0,0,0,.035) !important; }
html[data-theme="light"] .border-white\/\[\.06\] { border-color: rgba(0,0,0,.055) !important; }
html[data-theme="light"] .border-white\/\[\.08\] { border-color: rgba(0,0,0,.07)  !important; }
html[data-theme="light"] .border-white\/\[\.1\]  { border-color: rgba(0,0,0,.09)  !important; }
html[data-theme="light"] .border-white\/10       { border-color: rgba(0,0,0,.09)  !important; }
html[data-theme="light"] .border-white\/20       { border-color: rgba(0,0,0,.15)  !important; }
html[data-theme="light"] .border-white\/30       { border-color: rgba(0,0,0,.2)   !important; }
html[data-theme="light"] .hover\:border-white\/20:hover { border-color: rgba(0,0,0,.15) !important; }
/* from-white/X (gradient start) → dark-alpha */
html[data-theme="light"] [class*="from-white\/\[\.03\]"] { --tw-gradient-from: rgba(0,0,0,.02) !important; }
html[data-theme="light"] [class*="from-white\/\[\.04\]"] { --tw-gradient-from: rgba(0,0,0,.03) !important; }
/* .kai-card glass effect → subtle dark tint on light */
html[data-theme="light"] .kai-card {
    background: linear-gradient(135deg, rgba(0,0,0,.015), rgba(0,0,0,.005));
}
/* .qa-card (quick actions) */
html[data-theme="light"] .qa-card {
    background: rgba(0,0,0,.02);
}
html[data-theme="light"] .qa-card:hover {
    background: rgba(74,126,255,.06);
}

/* ── Vibrant / Neon Theme ────────────────────────────────── */
html[data-theme="vibrant"] {
    --color-base:         #060612;
    --color-card:         #0e0c22;
    --color-input:        #161430;
    --color-hover:        #1c193e;
    --color-surface:      #110f28;
    --color-border:       rgba(176,127,255,0.14);
    --color-border-light: rgba(176,127,255,0.07);
    --color-txt:          #ede8ff;
    --color-muted:        #8e7cc3;
    --color-accent:       #b07fff;
    --color-accent-dim:   rgba(176,127,255,0.15);
    --color-accent-glow:  rgba(176,127,255,0.30);
    --color-success:      #0fe8a8;
    --color-danger:       #ff5577;
    --color-warning:      #f5c842;
    --color-purple:       #e07fff;
    --color-cyan:         #00f5d4;
}
html[data-theme="vibrant"] body {
    background: #060612;
    color: #ede8ff;
}
html[data-theme="vibrant"] .text-gradient-accent {
    background: linear-gradient(135deg, #b07fff, #00f5d4);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
html[data-theme="vibrant"] .bg-gradient-accent { background: linear-gradient(135deg, #b07fff, #00f5d4); }

/* ── Quick action cards (Dashboard) ─────────────────────── */
.qa-card {
    display: flex; align-items: center; gap: 0.625rem;
    padding: 0.625rem 0.75rem; border-radius: 0.75rem;
    border: 1px solid var(--color-border); text-decoration: none;
    font-size: 0.8rem; font-weight: 500; color: var(--color-txt);
    background: rgba(255,255,255,.025);
}
.qa-card:hover {
    transform: translateY(-2px);
    background: rgba(108,159,255,.07);
    border-color: rgba(108,159,255,.28);
    color: var(--color-accent);
    box-shadow: 0 4px 18px rgba(108,159,255,.1);
    text-decoration: none;
}
.qa-icon {
    width: 2rem; height: 2rem; border-radius: 0.5rem;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* ── Stat bar gradient helpers ───────────────────────────── */
.bar-accent  { background: linear-gradient(90deg,#6c9fff,#a78bfa); }
.bar-success { background: var(--color-success); }
.bar-danger  { background: var(--color-danger); }
.bar-warning { background: var(--color-warning); }
.bar-cyan    { background: linear-gradient(90deg,#6c9fff,#22d3ee); }
.bar-purple  { background: var(--color-purple); }

/* ── Standard card ───────────────────────────────────────── */
.kai-card {
    background: linear-gradient(135deg, rgba(255,255,255,.04), rgba(255,255,255,.01));
    border: 1px solid var(--color-border);
    border-radius: 0.875rem;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all 0.3s ease;
}
.kai-card:hover {
    border-color: var(--color-accent-dim);
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--color-accent-glow);
}

/* ── Standard page header ────────────────────────────────── */
.page-hd {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.page-hd h1 {
    font-size: 1.6rem;
    font-weight: 900;
    line-height: 1.2;
    margin-bottom: 0.25rem;
    letter-spacing: -0.02em;
}
.page-hd p {
    font-size: 0.875rem;
    color: var(--color-muted);
    margin: 0;
}
.page-hd .hd-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}