/* ============================================================
   WebUp Platform — design system
   Spójny look dla klient.webup.pl: top-nav (klient), sidebar (admin)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; }

:root {
    /* Surfaces */
    --bg:           #F8FAFC;
    --surface:      #FFFFFF;
    --surface-2:    #F1F5F9;
    --surface-3:    #E2E8F0;
    --border:       #E2E8F0;
    --border-soft:  #EDF1F5;
    --border-strong:#CBD5E1;

    /* Text */
    --fg:            #0F172A;
    --fg-secondary:  #475569;
    --fg-muted:      #94A3B8;
    --fg-inverse:    #FFFFFF;

    /* Brand accent */
    --accent:        #F97316;
    --accent-hover:  #EA580C;
    --accent-soft:   #FFF7ED;
    --accent-fg:     #C2410C;

    /* Status */
    --success:       #10B981;
    --success-soft:  #ECFDF5;
    --success-fg:    #047857;

    --warn:          #F59E0B;
    --warn-soft:     #FFFBEB;
    --warn-fg:       #B45309;

    --info:          #3B82F6;
    --info-soft:     #EFF6FF;
    --info-fg:       #1D4ED8;

    --danger:        #EF4444;
    --danger-soft:   #FEF2F2;
    --danger-fg:     #B91C1C;

    /* Radii */
    --r-sm: 6px;
    --r:    10px;
    --r-lg: 14px;
    --r-xl: 18px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
    --shadow:    0 1px 3px rgba(15, 23, 42, .05), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-lg: 0 8px 24px rgba(15, 23, 42, .08), 0 2px 6px rgba(15, 23, 42, .04);

    /* Layout */
    --sidebar-w: 240px;
    --header-h:  56px;
}

html, body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--fg);
    font-feature-settings: "cv11", "ss01";
    -webkit-font-smoothing: antialiased;
}

/* ============================================================
   App shell — sidebar + main (admin/superadmin)
   ============================================================ */

.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 30;
}
.app-sidebar__brand {
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: .625rem;
    padding: 0 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--fg);
    font-weight: 600;
    font-size: .9375rem;
    text-decoration: none;
}
.app-sidebar__brand img { height: 24px; }
.app-sidebar__section {
    padding: .75rem .5rem;
    border-bottom: 1px solid var(--border-soft);
}
.app-sidebar__section:last-child { border-bottom: 0; }
.app-sidebar__title {
    padding: .25rem .625rem .5rem;
    text-transform: uppercase;
    font-size: .6875rem;
    font-weight: 600;
    color: var(--fg-muted);
    letter-spacing: .04em;
}
.app-sidebar__link {
    display: flex;
    align-items: center;
    gap: .625rem;
    padding: .5rem .625rem;
    border-radius: var(--r-sm);
    color: var(--fg-secondary);
    font-size: .875rem;
    font-weight: 500;
    text-decoration: none;
    transition: background .12s, color .12s;
    margin-bottom: 1px;
}
.app-sidebar__link svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .8; }
.app-sidebar__link:hover { background: var(--surface-2); color: var(--fg); }
.app-sidebar__link--active {
    background: var(--accent-soft);
    color: var(--accent-fg);
}
.app-sidebar__link--active svg { opacity: 1; }
.app-sidebar__user {
    margin-top: auto;
    padding: .75rem 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: .625rem;
}

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.app-topbar {
    height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 20;
}
.app-topbar__title {
    font-size: .9375rem;
    font-weight: 600;
    color: var(--fg);
    display: flex;
    align-items: center;
    gap: .5rem;
}
.app-topbar__crumb {
    color: var(--fg-muted);
    text-decoration: none;
    font-weight: 500;
}
.app-topbar__crumb:hover { color: var(--fg); }
.app-topbar__sep { color: var(--fg-muted); }

.app-content { padding: 1.5rem; max-width: 1280px; width: 100%; margin: 0 auto; }

/* Mobile shell — sidebar collapses */
@media (max-width: 768px) {
    .app-shell { flex-direction: column; }
    .app-sidebar {
        width: 100%;
        height: auto;
        position: static;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }
    .app-sidebar__user { display: none; }
}

/* ============================================================
   Top nav (client side, simpler)
   ============================================================ */

.client-nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 30;
}
.client-nav__inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: .625rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.client-nav__brand img { height: 28px; }

.client-nav__links { display: flex; align-items: center; gap: .25rem; }
.client-nav__link {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    padding: .4375rem .75rem;
    border-radius: var(--r-sm);
    color: var(--fg-secondary);
    font-size: .875rem;
    font-weight: 500;
    text-decoration: none;
    transition: background .12s, color .12s;
}
.client-nav__link svg { width: 15px; height: 15px; opacity: .85; }
.client-nav__link:hover { background: var(--surface-2); color: var(--fg); }
.client-nav__link--active {
    background: var(--accent-soft);
    color: var(--accent-fg);
}
.client-nav__divider { width: 1px; height: 18px; background: var(--border); margin: 0 .375rem; }

@media (max-width: 768px) {
    .client-nav__links { display: none; }
    .client-nav__links--mobile {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        padding: .5rem;
        border-top: 1px solid var(--border);
        gap: 2px;
    }
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .5rem 1rem;
    border-radius: var(--r);
    font-size: .875rem;
    font-weight: 600;
    line-height: 1.25;
    cursor: pointer;
    text-decoration: none;
    border: 1px solid transparent;
    transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
    white-space: nowrap;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }
.btn--sm { padding: .375rem .75rem; font-size: .8125rem; border-radius: var(--r-sm); }
.btn--lg { padding: .625rem 1.25rem; font-size: .9375rem; }

/* Standalone button classes (działają BEZ .btn — backward-compat z legacy stronami) */
.btn-primary, .btn-secondary, .btn-ghost, .btn-danger, .btn-success {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .5rem 1rem;
    border-radius: var(--r);
    font-size: .875rem;
    font-weight: 600;
    line-height: 1.25;
    cursor: pointer;
    text-decoration: none;
    border: 1px solid transparent;
    transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
    white-space: nowrap;
}
.btn-primary svg, .btn-secondary svg, .btn-ghost svg, .btn-danger svg, .btn-success svg { width: 15px; height: 15px; }

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-secondary {
    background: var(--surface);
    color: var(--fg);
    border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--surface-2); }

.btn-ghost {
    background: transparent;
    color: var(--fg-secondary);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--fg); }

.btn-danger {
    background: var(--danger-soft);
    color: var(--danger-fg);
}
.btn-danger:hover { background: #FEE2E2; }

.btn-success {
    background: var(--success-soft);
    color: var(--success-fg);
}
.btn-success:hover { background: #D1FAE5; }

/* Modyfikatory rozmiaru działają też dla standalone buttonów */
.btn-primary.btn--sm, .btn-secondary.btn--sm, .btn-ghost.btn--sm, .btn-danger.btn--sm, .btn-success.btn--sm {
    padding: .375rem .75rem;
    font-size: .8125rem;
    border-radius: var(--r-sm);
}

/* legacy alias — preserved for unmigrated pages */
.btn-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .5rem 1rem;
    border-radius: var(--r);
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    background: var(--surface);
    color: var(--fg);
    border: 1px solid var(--border-strong);
    transition: background .12s, border-color .12s;
}
.btn-outline:hover { background: var(--surface-2); }

/* ============================================================
   Inputs
   ============================================================ */

.input-field, .input-field:where(textarea, select) {
    display: block;
    width: 100%;
    padding: .5rem .75rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    font-size: .875rem;
    color: var(--fg);
    background: var(--surface);
    outline: none;
    transition: border-color .12s, box-shadow .12s;
    line-height: 1.4;
    font-family: inherit;
}
.input-field::placeholder { color: var(--fg-muted); }
.input-field:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, .15);
}
.input-field:disabled { background: var(--surface-2); color: var(--fg-muted); cursor: not-allowed; }

textarea.input-field { resize: vertical; min-height: 80px; }

.input-label {
    display: block;
    font-size: .8125rem;
    font-weight: 500;
    color: var(--fg-secondary);
    margin-bottom: .25rem;
}
.input-help {
    display: block;
    font-size: .75rem;
    color: var(--fg-muted);
    margin-top: .25rem;
}
.input-error {
    display: block;
    font-size: .75rem;
    color: var(--danger-fg);
    margin-top: .25rem;
}

/* ============================================================
   Cards
   ============================================================ */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
}
.card--hoverable { transition: border-color .12s, box-shadow .12s; }
.card--hoverable:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.card__header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.card__title { font-size: .9375rem; font-weight: 600; color: var(--fg); }
.card__body { padding: 1.25rem; }
.card__footer {
    padding: .75rem 1.25rem;
    border-top: 1px solid var(--border-soft);
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .5rem;
}

/* ============================================================
   Pills / status badges
   ============================================================ */

.pill {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .1875rem .5rem;
    border-radius: 99px;
    font-size: .6875rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: .01em;
    white-space: nowrap;
}
.pill--neutral { background: var(--surface-2); color: var(--fg-secondary); }
.pill--success { background: var(--success-soft); color: var(--success-fg); }
.pill--warn    { background: var(--warn-soft);    color: var(--warn-fg); }
.pill--info    { background: var(--info-soft);    color: var(--info-fg); }
.pill--danger  { background: var(--danger-soft);  color: var(--danger-fg); }
.pill--accent  { background: var(--accent-soft);  color: var(--accent-fg); }

.pill__dot {
    width: 6px; height: 6px;
    border-radius: 99px;
    background: currentColor;
    opacity: .8;
}

/* Dot indicator (for unread, etc.) */
.dot {
    width: 8px; height: 8px;
    border-radius: 99px;
    background: var(--accent);
    flex-shrink: 0;
}
.dot--danger { background: var(--danger); }
.dot--info   { background: var(--info); }
.dot--success{ background: var(--success); }

/* Notification badge (for nav links) */
.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--danger);
    color: #fff;
    border-radius: 99px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
}

/* ============================================================
   Avatar
   ============================================================ */

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-3);
    color: var(--fg-secondary);
    border-radius: 99px;
    font-weight: 600;
    flex-shrink: 0;
    font-size: .75rem;
}
.avatar--sm { width: 24px; height: 24px; font-size: .6875rem; }
.avatar--md { width: 32px; height: 32px; font-size: .8125rem; }
.avatar--lg { width: 40px; height: 40px; font-size: .9375rem; }
.avatar--accent { background: var(--accent); color: #fff; }
.avatar--user   { background: #DBEAFE; color: var(--info-fg); }

/* ============================================================
   Step / progress
   ============================================================ */

.progress {
    width: 100%;
    height: 4px;
    background: var(--surface-3);
    border-radius: 99px;
    overflow: hidden;
}
.progress__bar {
    height: 100%;
    background: var(--accent);
    transition: width .3s ease;
}
.progress__bar--success { background: var(--success); }

.step-marker {
    width: 28px; height: 28px;
    border-radius: 99px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: .75rem;
    font-weight: 600;
    border: 2px solid var(--border-strong);
    background: var(--surface);
    color: var(--fg-muted);
}
.step-marker--active {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-fg);
}
.step-marker--done {
    border-color: var(--success);
    background: var(--success);
    color: #fff;
}
.step-marker--prog {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}
.step-marker--blocked {
    border-color: var(--danger);
    background: var(--danger-soft);
    color: var(--danger-fg);
}

/* ============================================================
   Tables (admin)
   ============================================================ */

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: .875rem;
}
.table th {
    text-align: left;
    font-weight: 500;
    color: var(--fg-muted);
    padding: .625rem 1rem;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.table th:first-child { border-top-left-radius: var(--r-lg); }
.table th:last-child  { border-top-right-radius: var(--r-lg); }
.table td {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border-soft);
    color: var(--fg);
    vertical-align: middle;
}
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: var(--surface-2); }

/* ============================================================
   Chat (preserved functionality, new look)
   ============================================================ */

.chat { display: flex; flex-direction: column; gap: .875rem; }

.chat-bubble {
    display: flex;
    gap: .5rem;
    align-items: flex-start;
    max-width: 80%;
    width: fit-content;
}
.chat-bubble--mine {
    margin-left: auto;
    flex-direction: row-reverse;
}
.chat-bubble__avatar { flex-shrink: 0; margin-top: .125rem; }
.chat-bubble__body {
    display: flex;
    flex-direction: column;
    gap: .1875rem;
    min-width: 0;
}
.chat-bubble--mine .chat-bubble__body { align-items: flex-end; }
.chat-bubble__meta {
    font-size: .6875rem;
    color: var(--fg-muted);
    display: flex;
    align-items: baseline;
    gap: .375rem;
    padding: 0 .25rem;
    line-height: 1.2;
}
.chat-bubble--mine .chat-bubble__meta { flex-direction: row-reverse; }
.chat-bubble__author {
    font-weight: 600;
    color: var(--fg-secondary);
}
.chat-bubble__msg {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: .5rem .75rem;
    font-size: .8125rem;
    color: var(--fg);
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.chat-bubble--mine .chat-bubble__msg {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    border-bottom-right-radius: 4px;
}
.chat-bubble:not(.chat-bubble--mine) .chat-bubble__msg {
    border-bottom-left-radius: 4px;
}
.chat-bubble--admin .chat-bubble__msg {
    background: var(--info-soft);
    border-color: #DBEAFE;
    color: var(--fg);
}
.chat-bubble__attach {
    margin-top: .375rem;
    font-size: .75rem;
}
.chat-bubble__attach img {
    max-width: 100%;
    max-height: 220px;
    border-radius: var(--r-sm);
    display: block;
    object-fit: cover;
}
.chat-bubble--mine .chat-bubble__attach a { color: rgba(255,255,255,.92); }
.chat-bubble__attach a {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Task collapse — chevron rotation */
.task-details summary { user-select: none; }
.task-details[open] .task-chevron { transform: rotate(180deg); }
.task-details[open] summary { background: var(--surface); }
.task-details summary::-webkit-details-marker { display: none; }

/* Done task — subtle */
.task-card:has(.task-details:not([open])) { background: var(--surface-2); }

.chat-composer {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-lg);
    overflow: hidden;
}
.chat-composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(249, 115, 22, .15); }
.chat-composer textarea {
    width: 100%;
    border: 0;
    outline: none;
    padding: .625rem .875rem;
    font-size: .875rem;
    font-family: inherit;
    resize: none;
    min-height: 64px;
    max-height: 220px;
    color: var(--fg);
    background: transparent;
}
.chat-composer__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .375rem .625rem;
    border-top: 1px solid var(--border-soft);
    background: var(--surface-2);
}
.chat-composer__file {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    font-size: .75rem;
    color: var(--fg-muted);
    cursor: pointer;
}
.chat-composer__file:hover { color: var(--fg-secondary); }
.chat-composer__file svg { width: 14px; height: 14px; }

/* ============================================================
   Choice cards (radio-as-card for action_type=choice)
   ============================================================ */

.choice-list { display: flex; flex-direction: column; gap: .5rem; }
.choice-card {
    border: 1.5px solid var(--border);
    border-radius: var(--r);
    background: var(--surface);
    overflow: hidden;
    transition: border-color .12s, background .12s;
}
.choice-card__btn {
    display: flex;
    align-items: center;
    gap: .75rem;
    width: 100%;
    padding: .625rem .875rem;
    background: transparent;
    border: 0;
    text-align: left;
    cursor: pointer;
    color: var(--fg);
    font-size: .875rem;
    font-weight: 500;
    transition: background .12s;
}
.choice-card__btn:hover { background: var(--surface-2); }
.choice-card__radio {
    width: 18px; height: 18px;
    border-radius: 99px;
    border: 2px solid var(--border-strong);
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: border-color .12s;
}
.choice-card__radio::after {
    content: '';
    width: 8px; height: 8px;
    border-radius: 99px;
    background: transparent;
    transition: background .12s;
}
.choice-card--selected { border-color: var(--accent); background: var(--accent-soft); }
.choice-card--selected .choice-card__radio { border-color: var(--accent); }
.choice-card--selected .choice-card__radio::after { background: var(--accent); }
.choice-card__detail {
    padding: .625rem .875rem .75rem 2.625rem;
    font-size: .8125rem;
    color: var(--fg-secondary);
    border-top: 1px solid var(--border);
    background: var(--surface);
    line-height: 1.5;
}

/* ============================================================
   Empty state
   ============================================================ */

.empty {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--fg-muted);
    font-size: .875rem;
}
.empty__icon {
    margin: 0 auto .5rem;
    width: 40px; height: 40px;
    opacity: .5;
}

/* ============================================================
   Misc / kept from old
   ============================================================ */

.badge-en {
    display: inline-block;
    font-size: .65rem;
    font-weight: 700;
    padding: .1rem .4rem;
    background: #DBEAFE;
    color: #1D4ED8;
    border-radius: .25rem;
    margin-left: .375rem;
    vertical-align: middle;
    letter-spacing: .05em;
}

.prose { line-height: 1.7; }
.prose h2 { font-size: 1.125rem; font-weight: 700; margin-top: 1.5rem; margin-bottom: .5rem; color: var(--fg); }
.prose h3 { font-size: 1rem; font-weight: 600; margin-top: 1.25rem; margin-bottom: .375rem; color: var(--fg-secondary); }
.prose p { margin-bottom: .875rem; }
.prose ul { list-style: disc; padding-left: 1.5rem; margin-bottom: .875rem; }
.prose ol { list-style: decimal; padding-left: 1.5rem; margin-bottom: .875rem; }
.prose li { margin-bottom: .25rem; }
.prose a { color: var(--accent-fg); text-decoration: underline; }
.prose strong { font-weight: 600; }
.prose code { font-size: .85em; background: var(--surface-2); padding: .1em .35em; border-radius: .25rem; }
.prose blockquote { border-left: 3px solid var(--accent); padding-left: 1rem; color: var(--fg-secondary); font-style: italic; margin: 1rem 0; }

video::-webkit-media-controls-download-button { display: none !important; }
video::-webkit-media-controls-enclosure { overflow: hidden !important; }
video { -webkit-user-select: none; user-select: none; }

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.aspect-video { aspect-ratio: 16 / 9; }
.rotate-180 { transform: rotate(180deg); }
