/* ============================================================================
   CPADS — motyw wizualny (WebSonar / MediaPanel)
   Akcent: coral #ff5733. Czcionki: Sora (nagłówki) + DM Sans (tekst).
   Jeden plik = źródło prawdy. Dołączany w <head> KAŻDEJ strony PO jej własnym
   <style>, dzięki czemu kaskada nadpisuje starszy motyw (indygo/Outfit).
   Sekcja "WARSTWA KOMPATYBILNOŚCI" remapuje legacy zmienne na coral, więc
   istniejące komponenty przekolorowują się bez przepisywania markupu.
   ========================================================================== */

:root {
    --coral-50: #fff5f3;
    --coral-100: #ffe4df;
    --coral-200: #ffccc4;
    --coral-300: #ffa899;
    --coral-400: #ff7a5c;
    --coral-500: #ff5733;
    --coral-600: #ed3d19;
    --coral-700: #c83010;

    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #eeeeee;
    --gray-300: #e0e0e0;
    --gray-400: #bdbdbd;
    --gray-500: #9e9e9e;
    --gray-600: #757575;
    --gray-700: #424242;
    --gray-800: #2d2d2d;
    --gray-900: #1a1a1a;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
}

/* ----------------------------------------------------------------------------
   WARSTWA KOMPATYBILNOŚCI — remap legacy zmiennych używanych na istniejących
   stronach (--accent / --bg / --surface / --border / --text* / --shadow* / --r)
   na nową paletę coral. Druga deklaracja :root w kolejności dokumentu wygrywa.
   -------------------------------------------------------------------------- */
:root {
    --accent: var(--coral-500);
    --accent2: var(--coral-400);
    --accent-600: var(--coral-600);
    --bg: #fafafa;
    --surface: #ffffff;
    --border: rgba(0, 0, 0, 0.06);
    --border-soft: var(--gray-100);
    --text: var(--gray-900);
    --text-2: var(--gray-600);
    --text-3: var(--gray-500);
    --shadow: var(--shadow-md);
    --shadow-xs: var(--shadow-sm);
    --r: 16px;
    /* statusy semantyczne (pozostają zbliskie oryginałowi WebSonar) */
    --ok: #16a34a;
    --warn: #d97706;
    --err: #dc2626;
}

/* ---- Reset / typografia bazowa ---- */
* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
    color: var(--gray-800);
    line-height: 1.6;
    overflow-x: hidden;
    /* Grayscale antialiasing — fonty renderują się cienko/ostro (jak w podglądach claude.ai),
       zamiast domyślnego subpikselowego „pogrubienia" psującego czytelność DM Sans. */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Sora', sans-serif;
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* elementy, które wg guide'a mają być w Sora (nawet jeśli nie są nagłówkiem) */
.stat-number, .brand-name, .source-pill, .metric-toggle,
button, .btn, .data-table thead th, table thead th {
    font-family: 'Sora', sans-serif;
}

/* Subtelne radialne tło — coralowe akcenty w rogach */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 20% 20%, rgba(255, 87, 51, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 122, 92, 0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.container { position: relative; z-index: 1; }

/* ---- Karty ---- */
.card {
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.04);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

/* ---- Animacje wejścia ---- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}
.animate-fade-in { animation: fadeInUp 0.6s ease-out forwards; }
.animate-delay-1 { animation-delay: 0.1s; opacity: 0; }
.animate-delay-2 { animation-delay: 0.2s; opacity: 0; }
.animate-delay-3 { animation-delay: 0.3s; opacity: 0; }
.animate-delay-4 { animation-delay: 0.4s; opacity: 0; }

@keyframes pulse-dot {
    0%, 100% { transform: scale(1);   opacity: 1; }
    50%      { transform: scale(1.2); opacity: 0.7; }
}

.partial-data-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 14px;
    background: var(--coral-50);
    color: var(--coral-700);
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid var(--coral-200);
}
.partial-data-badge .pulse-dot {
    width: 6px; height: 6px;
    background: var(--coral-500);
    border-radius: 50%;
    animation: pulse-dot 1.5s ease-in-out infinite;
}

/* ---- Akcent kreska nad sekcją ---- */
.accent-line {
    width: 40px; height: 3px;
    background: linear-gradient(90deg, var(--coral-500), var(--coral-300));
    border-radius: 2px;
    margin-bottom: 12px;
}

/* ---- Pigułki filtrów ---- */
.source-pill {
    padding: 10px 20px;
    border-radius: 12px;
    border: 2px solid var(--gray-200);
    background: white;
    color: var(--gray-600);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}
.source-pill:hover {
    border-color: var(--coral-300);
    background: var(--coral-50);
    color: var(--coral-600);
}
.source-pill.active {
    border-color: var(--coral-500);
    background: var(--coral-500);
    color: white;
    box-shadow: 0 4px 12px rgba(255, 87, 51, 0.25);
}

/* ---- Statystyki ---- */
.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.03em;
}
.stat-label {
    font-size: 0.875rem;
    color: var(--gray-500);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ---- Pole wyszukiwania ---- */
.search-input {
    width: 100%;
    padding: 14px 48px 14px 20px;
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    font-size: 15px;
    transition: all 0.2s ease;
    background: white;
}
.search-input:focus {
    outline: none;
    border-color: var(--coral-400);
    box-shadow: 0 0 0 4px rgba(255, 87, 51, 0.08);
}

/* ---- Tabele ---- */
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.data-table thead th {
    background: var(--gray-50);
    padding: 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--gray-200);
}
.data-table tbody tr { transition: background 0.15s ease; }
.data-table tbody tr:hover { background: var(--gray-50); }
.data-table tbody td {
    padding: 16px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
    font-size: 14px;
}

/* ---- Spinner ---- */
.spinner {
    border: 3px solid var(--gray-200);
    border-top: 3px solid var(--coral-500);
    border-radius: 50%;
    width: 40px; height: 40px;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Badge ---- */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.badge-audited { background: rgba(16, 185, 129, 0.1); color: rgb(5, 150, 105); }
.badge-unaudited { background: var(--gray-100); color: var(--gray-500); }

/* ---- Górny pasek nawigacji ---- */
.top-nav {
    border-bottom: 1px solid var(--gray-200);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
    background: rgba(255, 255, 255, 0.95);
}
.top-nav-content {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand a { transition: opacity 0.2s ease; }
.brand a:hover { opacity: 0.7; cursor: pointer; }

.brand-name {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--coral-600), var(--coral-400));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}
.brand-subtitle {
    font-size: 12px;
    color: var(--gray-500);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: -2px;
}

.nav-link {
    font-size: 14px;
    color: var(--gray-600);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}
.nav-link:hover { color: var(--coral-600); }
.nav-link.active { color: var(--coral-600); font-weight: 600; }

/* ---- Date picker ---- */
input[type="date"] {
    padding: 8px 12px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    font-size: 13px;
    font-family: 'DM Sans', sans-serif;
    color: var(--gray-700);
    background: white;
    transition: all 0.2s ease;
    min-width: 140px;
}
input[type="date"]:focus {
    outline: none;
    border-color: var(--coral-400);
    box-shadow: 0 0 0 3px rgba(255, 87, 51, 0.08);
}
.date-range-picker {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--gray-50);
    padding: 8px 16px;
    border-radius: 12px;
    border: 1px solid var(--gray-200);
}
.date-range-label {
    font-size: 12px;
    color: var(--gray-600);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.date-separator { color: var(--gray-400); font-weight: 300; font-size: 14px; }

.number-large, .number, .num, td.num { font-variant-numeric: tabular-nums; }

.chart-container { position: relative; height: 280px; padding: 20px; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track  { background: var(--gray-100); border-radius: 4px; }
::-webkit-scrollbar-thumb  { background: var(--gray-300); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ---- Przełączniki metryk ---- */
.metric-toggle {
    padding: 8px 16px;
    border-radius: 8px;
    border: 2px solid var(--gray-200);
    background: white;
    color: var(--gray-600);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.metric-toggle:hover {
    border-color: var(--coral-300);
    background: var(--coral-50);
    color: var(--coral-600);
}
.metric-toggle.active {
    border-color: var(--coral-500);
    background: var(--coral-500);
    color: white;
    box-shadow: 0 4px 12px rgba(255, 87, 51, 0.25);
}

/* ---- Sortowalne nagłówki ---- */
.sortable { cursor: pointer; user-select: none; transition: all 0.2s ease; position: relative; }
.sortable:hover { background: var(--gray-100); color: var(--coral-600); }
.sortable.active { color: var(--coral-600); background: var(--coral-50); }
.sort-icon { margin-left: 6px; font-size: 12px; opacity: 0.5; }
.sortable.active .sort-icon { opacity: 1; }

/* ---- Range slider ---- */
.range-slider-container { position: relative; height: 50px; padding-top: 30px; }
.range-slider {
    position: absolute; width: 100%; height: 6px;
    background: transparent; pointer-events: none;
    -webkit-appearance: none; top: 30px;
}
.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none; pointer-events: all;
    width: 20px; height: 20px;
    background: var(--coral-500); border-radius: 50%; cursor: pointer;
    box-shadow: 0 2px 6px rgba(255, 87, 51, 0.3); border: 3px solid white;
    transition: all 0.2s ease;
}
.range-slider::-webkit-slider-thumb:hover { background: var(--coral-600); transform: scale(1.1); }
.range-slider::-moz-range-thumb {
    pointer-events: all; width: 20px; height: 20px;
    background: var(--coral-500); border-radius: 50%; cursor: pointer;
    box-shadow: 0 2px 6px rgba(255, 87, 51, 0.3); border: 3px solid white;
}
.range-slider-track {
    position: absolute; top: 30px; width: 100%; height: 6px;
    background: var(--gray-200); border-radius: 3px;
}
.range-slider-range {
    position: absolute; top: 30px; height: 6px;
    background: linear-gradient(90deg, var(--coral-500), var(--coral-300));
    border-radius: 3px;
}

/* ---- Mostki dla legacy klas/elementów (przyciski, linki, focus) ---- */
a { color: var(--coral-600); }
button, .btn,
input:not([type="date"]):not([type="checkbox"]):not([type="radio"]):focus,
select:focus, textarea:focus {
    /* focus ring spójny z guide */
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--coral-400);
    box-shadow: 0 0 0 4px rgba(255, 87, 51, 0.08);
}
