/* =========================================================
   Unfold Admin Overrides
   ========================================================= */

/* ---------- Form field borders ---------- */
.change-form input[type="text"],
.change-form input[type="email"],
.change-form input[type="number"],
.change-form input[type="url"],
.change-form input[type="password"],
.change-form input[type="date"],
.change-form input[type="datetime-local"],
.change-form input[type="time"],
.change-form input[type="search"],
.change-form input[type="tel"],
.change-form select,
.change-form textarea,
.change-form .vTextField,
.change-form .vLargeTextField,
.change-form .vURLField,
.change-form .vIntegerField,
.change-form .vDateField,
.change-form .vTimeField,
.change-form .prepopulated_field input,
.change-form .vCharField,
.change-form .vForeignKeyRawIdAdminField {
    border: 1px solid #e5e7eb !important;
    background-color: #fff !important;
    padding: 0.375rem 0.5rem !important;
    border-radius: 0.375rem !important;
}

/* Dark mode field borders — with subtle Blueish-violet accent */
.dark .change-form input[type="text"],
.dark .change-form input[type="email"],
.dark .change-form input[type="number"],
.dark .change-form input[type="url"],
.dark .change-form input[type="password"],
.dark .change-form input[type="date"],
.dark .change-form input[type="datetime-local"],
.dark .change-form input[type="time"],
.dark .change-form input[type="search"],
.dark .change-form input[type="tel"],
.dark .change-form select,
.dark .change-form textarea,
.dark .change-form .vTextField,
.dark .change-form .vLargeTextField,
.dark .change-form .vURLField,
.dark .change-form .vIntegerField,
.dark .change-form .vDateField,
.dark .change-form .vTimeField {
    border-color: #374151 !important;
    background-color: #1f2937 !important;
    color: #f3f4f6 !important;
}

.dark .change-form input:focus,
.dark .change-form select:focus,
.dark .change-form textarea:focus {
    border-color: #6983c0 !important;
    box-shadow: 0 0 0 2px rgba(105, 131, 192, 0.2) !important;
}

/* Focus states */
.change-form input:focus,
.change-form select:focus,
.change-form textarea:focus {
    outline: none !important;
    box-shadow: 0 0 0 2px var(--color-primary-200, rgba(59,130,246,0.25)) !important;
    border-color: var(--color-primary-500, #3b82f6) !important;
}

/* Readonly fields */
.change-form input[readonly],
.change-form input[readonly="readonly"],
.change-form textarea[readonly],
.change-form textarea[readonly="readonly"],
#agreement-wizard input[readonly] {
    border-width: 1px !important;
    border-style: solid !important;
    border-color: var(--color-base-200, #e5e7eb) !important;
    background-color: var(--color-base-50, #f9fafb) !important;
}

.dark .change-form input[readonly],
.dark .change-form textarea[readonly],
.dark #agreement-wizard input[readonly] {
    border-color: var(--color-base-700, #374151) !important;
    background-color: var(--color-base-800, #1f2937) !important;
    color: var(--color-base-300, #d1d5db) !important;
}

/* Tailwind 4 (preflight Unfolda) zostawia przyciskom kursor domyślny — klikalne elementy dostają „łapkę”.
   Warstwa base, żeby klasy cursor-* Tailwinda (utilities) nadal wygrywały. */
@layer base {
    button:not(:disabled),
    [role="button"]:not([aria-disabled="true"]),
    input[type="submit"]:not(:disabled),
    input[type="button"]:not(:disabled),
    input[type="reset"]:not(:disabled),
    input[type="checkbox"]:not(:disabled),
    input[type="radio"]:not(:disabled),
    input[type="file"]:not(:disabled),
    label:has(> input[type="checkbox"], > input[type="radio"]),
    select:not(:disabled),
    summary,
    a[href],
    [\@click],
    [x-on\:click],
    [onclick],
    .select2-selection,
    .select2-results__option--selectable {
        cursor: pointer;
    }
}

/* Edycja wybranego obiektu (django-addanother) — bez wybranej wartości link nie ma href */
.related-widget-wrapper a.change-related:not([href]) {
    opacity: 0.4;
    pointer-events: none;
}

/* Help text */
.change-form .help,
.change-form .field-help {
    color: #6b7280 !important;
    font-size: 0.8125rem !important;
}


/* =========================================================
   Dashboard — responsive layout
   (we use named CSS classes everywhere so we don't rely on
   Tailwind responsive prefixes that may not be in Unfold's bundle)
   ========================================================= */

/* ── Outer two-column layout ─────────────────────────────── */

.dashboard-layout {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: stretch;
    width: 100%;
}

.dashboard-main {
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.dashboard-history {
    width: 100%;
    flex-shrink: 0;
}

/* History scroll: no padding (handled by activity-log-list inside),
   no height cap on mobile — just flows with the page */
.dashboard-history__scroll {
    padding: 0;
}

/* Side-by-side layout kicks in at 1600 px.
   Unfold's sidebar is ~288 px wide and appears at ~1024 px.
   At 1600 px: 1600 - 288 (sidebar) - 304 (history) - gaps ≈ 960 px for
   the main content — comfortable for three KPI cards with the sidebar open.
   Below 1600 px the history panel drops below the main content. */
@media (min-width: 1600px) {
    .dashboard-layout {
        flex-direction: row;
        align-items: flex-start;
    }
    .dashboard-main {
        flex: 1;
        width: auto;
    }
    .dashboard-history {
        width: 19rem;        /* 304 px */
        position: sticky;
        top: 1rem;
    }
    .dashboard-history__scroll {
        overflow-y: auto;
        max-height: calc(100vh - 6rem);
    }
}

@media (min-width: 1536px) {
    .dashboard-history { width: 22rem; }   /* 352 px on large monitors */
}

@media (min-width: 1920px) {
    .dashboard-history { width: 26rem; }   /* 416 px on wide/4K screens */
}


/* ── Role workspaces: tabs, six shortcuts, three cards ───────
   Layout follows the workspace's own width (container queries), so it holds
   with the sidebar open or closed and with the history column beside it.
   Six shortcuts are always a full grid: 1×6, 2×3 or 3×2 — never a stray tile. */

.workspaces {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.workspace {
    container-type: inline-size;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.workspace__title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6b7280;
}

.workspace-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.25rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    background: #f9fafb;
    align-self: flex-start;
}
.dark .workspace-tabs {
    border-color: #1f2937;
    background: #0b0f14;
}

.workspace-tab {
    flex: 1 1 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    border-radius: 0.55rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #6b7280;
    transition: background 150ms ease, color 150ms ease;
}
.workspace-tab .material-symbols-outlined { font-size: 1.15rem; }
.workspace-tab:hover { color: #1d2647; }
.dark .workspace-tab:hover { color: #e5e7eb; }

.workspace-tab--active {
    background: #ffffff;
    color: #1d2647;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}
.dark .workspace-tab--active {
    background: #1f2937;
    color: #f9fafb;
}

.workspace-tab__badge {
    min-width: 1.25rem;
    padding: 0 0.35rem;
    border-radius: 9999px;
    background: #f59e0b;
    color: #ffffff;
    font-size: 0.7rem;
    line-height: 1.25rem;
    text-align: center;
}

.workspace-actions {
    display: grid;
    gap: 0.5rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@container (min-width: 26rem) {
    .workspace-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@container (min-width: 50rem) {
    .workspace-actions { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

.workspace-cards {
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(0, 1fr);
}

@container (min-width: 52rem) {
    .workspace-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ── Cards ───────────────────────────────────────────────── */

.dashboard-card {
    --card-color: #6983c0;
    display: flex;
    flex-direction: column;
    border-radius: 0.875rem;
    border: 1px solid #e5e7eb;
    border-left: 4px solid var(--card-color);
    background: #ffffff;
    padding: 1.25rem 1.25rem 1rem;
    color: inherit;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.07);
    transition: transform 150ms ease, box-shadow 150ms ease;
    cursor: pointer;
}

.dark .dashboard-card {
    background: #0f1419;
    border-color: #1f2937;
    /* Deep blue disappears on a dark background; lighten every accent alike. */
    border-left-color: color-mix(in srgb, var(--card-color) 70%, #ffffff);
}

.dashboard-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.1);
}

.dark .dashboard-card:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.dashboard-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.dashboard-card__badge {
    display: inline-flex;
    border-radius: 9999px;
    padding: 0.25rem 0.625rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    background: var(--card-color);
    color: #ffffff;
}

.dark .dashboard-card__badge {
    background: color-mix(in srgb, var(--card-color) 70%, #ffffff);
    color: #0f1419;
}

.dashboard-card__icon {
    font-size: 1.5rem;
    opacity: 0.2;
    user-select: none;
}

.dashboard-card__value {
    margin-top: 0.75rem;
    font-size: 2rem;
    line-height: 1.1;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: #111827;
}

.dark .dashboard-card__value {
    color: #f9fafb;
}

.dashboard-card__value--attention,
.dark .dashboard-card__value--attention {
    color: #b45309;
}

.dashboard-card__description {
    margin-top: 0.35rem;
    font-size: 0.8rem;
    line-height: 1.45;
    color: #6b7280;
}

.dark .dashboard-card__description {
    color: #9ca3af;
}

.dashboard-card__lines {
    margin-top: auto;
    padding-top: 0.75rem;
}

.dashboard-line {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 0.3rem 0;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    font-size: 0.8rem;
    color: #374151;
}

.dark .dashboard-line {
    border-top-color: rgba(255, 255, 255, 0.08);
    color: #d1d5db;
}

.dashboard-line strong {
    flex-shrink: 0;
    white-space: nowrap;
    font-weight: 600;
}

.dashboard-line__label {
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

a.dashboard-line__label:hover {
    color: var(--color-primary-600, #2563eb);
    text-decoration: underline;
}

.dashboard-line--attention strong { color: #b45309; }
.dashboard-line--attention strong::before {
    content: "";
    display: inline-block;
    width: 0.4rem;
    height: 0.4rem;
    margin-right: 0.35rem;
    border-radius: 9999px;
    background: #f59e0b;
    vertical-align: middle;
}

.dark .dashboard-line--attention strong { color: #fbbf24; }

/* =========================================================
   Dashboard – "Wszystkie moduły" collapsible toggle
   ========================================================= */

.modules-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    cursor: pointer;
    text-align: left;
    transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}
.dark .modules-toggle {
    border-color: #1f2937;
    background: #0f1419;
    border-left: 3px solid transparent;
}
.modules-toggle:hover { background: #f9fafb; }
.dark .modules-toggle:hover {
    background: #1a212b;
    border-left-color: #6983c0;
    box-shadow: 0 2px 8px rgba(105, 131, 192, 0.1);
}

.modules-toggle__label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
}
.dark .modules-toggle__label { color: #d1d5db; }

.modules-toggle__icon { color: #9ca3af; }


/* =========================================================
   Dashboard – Activity log panel
   ========================================================= */

.activity-log-panel {
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}
.dark .activity-log-panel {
    border-color: #1f2937;
    background: #0f1419;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    border-top: 3px solid #6983c0;
}

.activity-log-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e5e7eb;
}
.dark .activity-log-header { border-color: #1f2937; }

.activity-log-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
}
.dark .activity-log-title { color: #f0f9ff; }

.activity-log-title-icon {
    font-size: 1rem !important;
    color: #9ca3af;
}
.dark .activity-log-title-icon {
    color: #6983c0;
}

.activity-log-all-link {
    font-size: 0.75rem;
    color: #9ca3af;
    text-decoration: none;
    transition: color 150ms ease;
}
.activity-log-all-link:hover { color: var(--color-primary-500, #44577a); }
.dark .activity-log-all-link { color: #9ca3af; }
.dark .activity-log-all-link:hover { color: #a0b2d8; }

.activity-log-empty {
    font-size: 0.75rem;
    color: #9ca3af;
    padding: 1rem 0;
    text-align: center;
}
.dark .activity-log-empty { color: #6b7280; }

.activity-log-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.75rem;
}


/* ── Activity log items ──────────────────────────────────── */

.activity-item {
    border-left: 3px solid transparent;
    border-radius: 0 6px 6px 0;
    padding: 0.45rem 0.7rem;
}

.activity-item__row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.activity-item__icon {
    font-size: 1rem !important;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.activity-item__content {
    flex: 1;
    min-width: 0;
}

.activity-item__title {
    font-size: 0.8125rem;
    font-weight: 500;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #1f2937;
    text-decoration: none;
    transition: color 150ms ease;
}
.dark .activity-item__title { color: #e5e7eb; }
.activity-item__title:hover { color: var(--color-primary-500, #44577a); }
.dark .activity-item__title:hover { color: #a0b2d8; }

.activity-item__meta {
    font-size: 0.7rem;
    color: #9ca3af;
    display: block;
    margin-top: 0.15rem;
    line-height: 1.4;
}
.dark .activity-item__meta { color: #6b7280; }


/* Action-type colours */

.activity-item--add    { border-left-color: #6aab8a; background: rgba(106,171,138,0.08); }
.activity-item--edit   { border-left-color: #c4a050; background: rgba(196,160,80, 0.08); }
.activity-item--delete { border-left-color: #c47070; background: rgba(196,112,112,0.08); }
.activity-item--other  { border-left-color: #a0aab8; background: rgba(160,170,184,0.08); }

.dark .activity-item--add    { background: rgba(106,171,138,0.14); }
.dark .activity-item--edit   { background: rgba(196,160,80, 0.14); }
.dark .activity-item--delete { background: rgba(196,112,112,0.14); }
.dark .activity-item--other  { background: rgba(160,170,184,0.14); }

.activity-item--add    .activity-item__icon { color: #6aab8a; }
.activity-item--edit   .activity-item__icon { color: #c4a050; }
.activity-item--delete .activity-item__icon { color: #c47070; }
.activity-item--other  .activity-item__icon { color: #a0aab8; }


/* =========================================================
   Dashboard – Quick Access Buttons
   ========================================================= */

.dashboard-quicklink {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 1rem 0.5rem;
    border-radius: 0.75rem;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    color: #374151;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    line-height: 1.3;
    transition: background 150ms ease, color 150ms ease, border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.dark .dashboard-quicklink {
    background: #0f1419;
    border-color: #1f2937;
    color: #d1d5db;
}

.dashboard-quicklink:hover {
    background: var(--color-primary-50, #eff6ff);
    border-color: var(--color-primary-300, #93c5fd);
    color: var(--color-primary-700, #1d4ed8);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.12);
    text-decoration: none;
}

.dark .dashboard-quicklink:hover {
    background: rgba(105, 131, 192, 0.15);
    border-color: #6983c0;
    color: #a0b2d8;
    box-shadow: 0 4px 12px rgba(105, 131, 192, 0.25);
}

.dashboard-quicklink .material-symbols-outlined {
    font-size: 1.6rem;
    opacity: 0.7;
    transition: opacity 150ms ease;
}

.dashboard-quicklink:hover .material-symbols-outlined {
    opacity: 1;
}

/* =========================================================
   Dashboard – search
   ========================================================= */

.dashboard-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    background: #ffffff;
}
.dashboard-search input {
    flex: 1;
    border: 0;
    outline: none;
    background: transparent;
    font-size: 0.95rem;
    padding: 0.25rem 0;
}
.dark .dashboard-search {
    border-color: #1f2937;
    background: #0f1419;
}
