/*
 * CabaBase: system wizualny.
 * Granat (marka, zaufanie) + neutralne tło + jeden ciepły akcent wyłącznie dla CTA.
 * Czerwień tylko dla błędów. Zaokrąglenia 8 / 12 / 16 px, miękkie cienie zamiast ramek.
 */

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-display: swap;
    font-weight: 100 900;
    src: url("fonts/inter-latin-ext-wght-normal.ad4eb06671be.woff2") format('woff2-variations');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-display: swap;
    font-weight: 100 900;
    src: url("fonts/inter-latin-wght-normal.8e433c0592f7.woff2") format('woff2-variations');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    /* Marka */
    --cb-brand-900: #121a3d;
    --cb-brand-800: #1a2554;
    --cb-brand-700: #22306b;
    --cb-brand-600: #2e3f87;
    --cb-brand-100: #e4e8f6;
    --cb-brand-50: #f1f3fb;
    /* Akcent: tylko CTA (Dodaj pliki, Załóż konto, Wybierz plan) */
    --cb-accent: #c2410c;
    --cb-accent-hover: #9a3412;
    --cb-accent-soft: #fff1e8;
    /* Neutralne */
    --cb-bg: #f6f7f9;
    --cb-surface: #ffffff;
    --cb-surface-muted: #f9fafb;
    --cb-text: #1b2033;
    --cb-text-muted: #5b6275;
    --cb-text-subtle: #808799;
    --cb-line: #e7e9ef;
    /* Stany */
    --cb-success: #157347;
    --cb-success-soft: #e7f6ee;
    --cb-warning: #8a5a00;
    --cb-warning-soft: #fff6e0;
    --cb-danger: #b42318;
    --cb-danger-soft: #fdecea;
    --cb-info-soft: #eaf1fd;
    /* Kształt i głębia */
    --cb-radius-sm: 8px;
    --cb-radius: 12px;
    --cb-radius-lg: 16px;
    --cb-shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.05);
    --cb-shadow: 0 1px 2px rgba(17, 24, 39, 0.04), 0 4px 16px rgba(17, 24, 39, 0.06);
    --cb-shadow-lg: 0 2px 6px rgba(17, 24, 39, 0.05), 0 12px 32px rgba(17, 24, 39, 0.1);
    --cb-ease: cubic-bezier(0.2, 0.7, 0.2, 1);

    /* Bootstrap w barwach marki */
    --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --bs-body-color: var(--cb-text);
    --bs-body-bg: var(--cb-bg);
    --bs-secondary-color: var(--cb-text-muted);
    --bs-border-color: var(--cb-line);
    --bs-border-radius: var(--cb-radius-sm);
    --bs-border-radius-lg: var(--cb-radius);
    --bs-border-radius-xl: var(--cb-radius-lg);
    --bs-primary: var(--cb-brand-700);
    --bs-primary-rgb: 34, 48, 107;
    --bs-link-color: var(--cb-brand-600);
    --bs-link-color-rgb: 46, 63, 135;
    --bs-link-hover-color: var(--cb-brand-800);
    --bs-link-hover-color-rgb: 26, 37, 84;
    --bs-focus-ring-color: rgba(46, 63, 135, 0.25);
}

body {
    background: var(--cb-bg);
    color: var(--cb-text);
    font-feature-settings: 'cv11', 'ss01';
    -webkit-font-smoothing: antialiased;
    letter-spacing: -0.006em;
}

h1, h2, h3, h4, h5, .h1, .h2, .h3, .h4, .h5 {
    color: var(--cb-text);
    font-weight: 650;
    letter-spacing: -0.02em;
}

.h-page { font-size: 1.6rem; margin: 0; }
.text-muted, .text-body-secondary { color: var(--cb-text-muted) !important; }
.text-subtle { color: var(--cb-text-subtle); }
.small-caps {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--cb-text-subtle);
}

a { text-underline-offset: 2px; }

.icon { flex-shrink: 0; vertical-align: -0.15em; }

/* --- Układ aplikacji: boczna nawigacja + treść --- */

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

.sidebar {
    width: 248px;
    flex-shrink: 0;
    background: var(--cb-brand-900);
    color: #c9cfe6;
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.02em;
    text-decoration: none;
    padding: 4px 10px 20px;
}

.brand:hover { color: #fff; }

.brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: linear-gradient(140deg, #3b4fa8, #22306b);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.nav-section { margin-top: 18px; padding: 0 10px 6px; color: #7e88b0; }

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    color: #c9cfe6;
    border-radius: var(--cb-radius-sm);
    padding: 8px 10px;
    font-size: 0.93rem;
    font-weight: 500;
    transition: background-color 0.15s var(--cb-ease), color 0.15s var(--cb-ease);
}

.sidebar .nav-link:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.sidebar .nav-link.active { background: rgba(255, 255, 255, 0.1); color: #fff; }

.sidebar-footer {
    margin-top: auto;
    padding: 12px 10px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.85rem;
}

.sidebar-footer .workspace-name { color: #fff; font-weight: 600; }

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

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 32px;
    background: rgba(246, 247, 249, 0.85);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-search { flex: 1; max-width: 560px; position: relative; }

.topbar-search .form-control {
    padding-left: 40px;
    background: var(--cb-surface);
    border-color: transparent;
    box-shadow: var(--cb-shadow-sm);
    height: 42px;
}

.topbar-search .icon { position: absolute; left: 13px; top: 12px; color: var(--cb-text-subtle); }

.content { padding: 8px 32px 48px; width: 100%; max-width: 1240px; animation: cb-fade-in 0.25s var(--cb-ease); }

.menu-toggle { display: none; }

@media (max-width: 991.98px) {
    .app-shell { flex-direction: column; }
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 40;
        transform: translateX(-100%);
        transition: transform 0.2s var(--cb-ease);
        box-shadow: var(--cb-shadow-lg);
    }
    .sidebar.open { transform: none; }
    .menu-toggle { display: inline-flex; }
    .topbar { padding: 12px 16px; }
    .content { padding: 4px 16px 40px; }
}

/* --- Powierzchnie --- */

.card, .panel {
    background: var(--cb-surface);
    border: 0;
    border-radius: var(--cb-radius);
    box-shadow: var(--cb-shadow);
}

.panel { padding: 20px 22px; }
.panel + .panel { margin-top: 16px; }
.panel-title { font-size: 1rem; font-weight: 650; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--cb-line);
    border-radius: var(--cb-radius) var(--cb-radius) 0 0 !important;
}

/* --- Przyciski: granat dla akcji, akcent wyłącznie dla CTA --- */

.btn {
    --bs-btn-border-radius: var(--cb-radius-sm);
    --bs-btn-font-weight: 550;
    --bs-btn-padding-x: 0.95rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    transition: background-color 0.15s var(--cb-ease), box-shadow 0.15s var(--cb-ease), transform 0.15s var(--cb-ease), color 0.15s;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
    --bs-btn-bg: var(--cb-brand-700);
    --bs-btn-border-color: var(--cb-brand-700);
    --bs-btn-hover-bg: var(--cb-brand-800);
    --bs-btn-hover-border-color: var(--cb-brand-800);
    --bs-btn-active-bg: var(--cb-brand-900);
    --bs-btn-active-border-color: var(--cb-brand-900);
    --bs-btn-disabled-bg: var(--cb-brand-700);
    --bs-btn-disabled-border-color: var(--cb-brand-700);
}

.btn-cta {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--cb-accent);
    --bs-btn-border-color: var(--cb-accent);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--cb-accent-hover);
    --bs-btn-hover-border-color: var(--cb-accent-hover);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--cb-accent-hover);
    --bs-btn-active-border-color: var(--cb-accent-hover);
    box-shadow: 0 1px 2px rgba(154, 52, 18, 0.25);
}

.btn-soft {
    --bs-btn-color: var(--cb-brand-700);
    --bs-btn-bg: var(--cb-brand-50);
    --bs-btn-border-color: transparent;
    --bs-btn-hover-color: var(--cb-brand-800);
    --bs-btn-hover-bg: var(--cb-brand-100);
    --bs-btn-hover-border-color: transparent;
    --bs-btn-active-bg: var(--cb-brand-100);
    --bs-btn-active-color: var(--cb-brand-900);
}

.btn-ghost {
    --bs-btn-color: var(--cb-text-muted);
    --bs-btn-bg: transparent;
    --bs-btn-border-color: transparent;
    --bs-btn-hover-color: var(--cb-text);
    --bs-btn-hover-bg: rgba(17, 24, 39, 0.05);
    --bs-btn-hover-border-color: transparent;
    --bs-btn-active-bg: rgba(17, 24, 39, 0.08);
}

.btn-outline-danger {
    --bs-btn-color: var(--cb-danger);
    --bs-btn-border-color: #f1c4bf;
    --bs-btn-hover-bg: var(--cb-danger);
    --bs-btn-hover-border-color: var(--cb-danger);
}

.btn-icon { width: 36px; height: 36px; padding: 0; }

/* --- Formularze --- */

.form-control, .form-select {
    border-radius: var(--cb-radius-sm);
    border-color: #dfe2ea;
    padding: 0.55rem 0.8rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--cb-brand-600);
    box-shadow: 0 0 0 4px rgba(46, 63, 135, 0.12);
}

.form-label { font-weight: 550; font-size: 0.9rem; margin-bottom: 6px; }
.form-text { color: var(--cb-text-subtle); }
.form-check-input:checked { background-color: var(--cb-brand-700); border-color: var(--cb-brand-700); }

/* --- Komunikaty (czerwień tylko dla błędów) --- */

.alert {
    border: 0;
    border-radius: var(--cb-radius);
    box-shadow: var(--cb-shadow-sm);
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.alert-success { background: var(--cb-success-soft); color: #0f5132; }
.alert-info { background: var(--cb-info-soft); color: #1e3a6e; }
.alert-warning { background: var(--cb-warning-soft); color: #6b4500; }
.alert-danger, .alert-error { background: var(--cb-danger-soft); color: #842018; }

.badge-soft {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 550;
    background: var(--cb-brand-50);
    color: var(--cb-brand-700);
    white-space: nowrap;
}

.badge-soft.is-success { background: var(--cb-success-soft); color: var(--cb-success); }
.badge-soft.is-warning { background: var(--cb-warning-soft); color: var(--cb-warning); }
.badge-soft.is-danger { background: var(--cb-danger-soft); color: var(--cb-danger); }
.badge-soft.is-muted { background: #eef0f4; color: var(--cb-text-muted); }

/* Kolory tagów (zgodne z Tag.Color) */
.tag-slate { background: #eef0f4; color: #454c5e; }
.tag-blue { background: #e6eefc; color: #1f4fa3; }
.tag-green { background: #e5f5ec; color: #17683f; }
.tag-amber { background: #fdf2dc; color: #7a4f00; }
.tag-purple { background: #f0eafc; color: #5b3a9e; }
.tag-teal { background: #e0f4f2; color: #0f5f58; }

/* --- Okruszki --- */

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 0.88rem; color: var(--cb-text-muted); margin-bottom: 6px; }
.crumbs a { color: var(--cb-text-muted); text-decoration: none; border-radius: 6px; padding: 2px 6px; }
.crumbs a:hover { background: rgba(17, 24, 39, 0.05); color: var(--cb-text); }
.crumbs .icon { color: var(--cb-text-subtle); }

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }

/* --- Siatka folderów --- */

.folder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 12px;
    margin-bottom: 28px;
}

.folder-tile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--cb-surface);
    border-radius: var(--cb-radius);
    box-shadow: var(--cb-shadow);
    color: var(--cb-text);
    text-decoration: none;
    transition: transform 0.18s var(--cb-ease), box-shadow 0.18s var(--cb-ease);
    animation: cb-rise 0.3s var(--cb-ease) both;
}

.folder-tile:hover { transform: translateY(-2px); box-shadow: var(--cb-shadow-lg); color: var(--cb-text); }

.folder-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: var(--cb-brand-50);
    color: var(--cb-brand-600);
    flex-shrink: 0;
}

.folder-tile .name { font-weight: 600; line-height: 1.25; word-break: break-word; }
.folder-tile .meta { font-size: 0.8rem; color: var(--cb-text-subtle); }

/* --- Lista plików --- */

.file-list { background: var(--cb-surface); border-radius: var(--cb-radius); box-shadow: var(--cb-shadow); overflow: hidden; }

.file-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
    padding: 12px 18px;
    border-top: 1px solid var(--cb-line);
    transition: background-color 0.12s;
}

.file-row:first-child { border-top: 0; }
.file-row:hover { background: var(--cb-surface-muted); }

.file-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.file-main a { color: var(--cb-text); font-weight: 550; text-decoration: none; }
.file-main a:hover { color: var(--cb-brand-600); }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-sub { font-size: 0.8rem; color: var(--cb-text-subtle); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.file-tags { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }

.file-type {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    background: #eef0f4;
    color: #4b5263;
}

.file-type.t-pdf { background: #fdecea; color: #a8321f; }
.file-type.t-text { background: #e6eefc; color: #1f4fa3; }
.file-type.t-sheet { background: #e5f5ec; color: #17683f; }
.file-type.t-slides { background: #fdf2dc; color: #8a5300; }
.file-type.t-image { background: #f0eafc; color: #5b3a9e; }

@media (max-width: 575.98px) {
    .file-row { grid-template-columns: minmax(0, 1fr); }
    .file-tags { justify-content: flex-start; }
}

/* --- Strefa upuszczania plików i puste stany --- */

.dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    padding: 28px 20px;
    border-radius: var(--cb-radius-lg);
    background: var(--cb-surface);
    box-shadow: inset 0 0 0 2px #dfe3ee;
    color: var(--cb-text-muted);
    cursor: pointer;
    transition: box-shadow 0.18s var(--cb-ease), background-color 0.18s var(--cb-ease);
}

.dropzone:hover, .dropzone.is-over { background: var(--cb-brand-50); box-shadow: inset 0 0 0 2px var(--cb-brand-600); color: var(--cb-brand-700); }
.dropzone .dz-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--cb-accent-soft); color: var(--cb-accent); }
.dropzone strong { color: var(--cb-text); font-size: 1.02rem; }
.dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }

.empty-state { text-align: center; padding: 48px 20px; }
.empty-state .icon-wrap { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 16px; display: grid; place-items: center; background: var(--cb-brand-50); color: var(--cb-brand-600); }
.empty-state h2 { font-size: 1.25rem; }
.empty-state p { color: var(--cb-text-muted); max-width: 440px; margin: 0 auto 16px; }

/* --- Wybór szablonu --- */

.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }

.choice {
    position: relative;
    display: block;
    padding: 16px;
    border-radius: var(--cb-radius);
    background: var(--cb-surface);
    box-shadow: inset 0 0 0 1px var(--cb-line);
    cursor: pointer;
    transition: box-shadow 0.15s var(--cb-ease), background-color 0.15s;
    height: 100%;
}

.choice:hover { box-shadow: inset 0 0 0 1px var(--cb-brand-600); }
.choice input { position: absolute; opacity: 0; }
.choice:has(input:checked) { box-shadow: inset 0 0 0 2px var(--cb-brand-600); background: var(--cb-brand-50); }
.choice .choice-title { font-weight: 600; display: block; margin-bottom: 4px; }
.choice .choice-text { font-size: 0.85rem; color: var(--cb-text-muted); }

/* --- Strony bez logowania --- */

.auth-shell { min-height: 100vh; display: flex; flex-direction: column; }
.auth-top { display: flex; align-items: center; justify-content: space-between; padding: 20px 32px; }
.auth-top .brand { color: var(--cb-brand-900); padding: 0; }
.auth-top .brand:hover { color: var(--cb-brand-900); }
.auth-body { flex: 1; display: flex; justify-content: center; align-items: flex-start; padding: 24px 16px 64px; }
.auth-card { width: 100%; max-width: 440px; padding: 32px; }
.auth-card.wide { max-width: 760px; }

@media (max-width: 575.98px) {
    .auth-top { padding: 16px; }
    .auth-card { padding: 22px; }
}

/* --- Dziennik, definicje, tabele --- */

.table { --bs-table-bg: transparent; margin: 0; }
.table > :not(caption) > * > * { padding: 0.7rem 0.9rem; border-color: var(--cb-line); }
.table thead th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--cb-text-subtle); font-weight: 600; }

.dl-fields { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; font-size: 0.93rem; }
.dl-fields dt { color: var(--cb-text-muted); font-weight: 500; }
.dl-fields dd { margin: 0; word-break: break-word; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--cb-line); font-size: 0.88rem; }
.timeline li:first-child { border-top: 0; }
.timeline time { color: var(--cb-text-subtle); white-space: nowrap; }

mark { background: #fff1b8; padding: 0 2px; border-radius: 3px; }

/* Świeżo utworzony link: krótkie podświetlenie, żeby było widać, który skopiować. */
.share-new { background: var(--cb-accent-soft); animation: cb-fade-in 0.4s var(--cb-ease); }

/* --- Ładowanie: szkielety zamiast spinnerów --- */

.skeleton {
    display: block;
    border-radius: 6px;
    background: linear-gradient(90deg, #eceef3 0%, #f6f7fa 40%, #eceef3 80%);
    background-size: 200% 100%;
    animation: cb-shimmer 1.4s linear infinite;
    min-height: 0.8em;
}

/* --- Ruch: subtelny, wyłączany przez prefers-reduced-motion --- */

@keyframes cb-fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes cb-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes cb-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.folder-grid > :nth-child(2) { animation-delay: 30ms; }
.folder-grid > :nth-child(3) { animation-delay: 60ms; }
.folder-grid > :nth-child(4) { animation-delay: 90ms; }
.folder-grid > :nth-child(n+5) { animation-delay: 120ms; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }

.dropdown-menu { border: 0; border-radius: var(--cb-radius); box-shadow: var(--cb-shadow-lg); padding: 6px; }
.dropdown-item { border-radius: 6px; display: flex; align-items: center; gap: 8px; font-size: 0.92rem; }

.pricing-card { position: relative; display: flex; flex-direction: column; height: 100%; padding: 26px; }
.pricing-card.is-popular { box-shadow: 0 0 0 2px var(--cb-brand-600), var(--cb-shadow-lg); }
.pricing-price { font-size: 2.2rem; font-weight: 700; letter-spacing: -0.03em; }
