/* ── Variables & base ──────────────────────────────────────────────────────── */
:root {
    --sidebar-w: 220px;

    /* Brand color: Indigo */
    --bs-primary:             #4f46e5;
    --bs-primary-rgb:         79, 70, 229;
    --bs-link-color:          #4f46e5;
    --bs-link-color-rgb:      79, 70, 229;
    --bs-link-hover-color:    #4338ca;
}
body  { background: #f8f9fb; }

/* ── btn-primary ───────────────────────────────────────────────────────────── */
.btn-primary {
    --bs-btn-bg:                    #4f46e5;
    --bs-btn-border-color:          #4f46e5;
    --bs-btn-hover-bg:              #4338ca;
    --bs-btn-hover-border-color:    #4338ca;
    --bs-btn-active-bg:             #3730a3;
    --bs-btn-active-border-color:   #3730a3;
    --bs-btn-focus-shadow-rgb:      79, 70, 229;
    --bs-btn-disabled-bg:           #4f46e5;
    --bs-btn-disabled-border-color: #4f46e5;
}
.btn-outline-primary {
    --bs-btn-color:                 #4f46e5;
    --bs-btn-border-color:          #4f46e5;
    --bs-btn-hover-bg:              #4f46e5;
    --bs-btn-hover-border-color:    #4f46e5;
    --bs-btn-active-bg:             #4338ca;
    --bs-btn-active-border-color:   #4338ca;
    --bs-btn-focus-shadow-rgb:      79, 70, 229;
}

/* ── btn-outline-secondary — lepszy kontrast w dark mode ───────────────────── */
[data-bs-theme="dark"] .btn-outline-secondary {
    --bs-btn-color:              #9ca3af;
    --bs-btn-border-color:       #4b5563;
    --bs-btn-hover-bg:           #2a2d35;
    --bs-btn-hover-color:        #e2e5ea;
    --bs-btn-hover-border-color: #6b7280;
    --bs-btn-active-bg:          #1e2128;
    --bs-btn-active-border-color:#6b7280;
}

/* ── Bootstrap 5.3 dark theme overrides ────────────────────────────────────── */
[data-bs-theme="dark"] {
    --bs-body-bg:           #272b34;
    --bs-body-color:        #e2e5ea;
    --bs-secondary-bg:      #1a1d22;
    --bs-tertiary-bg:       #1e2128;
    --bs-border-color:      #2a2d35;
    --bs-border-color-translucent: rgba(255,255,255,.08);
    --bs-card-bg:           #1a1d22;
    --bs-card-cap-bg:       #16181e;
    --bs-card-border-color: #2a2d35;
    --bs-table-bg:          transparent;
    --bs-table-striped-bg:  rgba(255,255,255,.04);
    --bs-table-border-color:#2a2d35;
    --bs-input-bg:          #0d0f13;
    --bs-form-select-bg:    #0d0f13;
}
[data-bs-theme="dark"] body { background: var(--bs-body-bg); }

[data-bs-theme="dark"] .card {
    --bs-card-bg: #1a1d22;
    background-color: #1a1d22 !important;
    box-shadow: 0 0 0 1px rgba(255,255,255,.07), 0 2px 8px rgba(0,0,0,.45) !important;
}
[data-bs-theme="dark"] .card-header,
[data-bs-theme="dark"] .card-footer {
    --bs-card-cap-bg: #16181e;
    background-color: #16181e !important;
}

/* Card-header w light mode — taki sam odcień jak thead.table-active */
[data-bs-theme="light"] .card-header,
[data-bs-theme="light"] .card-footer {
    background-color: var(--bs-table-active-bg) !important;
}

/* Nadpisanie bg-white w dark mode (card-header używa tej klasy) */
[data-bs-theme="dark"] .bg-white { background-color: var(--bs-card-cap-bg) !important; }
[data-bs-theme="dark"] .card-footer.bg-white { background-color: var(--bs-card-cap-bg) !important; }


/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 220px;
    background: #1a1d22;
    overflow-y: auto; overflow-x: hidden;
    z-index: 100;
}
.sidebar.collapsed { width: 64px; }

.sidebar .brand        { padding: 1.5rem 1.25rem; border-bottom: 1px solid #2a2d35; }
.sidebar .brand-name   { font-size: .95rem; font-weight: 700; color: #fff; }
.sidebar .brand-sub    { font-size: .72rem; color: #6c7380; text-transform: uppercase; letter-spacing: .06em; }

.sidebar .nav-link {
    color: #9ca3af; padding: .6rem 1.25rem; border-radius: 8px;
    margin: 2px 8px; font-size: .875rem;
    display: flex; align-items: center; gap: .5rem;
}
.sidebar .nav-link:hover,
.sidebar .nav-link.active { background: #2a2d35; color: #fff; }
.sidebar .nav-section  { font-size: .72rem; color: #fff; text-transform: uppercase; letter-spacing: .08em; padding: 1rem 1.25rem .25rem; }

/* Collapsed state */
.sidebar.collapsed .sidebar-text      { display: none !important; }
.sidebar.collapsed .sidebar-brand-info { display: none; }
.sidebar.collapsed .nav-section       { display: none; }
.sidebar.collapsed .brand             { justify-content: center !important; padding: 1rem .5rem; }
.sidebar.collapsed .nav-link          { justify-content: center; gap: 0; padding: .6rem; margin: 2px 4px; font-size: 1rem; }
.sidebar.collapsed .sidebar-footer .d-flex {
    flex-direction: column; align-items: center; justify-content: center; gap: .5rem; padding: .75rem 0;
}

/* Toggle button */
.sidebar-toggle {
    background: none; border: none; color: #6c7380;
    cursor: pointer; padding: 4px 6px; border-radius: 6px;
    line-height: 1; flex-shrink: 0; font-size: 1rem;
}
.sidebar-toggle:hover              { color: #fff; background: #2a2d35; }
.sidebar-toggle i                  { display: block; transition: transform .25s ease; }
.sidebar.collapsed .sidebar-toggle i { transform: rotate(180deg); }

/* ── Layout ────────────────────────────────────────────────────────────────── */
.main-content { margin-left: 220px; min-height: 100vh; }
body.sidebar-collapsed .main-content { margin-left: 64px; }

.topbar {
    background: var(--bs-card-bg, #fff);
    border-bottom: 1px solid var(--bs-border-color, #e5e7eb);
    padding: .875rem 1.5rem; position: sticky; top: 0; z-index: 50;
}

/* ── Tom Select fixes ──────────────────────────────────────────────────────── */
.ts-wrapper.form-select,
.ts-wrapper.form-select-sm { padding: 0 !important; }

/* Wrapper: flex z centralnym wyrównaniem pionowym */
.ts-wrapper.form-select { align-items: center !important; }

/* Kontrolka: symetryczny padding i wyrównanie do środka */
.ts-wrapper.form-select-sm .ts-control,
.ts-wrapper.form-select-sm.has-items .ts-control {
    padding: .25rem .5rem !important;
}
/* Wewnętrzne elementy: baseline → middle */
.ts-wrapper .ts-control > * { vertical-align: middle !important; }

/* Tom Select dark mode */
[data-bs-theme="dark"] .ts-control {
    background: #0d0f13 !important;
    border-color: #2a2d35 !important;
    color: #e2e5ea;
}
[data-bs-theme="dark"] .ts-dropdown {
    background: #1a1d22;
    border-color: #2a2d35;
    color: #e2e5ea;
}
[data-bs-theme="dark"] .ts-dropdown .option { color: #e2e5ea; }
[data-bs-theme="dark"] .ts-dropdown .active { background: #2d3039; color: #fff; }
[data-bs-theme="dark"] .ts-dropdown .option:hover { background: #2d3039; }
[data-bs-theme="dark"] .ts-control > input { color: #e2e5ea !important; }
[data-bs-theme="dark"] .focus .ts-control { box-shadow: 0 0 0 .25rem rgba(79,70,229,.25) !important; border-color: #4f46e5 !important; }

/* ── Info tooltip icon ─────────────────────────────────────────────────────── */
.info-tip {
    cursor: help;
    font-size: .8rem;
    vertical-align: middle;
    opacity: .55;
    transition: opacity .15s;
}
.info-tip:hover { opacity: 1; }

/* ── Stat cards (dashboard / settings) ─────────────────────────────────────── */
.stat-card {
    border-radius: 10px;
    border: 1px solid var(--bs-border-color, #e5e7eb);
    background: var(--bs-card-bg, #fff);
}
.stat-card .stat-icon {
    width: 44px; height: 44px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
}

/* ── Badges (wspólne) ──────────────────────────────────────────────────────── */
.badge-success  { background: #d1fae5; color: #065f46; }
.badge-failed   { background: #fee2e2; color: #991b1b; }
.badge-partial  { background: #fef3c7; color: #92400e; }
.badge-running  { background: #e0e7ff; color: #3730a3; }
.badge-pending  { background: #f3f4f6; color: #374151; }
.badge-muted    { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; }

[data-bs-theme="dark"] .badge-success  { background: #064e3b; color: #6ee7b7; }
[data-bs-theme="dark"] .badge-failed   { background: #450a0a; color: #fca5a5; }
[data-bs-theme="dark"] .badge-partial  { background: #451a03; color: #fcd34d; }
[data-bs-theme="dark"] .badge-running  { background: #1e1b4b; color: #a5b4fc; }
[data-bs-theme="dark"] .badge-pending  { background: #1a1d23; color: #9ca3af; }
[data-bs-theme="dark"] .badge-muted    { background: #2a2d35; color: #c9cdd4; border-color: #3a3d47; }

/* ── Nav tabs — wrapper z poziomym scrollem ─────────────────────────────────── */
.wh-tabs-nav {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    background: var(--bs-card-cap-bg, #f8f9fa);
    border: 1px solid var(--bs-border-color);
    border-bottom: none;
    border-radius: 10px 10px 0 0;
}
.wh-tabs-nav::-webkit-scrollbar { display: none; }
.wh-tabs-nav + .tab-content {
    border: 1px solid var(--bs-border-color);
    border-top: none;
    border-radius: 0 0 10px 10px;
    padding: 1.5rem;
    background: var(--bs-card-bg, #fff);
    margin-bottom: 1.5rem;
}
[data-bs-theme="dark"] .wh-tabs-nav + .tab-content {
    background: #21242c;
}

/* Nav-tabs dark mode */
[data-bs-theme="dark"] .nav-tabs {
    background: transparent;
    border-bottom-color: var(--bs-border-color);
    border-radius: 0;
    padding: .35rem .5rem 0;
    gap: .15rem;
}
[data-bs-theme="dark"] .nav-tabs .nav-link {
    color: #8b92a0;
    border-color: transparent;
    border-radius: 6px 6px 0 0;
    font-size: .875rem;
    white-space: nowrap;
}
[data-bs-theme="dark"] .nav-tabs .nav-link:hover:not(.disabled) {
    color: #e2e5ea;
    background: rgba(255,255,255,.06);
    border-color: transparent;
}
[data-bs-theme="dark"] .nav-tabs .nav-link.active {
    background: var(--bs-card-bg);
    border-color: var(--bs-border-color) var(--bs-border-color) var(--bs-card-bg);
    color: #fff;
    font-weight: 600;
}
[data-bs-theme="dark"] .nav-tabs .nav-link.disabled {
    color: #3d4252;
    opacity: .5;
}

/* ── Tabele ────────────────────────────────────────────────────────────────── */
.table-responsive { padding: 25px; }

/* Naprzemienne wiersze */
[data-bs-theme="dark"] .table tbody tr:nth-child(odd)  td,
[data-bs-theme="dark"] .table tbody tr:nth-child(odd)  th { background-color: rgba(0,0,0,.25) !important; }
[data-bs-theme="dark"] .table tbody tr:nth-child(even) td,
[data-bs-theme="dark"] .table tbody tr:nth-child(even) th { background-color: transparent !important; }
