/* =====================================================================
   multimail - biblioteka dokumentow i cztery edytory

   Nazwy klas zaczynaja sie od doc-, ed-, sheet-, slide- albo pdf-, zeby
   nie wchodzic w droge poczcie i kalendarzowi. Tamte widoki maja juz swoje
   .card, .chip i .mhead - kolizja konczylaby sie rozjechanym ukladem
   w zupelnie innym miejscu panelu.
   ===================================================================== */

/*
   .screen ma wlasne przewijanie calej zawartosci, a edytor potrzebuje czegos
   innego: pasek narzedzi ma stac w miejscu, a przewijac sie ma tylko tresc.
   Dlatego sam ekran jest kolumna bez przewijania, a scrolluje to, co w srodku.
*/
.screen.docs { display: flex; flex-direction: column; overflow: hidden; }
.screen.docs > .screenin { flex: 1; min-height: 0; overflow-y: auto; }

/* --- Biblioteka ------------------------------------------------------ */

.doclist {
    display: grid;
    gap: 10px;
}

.doccard {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 6px 12px 6px 6px;
    transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.doccard:hover { border-color: var(--accent-line); box-shadow: var(--shadow-1); }

.docopen {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px;
    text-align: left;
    border-radius: var(--r-sm);
    color: inherit;
}

.docicon {
    width: 40px; height: 40px;
    flex: 0 0 auto;
    display: grid; place-items: center;
    border-radius: var(--r-sm);
    background: var(--surface-3);
    color: var(--ink-2);
}
.docicon svg { width: 21px; height: 21px; }
.docicon.sm { width: 28px; height: 28px; border-radius: var(--r-xs); }
.docicon.sm svg { width: 16px; height: 16px; }

/* Kolor po rodzaju pliku - ta sama podpowiedz, co w Office. */
.docicon.k-docx { background: var(--accent-soft); color: var(--accent); }
.docicon.k-xlsx { background: var(--ok-soft);     color: var(--ok); }
.docicon.k-pptx { background: var(--warn-soft);   color: var(--warn); }
.docicon.k-pdf  { background: var(--bad-soft);    color: var(--bad); }

.docmeta { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.docmeta b { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.docsub { font-size: 12.5px; color: var(--ink-3); }

.docacts { display: flex; align-items: center; gap: 2px; opacity: 0; transition: opacity .14s var(--ease); }
.doccard:hover .docacts, .doccard:focus-within .docacts { opacity: 1; }
.docacts .iconbtn { width: 32px; height: 32px; }
.docacts .iconbtn svg { width: 17px; height: 17px; }

.btn.bad { border-color: var(--bad); color: var(--bad); }
.btn.bad:hover { background: var(--bad-soft); border-color: var(--bad); }

/* --- Zalacznik biurowy w poczcie -------------------------------------- */

/*
   Przycisk "otworz w edytorze" stoi obok pobrania, a nie zamiast niego.
   Pobranie jest tu wazniejsze: to jedyna droga do pliku, gdy nasz edytor
   danego formatu nie ogarnie.
*/
.filerow { display: inline-flex; align-items: center; gap: 2px; }
.filerow .iconbtn { width: 30px; height: 30px; opacity: 0; transition: opacity .14s var(--ease); }
.filerow .iconbtn svg { width: 16px; height: 16px; }
.filerow:hover .iconbtn, .filerow:focus-within .iconbtn { opacity: 1; }

@media (hover: none) {
    .filerow .iconbtn { opacity: 1; }
}

/* --- Powloka edytora -------------------------------------------------- */

.editor {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.edbar {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 54px;
    flex: 0 0 auto;
    padding: 0 14px;
    border-bottom: 1px solid var(--line-soft);
}
.edbar .spacer { flex: 1; }

.edtitle {
    font-family: var(--f-display);
    font-size: 17px;
    font-weight: 600;
    color: var(--ink);
    padding: 4px 8px;
    border-radius: var(--r-xs);
    max-width: 46ch;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.edtitle:hover { background: var(--surface-3); }

.edstate { font-size: 12px; color: var(--ink-3); }
.edstate.warn { color: var(--warn); font-weight: 600; }

.edtools {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
    flex-wrap: wrap;
    padding: 8px 14px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line-soft);
}
.edtools .spacer { flex: 1; }
.edtools .hint { font-size: 12px; color: var(--ink-3); }

.tbtn {
    width: 32px; height: 32px;
    display: grid; place-items: center;
    border-radius: var(--r-xs);
    color: var(--ink-2);
    transition: background .14s var(--ease), color .14s var(--ease);
}
.tbtn:hover { background: var(--surface-3); color: var(--ink); }
.tbtn.on { background: var(--accent-soft); color: var(--accent); }
.tbtn svg { width: 17px; height: 17px; }

.tsel {
    height: 30px;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: var(--r-xs);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 12.5px;
}
.tsel.sm { width: 62px; }

.tcolor {
    width: 30px; height: 30px;
    padding: 2px;
    border: 1px solid var(--line);
    border-radius: var(--r-xs);
    background: var(--surface);
    cursor: pointer;
}

.tsep { width: 1px; height: 22px; background: var(--line); margin: 0 5px; }

.edscroll { flex: 1; min-height: 0; overflow: auto; background: var(--ground); }

/* --- Word ------------------------------------------------------------- */

/*
   Szerokosc strony to 21 cm minus marginesy, przeliczone na piksele przy
   96 dpi. Nie udajemy podgladu wydruku, ale tekst ma sie lamac mniej wiecej
   tam, gdzie zlamie sie w Wordzie - inaczej kazdy akapit wygladalby inaczej
   niz w pliku.
*/
.page {
    max-width: 794px;
    min-height: 900px;
    margin: 26px auto 60px;
    padding: 64px 72px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 4px;
    box-shadow: var(--shadow-1);
    font-family: "Calibri", "Carlito", var(--f-ui);
    font-size: 11pt;
    line-height: 1.5;
    color: var(--ink);
    outline: none;
}
.page:focus { border-color: var(--accent-line); }

.page p { margin: 0 0 8pt; min-height: 1em; }
.page ul, .page ol { margin: 0 0 8pt; padding-left: 26px; }
.page li { margin-bottom: 2pt; }

.page .st-title {
    font-family: var(--f-display);
    font-size: 26pt;
    font-weight: 700;
    letter-spacing: -.02em;
    margin-bottom: 14pt;
}
.page .st-h1 { font-size: 18pt; font-weight: 700; margin: 16pt 0 6pt; color: var(--ink); }
.page .st-h2 { font-size: 14.5pt; font-weight: 700; margin: 14pt 0 5pt; }
.page .st-h3 { font-size: 12.5pt; font-weight: 700; margin: 12pt 0 4pt; }
.page .st-quote {
    border-left: 3px solid var(--accent-line);
    padding-left: 14px;
    color: var(--ink-2);
    font-style: italic;
}

.page a { color: var(--accent); text-decoration: underline; }

.dtable {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 10pt;
    font-size: 10.5pt;
}
.dtable td {
    border: 1px solid var(--line);
    padding: 5px 8px;
    vertical-align: top;
}
.dtable td p { margin: 0; }

/*
   Plakietka w miejscu obrazu albo pola. Ma wygladac jak cialo obce
   w tekscie, a nie jak jego czesc - inaczej ktos probowalby ja edytowac.
*/
.rawblock {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 0 8pt;
    padding: 10px 12px;
    border: 1px dashed var(--line);
    border-radius: var(--r-sm);
    background: var(--surface-2);
    color: var(--ink-2);
    font-family: var(--f-ui);
    font-size: 12.5px;
    line-height: 1.5;
    user-select: none;
}
.rawblock svg { width: 18px; height: 18px; flex: 0 0 auto; color: var(--ink-3); margin-top: 1px; }
.rawblock > span { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.rawblock b { font-size: 12.5px; color: var(--ink); }
.rawblock .rawtext { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rawblock .rawnote { font-size: 11.5px; color: var(--ink-3); }

/* --- Excel ------------------------------------------------------------ */

.edscroll.grid { background: var(--surface); }

.sheet {
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.sheet th {
    position: sticky;
    top: 0;
    z-index: 2;
    height: 26px;
    min-width: 92px;
    padding: 0 6px;
    background: var(--surface-2);
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    font-size: 11.5px;
    font-weight: 600;
    color: var(--ink-3);
}

.sheet th.rownum {
    position: sticky;
    left: 0;
    z-index: 1;
    top: auto;
    min-width: 46px;
    width: 46px;
    text-align: right;
    padding-right: 8px;
}

.sheet th.corner { position: sticky; left: 0; z-index: 3; min-width: 46px; width: 46px; }

.sheet td {
    height: 26px;
    min-width: 92px;
    max-width: 240px;
    padding: 0 6px;
    border-right: 1px solid var(--line-soft);
    border-bottom: 1px solid var(--line-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    outline: none;
    cursor: cell;
}
.sheet td.num { text-align: right; }

/* Zaznaczona komorka ma ramke wewnatrz, zeby nie przesuwac siatki. */
.sheet td[data-on] { box-shadow: inset 0 0 0 2px var(--accent); background: var(--accent-soft); }
.sheet td[contenteditable="true"] {
    background: var(--surface);
    box-shadow: inset 0 0 0 2px var(--accent);
    white-space: pre;
    overflow: visible;
    text-align: left;
    cursor: text;
}

.cellref {
    min-width: 56px;
    padding: 0 8px;
    height: 30px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: var(--r-xs);
    background: var(--surface);
    font-family: var(--f-mono);
    font-size: 12px;
    font-weight: 600;
}

.fbar {
    flex: 1;
    min-width: 200px;
    height: 30px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: var(--r-xs);
    background: var(--surface);
    color: var(--ink);
    font-family: var(--f-mono);
    font-size: 12.5px;
}
.fbar:focus { border-color: var(--accent); outline: none; }

.stabs {
    display: flex;
    gap: 4px;
    flex: 0 0 auto;
    padding: 6px 10px;
    border-top: 1px solid var(--line-soft);
    background: var(--surface-2);
    overflow-x: auto;
}

.stab {
    height: 26px;
    padding: 0 14px;
    border-radius: var(--r-xs);
    font-size: 12.5px;
    color: var(--ink-2);
    white-space: nowrap;
}
.stab:hover { background: var(--surface-3); }
.stab.on { background: var(--surface); color: var(--accent); font-weight: 600; box-shadow: var(--shadow-1); }

/* --- PowerPoint -------------------------------------------------------- */

/*
   minmax(0, 1fr) jest tu konieczne: bez tego dlugi tytul slajdu rozpycha
   track grida ponad szerokosc panelu i plotno ucieka poza krawedz.
*/
.deck {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 208px minmax(0, 1fr);
}

.slides {
    overflow-y: auto;
    padding: 12px 10px;
    border-right: 1px solid var(--line-soft);
    background: var(--surface-2);
    display: grid;
    gap: 8px;
    align-content: start;
}

.slidethumb {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    padding: 10px;
    text-align: left;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface);
    transition: border-color .14s var(--ease);
}
.slidethumb:hover { border-color: var(--accent-line); }
.slidethumb.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.slidethumb .num { font-size: 11px; font-weight: 700; color: var(--ink-3); }
.slidethumb .peek {
    font-size: 12px;
    color: var(--ink-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stage {
    overflow: auto;
    padding: 24px;
    background: var(--ground);
    display: grid;
    place-items: start center;
}

/*
   Plotno trzyma proporcje 16:9 przez aspect-ratio, a ksztalty stoja na nim
   w procentach. Dzieki temu slajd skaluje sie razem z oknem i nie trzeba
   przeliczac EMU na piksele przy kazdej zmianie rozmiaru.
*/
.canvas {
    position: relative;
    width: 100%;
    max-width: 960px;
    aspect-ratio: 16 / 9;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-1);
}

.shape {
    position: absolute;
    padding: 4px 6px;
    font-size: 15px;
    line-height: 1.3;
    color: var(--ink);
    border: 1px dashed transparent;
    border-radius: 3px;
    overflow: hidden;
    outline: none;
}
.shape:hover { border-color: var(--line); }
.shape:focus { border-color: var(--accent); border-style: solid; background: var(--surface); }

.shape .lvl1 { padding-left: 16px; }
.shape .lvl2 { padding-left: 32px; }
.shape .lvl3 { padding-left: 48px; }
.shape .lvl4 { padding-left: 64px; }

.shape.pic {
    display: grid;
    place-items: center;
    gap: 4px;
    background: var(--surface-2);
    border: 1px dashed var(--line);
    color: var(--ink-3);
    font-size: 11.5px;
}
.shape.pic svg { width: 22px; height: 22px; }

/* --- PDF --------------------------------------------------------------- */

.pdfview {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
}

.pdfframe { width: 100%; height: 100%; border: 0; background: var(--ground); }

.pdfside {
    overflow-y: auto;
    padding: 16px 18px;
    border-left: 1px solid var(--line-soft);
    background: var(--surface);
}
.pdfside .hint { font-size: 12.5px; color: var(--ink-3); line-height: 1.6; }

.pdftext {
    font-family: var(--f-mono);
    font-size: 11.5px;
    line-height: 1.65;
    color: var(--ink-2);
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
}
.pdftext mark { background: var(--warn-soft); color: var(--ink); border-radius: 2px; }

.tfind {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: var(--pill);
    background: var(--surface);
}
.tfind svg { width: 15px; height: 15px; color: var(--ink-3); }
.tfind input { border: 0; background: none; color: var(--ink); font: inherit; font-size: 12.5px; width: 150px; }
.tfind input:focus { outline: none; }

/* --- Waskie ekrany ------------------------------------------------------ */

@media (max-width: 900px) {
    .page { padding: 32px 24px; margin: 12px; }
    .deck { grid-template-columns: minmax(0, 1fr); }
    .slides { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line-soft); }
    .slidethumb { min-width: 170px; }
    .pdfview { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) 220px; }
    .pdfside { border-left: 0; border-top: 1px solid var(--line-soft); }
    .docacts { opacity: 1; }
}
