/**
 * PiPulse — style własne: glassmorphism, animacje, skeletons, progress bary,
 * komponenty wielokrotnego użytku (karty, tabele, badge, przyciski),
 * motyw jasny i style wydruku (eksport PDF).
 */

/* ==========================================================================
   Zmienne motywu
   ========================================================================== */

:root {
    --color-base: #09090B;
    --color-card: #18181B;
    --color-line: #27272A;
    --color-primary: #3B82F6;
    --color-success: #22C55E;
    --color-warning: #F59E0B;
    --color-danger: #EF4444;
}

html.light {
    color-scheme: light;
}

html.light body {
    background-color: #F4F4F5 !important;
    color: #18181B !important;
}

html.light .bg-base { background-color: #F4F4F5 !important; }
html.light .bg-card, html.light .card, html.light .stat-card { background-color: #FFFFFF !important; }
html.light .border-line { border-color: #E4E4E7 !important; }
html.light .text-zinc-100, html.light .text-zinc-200, html.light .text-zinc-300 { color: #27272A !important; }
html.light .text-zinc-400, html.light .text-zinc-500 { color: #52525B !important; }

/* Ukrywanie elementów przed inicjalizacją Alpine */
[x-cloak] { display: none !important; }

/* Płynne przewijanie całej aplikacji */
html { scroll-behavior: smooth; }

/* ==========================================================================
   Karty
   ========================================================================== */

.card {
    background-color: rgba(24, 24, 27, 0.85);
    border: 1px solid rgba(39, 39, 42, 0.8);
    border-radius: 1rem;
    backdrop-filter: blur(12px);
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card {
    background: linear-gradient(145deg, rgba(24, 24, 27, 0.95), rgba(24, 24, 27, 0.75));
    border: 1px solid rgba(39, 39, 42, 0.8);
    border-radius: 1rem;
    padding: 1.25rem;
    backdrop-filter: blur(12px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(600px circle at var(--mx, 50%) var(--my, 0%),
        rgba(59, 130, 246, 0.06), transparent 40%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.stat-card:hover {
    border-color: rgba(63, 63, 70, 1);
    transform: translateY(-2px);
    box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.6);
}

.stat-card:hover::before { opacity: 1; }

.stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.625rem;
    transition: transform 0.2s ease;
}

.stat-card:hover .stat-icon { transform: scale(1.1) rotate(-4deg); }

.card-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.mini-stat {
    background: rgba(9, 9, 11, 0.5);
    border: 1px solid rgba(39, 39, 42, 0.6);
    border-radius: 0.75rem;
    padding: 0.75rem;
}

.mini-stat-label {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #71717A;
}

.mini-stat-value {
    margin-top: 0.25rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Glassmorphism
   ========================================================================== */

.glass {
    background: rgba(24, 24, 27, 0.55);
    backdrop-filter: blur(24px) saturate(140%);
    -webkit-backdrop-filter: blur(24px) saturate(140%);
}

.glow-primary {
    animation: glow-pulse 3s ease-in-out infinite;
}

@keyframes glow-pulse {
    0%, 100% { box-shadow: 0 0 24px rgba(59, 130, 246, 0.35); }
    50%      { box-shadow: 0 0 48px rgba(59, 130, 246, 0.6); }
}

/* ==========================================================================
   Progress bary
   ========================================================================== */

.progress-track {
    height: 0.375rem;
    background: rgba(39, 39, 42, 0.8);
    border-radius: 9999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
    animation: progress-shimmer 2.5s ease-in-out infinite;
}

@keyframes progress-shimmer {
    0%   { transform: translateX(-100%); }
    60%, 100% { transform: translateX(100%); }
}

/* ==========================================================================
   Skeleton loading
   ========================================================================== */

.skeleton {
    position: relative;
    overflow: hidden;
    background: rgba(39, 39, 42, 0.5);
    border-radius: 0.5rem;
}

.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
    animation: skeleton-wave 1.6s ease-in-out infinite;
}

@keyframes skeleton-wave {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ==========================================================================
   Tabele danych
   ========================================================================== */

.data-table {
    width: 100%;
    font-size: 0.8125rem;
    border-collapse: collapse;
}

.data-table thead th {
    text-align: left;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #71717A;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid rgba(39, 39, 42, 0.8);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid rgba(39, 39, 42, 0.4);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background-color 0.15s ease;
}

.data-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.025);
}

html.light .data-table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

/* ==========================================================================
   Badge
   ========================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-success { background: rgba(34, 197, 94, 0.12);  color: #4ADE80; border: 1px solid rgba(34, 197, 94, 0.25); }
.badge-danger  { background: rgba(239, 68, 68, 0.12);  color: #F87171; border: 1px solid rgba(239, 68, 68, 0.25); }
.badge-warning { background: rgba(245, 158, 11, 0.12); color: #FBBF24; border: 1px solid rgba(245, 158, 11, 0.25); }
.badge-primary { background: rgba(59, 130, 246, 0.12); color: #60A5FA; border: 1px solid rgba(59, 130, 246, 0.25); }
.badge-neutral { background: rgba(113, 113, 122, 0.12); color: #A1A1AA; border: 1px solid rgba(113, 113, 122, 0.25); }

/* ==========================================================================
   Przyciski
   ========================================================================== */

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.625rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(39, 39, 42, 0.9);
    background: rgba(9, 9, 11, 0.4);
    font-size: 0.75rem;
    font-weight: 500;
    color: #D4D4D8;
    cursor: pointer;
    transition: all 0.15s ease;
}

.action-btn:hover:not(:disabled) {
    border-color: #52525B;
    background: rgba(255, 255, 255, 0.05);
    transform: translateY(-1px);
}

.action-btn:active:not(:disabled) { transform: scale(0.96); }

.action-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.quick-action {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    width: 100%;
    padding: 0.625rem 0.875rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(39, 39, 42, 0.8);
    background: rgba(9, 9, 11, 0.4);
    font-size: 0.8125rem;
    font-weight: 500;
    color: #D4D4D8;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.quick-action:hover:not(:disabled) {
    border-color: #3F3F46;
    background: rgba(255, 255, 255, 0.04);
    transform: translateX(3px);
}

.quick-action:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border-radius: 0.75rem;
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    color: white;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px -4px rgba(59, 130, 246, 0.4);
    transition: all 0.2s ease;
}

.btn-primary:hover { filter: brightness(1.1); box-shadow: 0 6px 20px -4px rgba(59, 130, 246, 0.55); }
.btn-primary:active { transform: scale(0.97); }

.form-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border-radius: 0.75rem;
    border: 1px solid #27272A;
    background: rgba(9, 9, 11, 0.6);
    font-size: 0.8125rem;
    color: inherit;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input::placeholder { color: #52525B; }

.form-input:focus {
    border-color: #3B82F6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

html.light .form-input { background: #FFFFFF; border-color: #E4E4E7; }

/* Efekt połysku na przycisku logowania */
.btn-shine::after {
    content: '';
    position: absolute;
    top: 0;
    left: -80%;
    width: 50%;
    height: 100%;
    background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transform: skewX(-20deg);
    transition: left 0.6s ease;
}

.btn-shine:hover::after { left: 130%; }

/* ==========================================================================
   Ekran logowania — animowane tło
   ========================================================================== */

.login-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.5;
    animation: blob-float 18s ease-in-out infinite;
}

.login-blob-1 {
    width: 480px; height: 480px;
    top: -10%; left: -5%;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.35), transparent 70%);
}

.login-blob-2 {
    width: 420px; height: 420px;
    bottom: -15%; right: -5%;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.28), transparent 70%);
    animation-delay: -6s;
}

.login-blob-3 {
    width: 320px; height: 320px;
    top: 45%; left: 55%;
    background: radial-gradient(circle, rgba(34, 197, 94, 0.14), transparent 70%);
    animation-delay: -12s;
}

@keyframes blob-float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%      { transform: translate(40px, -50px) scale(1.08); }
    66%      { transform: translate(-30px, 30px) scale(0.94); }
}

.login-grid-overlay {
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
    -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
}

/* ==========================================================================
   Animacje wejścia
   ========================================================================== */

.animate-rise {
    animation: rise 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes rise {
    from { opacity: 0; transform: translateY(24px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.animate-shake {
    animation: shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes shake {
    10%, 90% { transform: translateX(-1px); }
    20%, 80% { transform: translateX(2px); }
    30%, 50%, 70% { transform: translateX(-3px); }
    40%, 60% { transform: translateX(3px); }
}

.animate-toast-in {
    animation: toast-in 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(32px) scale(0.96); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}

/* ==========================================================================
   Konsola logów
   ========================================================================== */

.log-line {
    padding: 0.1rem 0.375rem;
    border-radius: 0.25rem;
    word-break: break-all;
    transition: background-color 0.1s ease;
}

.log-line:hover {
    background-color: rgba(255, 255, 255, 0.04);
}

/* ==========================================================================
   AI Assistant — dymki czatu
   ========================================================================== */

.ai-bubble {
    max-width: min(85%, 42rem);
    padding: 0.625rem 0.875rem;
    border-radius: 1.125rem;
    font-size: 0.8125rem;
    line-height: 1.6;
    word-break: break-word;
    animation: rise 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-bubble-user {
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    color: white;
    border-bottom-right-radius: 0.375rem;
    box-shadow: 0 4px 16px -6px rgba(59, 130, 246, 0.5);
}

.ai-bubble-ai {
    background: rgba(39, 39, 42, 0.6);
    border: 1px solid rgba(63, 63, 70, 0.5);
    color: #E4E4E7;
    border-bottom-left-radius: 0.375rem;
}

.ai-bubble-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #FCA5A5;
    border-bottom-left-radius: 0.375rem;
}

html.light .ai-bubble-ai {
    background: #FFFFFF;
    border-color: #E4E4E7;
    color: #27272A;
}

/* Migający kursor podczas streamowania odpowiedzi */
.ai-cursor {
    display: inline-block;
    width: 2px;
    height: 0.9em;
    margin-left: 2px;
    vertical-align: text-bottom;
    background: #60A5FA;
    animation: ai-blink 0.9s steps(2) infinite;
}

@keyframes ai-blink {
    50% { opacity: 0; }
}

/* Wskaźnik "pisania" — trzy pulsujące kropki */
.ai-typing {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0;
}

.ai-typing span {
    width: 0.375rem;
    height: 0.375rem;
    border-radius: 9999px;
    background: #71717A;
    animation: ai-typing-bounce 1.2s ease-in-out infinite;
}

.ai-typing span:nth-child(2) { animation-delay: 0.15s; }
.ai-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ai-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30%           { transform: translateY(-4px); opacity: 1; }
}

/* Suwaki parametrów modelu */
.ai-slider {
    -webkit-appearance: none;
    appearance: none;
    height: 0.25rem;
    border-radius: 9999px;
    background: rgba(63, 63, 70, 0.8);
    outline: none;
    cursor: pointer;
}

.ai-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 0.875rem;
    height: 0.875rem;
    border-radius: 9999px;
    background: #3B82F6;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.6);
    transition: transform 0.15s ease;
}

.ai-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }

.ai-slider::-moz-range-thumb {
    width: 0.875rem;
    height: 0.875rem;
    border: none;
    border-radius: 9999px;
    background: #3B82F6;
}

/* ==========================================================================
   Scrollbary
   ========================================================================== */

.scrollbar-thin::-webkit-scrollbar { width: 6px; height: 6px; }
.scrollbar-thin::-webkit-scrollbar-track { background: transparent; }
.scrollbar-thin::-webkit-scrollbar-thumb { background: #3F3F46; border-radius: 9999px; }
.scrollbar-thin::-webkit-scrollbar-thumb:hover { background: #52525B; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #09090B; }
::-webkit-scrollbar-thumb { background: #27272A; border-radius: 9999px; border: 2px solid #09090B; }
::-webkit-scrollbar-thumb:hover { background: #3F3F46; }

/* ==========================================================================
   Wydruk (eksport PDF)
   ========================================================================== */

@media print {
    body { background: white !important; color: black !important; }
    aside, header, footer, .toasts, button { display: none !important; }
    .lg\:pl-64 { padding-left: 0 !important; }
    .card, .stat-card { border: 1px solid #ddd !important; background: white !important; break-inside: avoid; }
    section[x-show] { display: block !important; }
}
