/* ============================================================
   DZIENNIK TRADINGU — DESIGN SYSTEM (JASNY MOTYW)
   Kolory P/L oddzielone od kolorow stanu psychicznego.
   ============================================================ */

:root {
  /* --- Tlo / powierzchnie --- */
  --bg:        #f3f5f8;   /* glowne tlo */
  --surface:   #ffffff;   /* karty, paski */
  --surface-2: #eef1f5;   /* hover, inputy */
  --border:    #e1e6ec;
  --border-2:  #ccd3dc;

  /* --- Tekst --- */
  --text:      #1a1f27;
  --text-dim:  #4d5764;
  --text-mute: #8893a1;

  /* --- Akcent (UI, nie P/L) --- */
  --accent:    #2563eb;
  --accent-d:  #1d4ed8;

  /* --- P/L (zysk/strata) — TYLKO dla wynikow --- */
  --win:       #1a7f37;   /* zysk */
  --win-soft:  #dcf3e3;
  --loss:      #cf222e;   /* strata */
  --loss-soft: #fce0e2;
  --be:        #9a6700;   /* breakeven ~0 */
  --be-soft:   #f7edcf;

  /* --- Statusy zagran --- */
  --st-taken:  #1a7f37;   /* ZAGRANE = zielony */
  --st-skip:   #cf222e;   /* NIE SWIADOMIE = czerwony */
  --st-missed: #bc6c00;   /* PRZEGAPIONE = pomaranczowy */

  /* --- Stan psychiczny (osobna paleta) --- */
  --mind-good: #2563eb;
  --mind-mid:  #6b7682;
  --mind-bad:  #c2410c;

  /* --- Dni OFF / weekend --- */
  --off:       #e9edf2;
  --weekend:   #eef1f5;

  --radius: 8px;
  --radius-s: 5px;
  --gap: 16px;
  --shadow: 0 2px 12px rgba(30,41,59,.10);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,h2,h3 { font-weight: 600; }
h2 { font-size: 20px; margin-bottom: 4px; }
h3 { font-size: 15px; color: var(--text-dim); }
a { color: var(--accent); }

/* ===================== TOPBAR ===================== */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-left { flex: 0 0 auto; }
.topbar-right { flex: 0 0 auto; margin-left: auto; }
.logo { font-size: 16px; font-weight: 700; letter-spacing: .2px; }

.tabs { display: flex; gap: 4px; flex: 1 1 auto; }
.tab {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid transparent;
  padding: 7px 14px;
  border-radius: var(--radius-s);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  white-space: nowrap;
  transition: .12s;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--surface-2); color: var(--text); border-color: var(--border-2); }

/* ===================== PRZYCISKI ===================== */
.btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-2);
  padding: 8px 14px;
  border-radius: var(--radius-s);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  transition: .12s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-d); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-danger { color: var(--loss); border-color: var(--loss-soft); }
.btn-danger:hover { border-color: var(--loss); background: var(--loss-soft); }
.btn-sm { padding: 4px 9px; font-size: 13px; }
.btn-icon { padding: 5px 8px; line-height: 1; }

/* ===================== LAYOUT WIDOKOW ===================== */
main { padding: 22px; max-width: 1280px; margin: 0 auto; }
/* Kalendarz na calej szerokosci strony */
body:has(#view-calendar:not([hidden])) main { max-width: 1700px; }

.view-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.view-head .spacer { flex: 1; }

.placeholder {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-mute);
  background: var(--surface);
  border: 1px dashed var(--border-2);
  border-radius: var(--radius);
}
.placeholder h2 { color: var(--text-dim); }

/* ===================== KARTY ===================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: var(--gap);
}
.card-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-mute);
  margin-bottom: 12px;
}

/* ===================== FORMULARZE ===================== */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 5px;
}
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 140px; }

input[type=text], input[type=number], input[type=time], input[type=date],
select, textarea {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-s);
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 60px; }
select { cursor: pointer; }

/* slidery stanu psychicznego 1-3 */
.scale {
  display: flex;
  gap: 6px;
}
.scale button {
  flex: 1;
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-s);
  padding: 9px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  transition: .12s;
}
.scale button:hover { border-color: var(--mind-mid); }
.scale button.sel { background: var(--mind-mid); color: #fff; border-color: var(--mind-mid); font-weight: 600; }
.scale button.sel[data-v="1"] { background: var(--mind-good); border-color: var(--mind-good); }
.scale button.sel[data-v="3"] { background: var(--mind-bad); border-color: var(--mind-bad); }

/* status dnia (przyciski OFF) */
.day-status-group { display: flex; gap: 6px; flex-wrap: wrap; }
.day-status-group button {
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-s);
  padding: 8px 12px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
}
.day-status-group button.sel { background: var(--accent); color: #fff; border-color: var(--accent); }
.day-status-group button.sel[data-s^="OFF"] { background: var(--off); color: var(--text); border-color: var(--border-2); }

/* ===================== TABELE ===================== */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 11px; border-bottom: 1px solid var(--border); }
th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-mute);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
th:hover { color: var(--text); }
tbody tr { cursor: pointer; transition: .1s; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-family: var(--mono); }

/* P/L kolory */
.pl-win  { color: var(--win);  font-weight: 600; }
.pl-loss { color: var(--loss); font-weight: 600; }
.pl-be   { color: var(--be); }
.pl-zero { color: var(--text-mute); }

/* znaczniki / chipy */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border-2);
}
.chip-taken  { background: var(--win-soft);  color: var(--st-taken);  border-color: transparent; }
.chip-skip   { background: var(--loss-soft); color: var(--st-skip);   border-color: transparent; }
.chip-missed { background: var(--be-soft);   color: var(--st-missed); border-color: transparent; }
.chip-off    { background: var(--off);       color: var(--text-dim); }

.badge-dir { font-family: var(--mono); font-weight: 700; }
.dir-long  { color: var(--win); }
.dir-short { color: var(--loss); }

/* ===================== TABELA ZAGRAN (Day Detail) ===================== */
.trades-table td { padding: 6px 8px; vertical-align: middle; }
.trades-table input, .trades-table select { padding: 5px 7px; font-size: 13px; }
.trades-table .col-narrow { width: 90px; }
.trades-table .col-time { width: 80px; }
.trades-table .col-mini { width: 60px; }
.trade-extra {
  background: var(--surface-2);
  border-left: 2px solid var(--st-missed);
}
.trade-extra td { padding: 10px 12px; }

/* ===================== TOAST ===================== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border-2);
  color: var(--text);
  padding: 11px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 200;
  font-size: 14px;
}
.toast.ok    { border-color: var(--win);  }
.toast.err   { border-color: var(--loss); }

/* ===================== POMOCNICZE ===================== */
[hidden] { display: none !important; }
.muted { color: var(--text-mute); }
.small { font-size: 12px; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.right { margin-left: auto; }
.hint {
  font-size: 12px;
  color: var(--text-mute);
  margin-top: 4px;
}
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-mute);
}

/* ===================== KALENDARZ ===================== */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}
.cal-head {
  text-align: center;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-mute);
  font-weight: 600;
  padding: 4px 0 8px;
}
.cal-cell {
  min-height: 150px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 9px;
  cursor: pointer;
  transition: .1s;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}
.cal-cell:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow); }
.cal-cell-empty { background: var(--bg); opacity: .55; }
.cal-weekend { opacity: .8; }
.cal-cell-empty.cal-weekend { background: var(--weekend); }
.cal-off { background: var(--off) !important; }
.cal-empty { min-height: 150px; }

.cal-top { display: flex; align-items: center; justify-content: space-between; }
.cal-num { font-size: 15px; font-weight: 700; color: var(--text); }
.cal-off-tag {
  font-size: 10px; font-weight: 700; color: var(--text-mute);
  border: 1px solid var(--border-2); border-radius: 3px; padding: 1px 5px;
}
.cal-pl { font-family: var(--mono); font-size: 15px; font-weight: 700; }

/* lista zagran-miniaturek: "RTY ⬆️✳️15:33,5" */
.cal-trades-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 4px 0;
}
.cal-trade {
  font-size: 12px;
  font-family: var(--mono);
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 3px 7px;
  border-radius: 6px;
}
.cal-trade-instr { font-weight: 800; }

.cal-icons { margin-top: auto; display: flex; flex-wrap: wrap; gap: 6px; font-size: 11px; color: var(--text-dim); padding-top: 2px; }
.cal-konc { white-space: nowrap; }

@media (max-width: 900px) {
  .cal-cell, .cal-empty { min-height: 100px; }
  .cal-pl, .cal-num { font-size: 12px; }
  .cal-trade { font-size: 10px; padding: 2px 5px; }
  .cal-icons { font-size: 9px; }
}

/* Zagrania - wiersz zwiniety (pasek) */
.trades-table .wiersz-zwiniety td { padding: 5px 8px; }
.trades-table .wiersz-zwiniety { background: var(--surface-2); opacity: .92; }
.trades-table .wiersz-zwiniety:hover { background: var(--surface); opacity: 1; }
.pl-pasek { white-space: nowrap; display: inline-flex; align-items: baseline; }

/* ===================== STEPPER (3 zakladki w Day Detail) ===================== */
.stepper-tabs {
  display: flex; gap: 4px;
  margin-bottom: 18px;
  border-bottom: 2px solid var(--border);
}
.stepper-tab {
  flex: 1; min-width: 140px;
  background: transparent;
  border: none; border-bottom: 3px solid transparent;
  padding: 14px 18px 12px;
  cursor: pointer;
  font-family: inherit; font-size: 14px;
  color: var(--text-dim);
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  transition: .12s;
  margin-bottom: -2px;
}
.stepper-tab:hover { color: var(--text); background: var(--surface-2); }
.stepper-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--surface);
}
.stepper-label { font-weight: 600; font-size: 15px; }
.stepper-meta { font-size: 11px; color: var(--text-mute); text-transform: uppercase; letter-spacing: .4px; }
.stepper-tab.active .stepper-meta { color: var(--accent); }

/* Mood picker (emoji nastroju) */
.mood-picker { display: flex; gap: 4px; flex-wrap: wrap; }
.mood-btn {
  background: var(--surface-2);
  border: 2px solid var(--border-2);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 22px; line-height: 1;
  cursor: pointer;
  transition: .12s;
}
.mood-btn:hover { border-color: var(--accent); transform: scale(1.1); }
.mood-btn.sel {
  border-color: var(--accent);
  background: var(--win-soft);
  transform: scale(1.15);
}

/* Przerwy */
.przerwa-row { margin-bottom: 6px; align-items: flex-end; }
.przerwa-row .field { margin-bottom: 0; }

/* ===================== PRZEGLAD ZAGRAN (tabela z filtrami) ===================== */
.przeglad-tbl td { padding: 8px 10px; font-size: 14px; }
.przeglad-tbl tbody tr:hover { background: var(--surface-2); }
.przeglad-mini {
  width: 60px; height: 36px; object-fit: cover;
  border: 1px solid var(--border-2); border-radius: 4px;
  cursor: zoom-in; transition: .12s;
}
.przeglad-mini:hover { border-color: var(--accent); transform: scale(1.1); }

/* ===================== GALERIA OBRAZOW PDF (zalaczniki zagrania) ===================== */
.galeria { border-top: 1px solid var(--border); padding-top: 10px; }
.galeria-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }
.galeria-item { display: flex; flex-direction: column; align-items: center; }
.galeria-mini {
  width: 160px; height: 90px; object-fit: cover;
  border: 2px solid var(--border-2); border-radius: var(--radius-s);
  cursor: zoom-in; transition: .15s;
  background: var(--surface-2);
}
.galeria-mini:hover { border-color: var(--accent); transform: scale(1.03); }

/* Lightbox overlay — full-screen powiekszenie */
.galeria-lightbox {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,.85);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; pointer-events: none;
}
.galeria-lightbox.sticky { pointer-events: auto; }
.galeria-lightbox img {
  max-width: 95%; max-height: 90vh; object-fit: contain;
  border-radius: var(--radius); box-shadow: 0 8px 40px rgba(0,0,0,.6);
}
.lightbox-label {
  margin-top: 14px; color: #fff;
  background: rgba(0,0,0,.5); padding: 6px 14px; border-radius: var(--radius-s);
  font-size: 14px;
}

/* Strefa drop dla wlasnych screenow */
.dropzone {
  border: 2px dashed var(--border-2);
  border-radius: var(--radius-s);
  padding: 14px;
  text-align: center;
  cursor: pointer;
  color: var(--text-dim);
  background: var(--surface-2);
  transition: .15s;
}
.dropzone:hover, .dropzone:focus { border-color: var(--accent); color: var(--text); outline: none; }
.dropzone.dragging { border-color: var(--accent); background: var(--win-soft); color: var(--win); }

/* ============================================================
   DARK MODE — aktywne gdy <html data-theme="dark">
   ============================================================ */
html[data-theme="dark"] {
  --bg:        #0d1117;
  --surface:   #161b22;
  --surface-2: #1c2330;
  --border:    #2a3038;
  --border-2:  #3a424d;

  --text:      #e6edf3;
  --text-dim:  #9aa7b4;
  --text-mute: #6b7682;

  --accent:    #3b82f6;
  --accent-d:  #2563eb;

  --win:       #2ea043;
  --win-soft:  #1a3a24;
  --loss:      #f85149;
  --loss-soft: #3a1d1d;
  --be:        #d29922;
  --be-soft:   #3a2f12;

  --st-taken:  #2ea043;
  --st-skip:   #f85149;
  --st-missed: #db8b2a;

  --mind-good: #58a6ff;
  --mind-mid:  #8b949e;
  --mind-bad:  #db6d28;

  --off:       #21262d;
  --weekend:   #15191f;

  --shadow: 0 4px 16px rgba(0,0,0,.4);
}
/* miniaturki zagran w kalendarzu — ciemne wersje tla */
html[data-theme="dark"] .cal-trade {
  filter: brightness(0.9) saturate(1.1);
}
html[data-theme="dark"] .btn-primary { color: #fff; }
