/* ============================================================
   resteye.ai Cloud — app.css
   Dark theme: sidebar + main layout
   ============================================================ */

:root {
  --sidebar-width: 220px;
  --topbar-height: 56px;
  --bg-dark:    #0f1117;
  --bg-sidebar: #161b27;
  --bg-card:    #1c2333;
  --border:     rgba(255,255,255,.08);
  --text-muted: #6c757d;

  /* Brand tokens (resteye.ai) */
  --brand-primary:      #1656D5;  /* logo "eye", primary actions */
  --brand-primary-dark: #0F44B0;  /* hover/active */
  --brand-bg-deep:      #0A0F1F;  /* deep dark — login bg, mark on-dark */

  /* Override Bootstrap primary so .text-primary, .btn-primary, .bg-primary use brand color */
  --bs-primary:     #1656D5;
  --bs-primary-rgb: 22, 86, 213;
}

/* ── Body ─────────────────────────────────────────────────── */
body {
  background-color: var(--bg-dark);
  color: #e0e0e0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: .9rem;
}

/* ── Layout shell ─────────────────────────────────────────── */
.foodai-body {
  display: flex;
  min-height: 100vh;
}

.foodai-sidebar {
  width: var(--sidebar-width);
  height: 100vh;            /* EXAKT, ne min-height — sidebar = viewport height */
  overflow: hidden;         /* skryje vnější scrollbar, vnitřní scroll v .foodai-sidebar-nav */
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1040;            /* nad Bootstrap modal backdrop default */
  transition: transform .25s ease;
}

/* Header (brand) a footer (user panel) se nezmenší — vždy viditelné. */
.foodai-sidebar .foodai-brand,
.foodai-sidebar .foodai-user-panel {
  flex-shrink: 0;
}

/* Nav (menu items) je middle flex child — scrollovatelný, když položek je víc
   než zbývající vertical space. `min-height: 0` je KLÍČOVÝ pro flex children
   s overflow — bez něj flex item neumí být menší než content. */
.foodai-sidebar-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}

/* ── Act-as banner (super-admin pracuje v cizím tenantu) ─────────────────
   Desktop: 1 řádek (ikona + text + tlačítko vpravo).
   Mobile (<768px): wrap = ikona+text 1. řádek, tlačítko 2. řádek na full šířku
   (= "Návrat do <tenant>" se nevejde na 1 řádek + ořezání). */
.foodai-actas-banner {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem 1.5rem;
  background: rgba(255,193,7,.12);
  border-bottom: 1px solid rgba(255,193,7,.35);
  color: #ffc107;
}
.foodai-actas-banner .actas-text { flex: 1; min-width: 0; }
.foodai-actas-banner .actas-action { flex-shrink: 0; }

.foodai-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Detail row toggle (revenue + jiné) ────────────────────
   Class-based visibility ať CSS na mobile vs desktop dává různý display. */
.foodai-content .detail-row { display: none; }
.foodai-content .detail-row.is-expanded { display: table-row; }
.foodai-content .rev-expand-btn .bi-chevron-right { transition: transform .15s ease; }
.foodai-content .rev-expand-btn.expanded .bi-chevron-right { transform: rotate(90deg); }

/* Bootstrap accordion na dark themu — default chevron je tmavý SVG (skoro
   neviditelný na dark backgroundu, viz Subkategorie sekce). Filter převede
   na bílý s 70 % opacity (subtle ale vidět), hover/expanded = plná bílá. */
.foodai-content .accordion-button::after {
  filter: brightness(0) invert(1) opacity(0.7);
  transition: filter .15s ease;
}
.foodai-content .accordion-button:hover::after,
.foodai-content .accordion-button:not(.collapsed)::after {
  filter: brightness(0) invert(1) opacity(1);
}

/* ── Mobile: hamburger toggle (< 992 px) ──────────────────── */
.foodai-mobile-toggle,
.foodai-mobile-toggle:focus,
.foodai-mobile-toggle:active,
.foodai-mobile-toggle:hover {
  display: none;                 /* default: hidden, jen mobile @media unhide */
  background: transparent !important;
  background-color: transparent !important;
  border: 0 !important;
  outline: none !important;
  box-shadow: none !important;
  color: #ffffff !important;
  padding: .5rem .75rem;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  margin-right: .5rem;
  -webkit-tap-highlight-color: transparent;   /* iOS no flash on tap */
  -webkit-appearance: none;
  appearance: none;
}
.foodai-mobile-toggle:hover { color: #6ea8fe !important; }

.foodai-sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.55);
  z-index: 1035;
  opacity: 0;
  transition: opacity .2s ease;
}
.foodai-sidebar-backdrop.is-open {
  display: block;
  opacity: 1;
}

@media (max-width: 991px) {
  /* Sidebar — slide-in z leva přes backdrop */
  .foodai-sidebar {
    transform: translateX(-100%) !important;
    box-shadow: 4px 0 20px rgba(0,0,0,.5);
  }
  .foodai-sidebar.is-open {
    transform: translateX(0) !important;
  }
  .foodai-main {
    margin-left: 0 !important;
  }
  .foodai-mobile-toggle {
    display: inline-flex !important;
    align-items: center;
  }

  /* Content padding — těsnější na mobile */
  .foodai-content {
    padding: .75rem !important;
  }

  /* Topbar je teď dvouřádkový na mobile (viz base.html refactor 2026-05-15d):
     řádek 1 = hamburger + title (kompaktní), řádek 2 = location dropdown + actions.
     CSS jen optimalizuje fontes / paddings. */
  .foodai-topbar h1 {
    font-size: 1rem !important;
    line-height: 1.2;
  }
  .foodai-topbar-mobile-actions {
    background: rgba(0, 0, 0, .15);
    border-bottom: 1px solid var(--border);
  }
  .foodai-topbar-mobile-actions .btn-group .btn,
  .foodai-topbar-mobile-actions .btn {
    font-size: .78rem;
    padding: .3rem .6rem;
  }
  .foodai-topbar-mobile-actions .btn-group {
    flex-wrap: wrap;
  }

  /* Tabulky — horizontal scroll fallback v .table-responsive obalu */
  .foodai-content .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  /* Kompaktní mobile: menší font + padding pro tabulky */
  .foodai-content .table {
    font-size: .82rem;
  }
  .foodai-content .table > :not(caption) > * > * {
    padding: .4rem .5rem;
  }

  /* ── Mobile-grid-table: tabulka jako 2-řádkové karty per row.
     Header se schovává, každý <tr> se stane CSS Grid-em s pojmenovanými
     buňkami. Buňky mají data-label atribut → zobrazí se jako popisek
     nad hodnotou (pseudoelement ::before).
     Aplikováno: events.html, revenue.html. */
  .foodai-content .mobile-grid-table,
  .foodai-content .mobile-grid-table thead,
  .foodai-content .mobile-grid-table tbody,
  .foodai-content .mobile-grid-table tr,
  .foodai-content .mobile-grid-table td,
  .foodai-content .mobile-grid-table th {
    display: revert;   /* defaultní reset (browser default) */
  }
  .foodai-content .mobile-grid-table thead { display: none; }
  .foodai-content .mobile-grid-table tbody { display: block; }
  .foodai-content .mobile-grid-table tbody tr {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: .5rem .75rem;
    padding: .75rem;
    border-bottom: 1px solid var(--border);
    align-items: start;
  }
  /* DIRECT children jen — nesahej na <td> uvnitř nested <table> v detail-row */
  .foodai-content .mobile-grid-table > tbody > tr > td {
    display: block;            /* obsah uvnitř zůstává inline (icon + text) */
    padding: 0 !important;
    border: 0;
    line-height: 1.3;
    min-width: 0;
    white-space: normal;
  }
  /* Popisek nad hodnotou — malá uppercase, světle šedý */
  .foodai-content .mobile-grid-table > tbody > tr > td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: .62rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: .1rem;
    opacity: .7;
  }

  /* ── Per-table grid layout ─────────────────────────────────────────
     Events: 7 buněk → 2 řádky × 4 sloupce (1 buňka přesahuje)
       row1: cell-time(1-2) | cell-class(3-4)
       row2: cell-type(1) | cell-conf(2) | cell-dur(3) | cell-snap(4)
       cell-loc: schováno (málo důležité na mobile, místo má snap ikona)
  */
  .foodai-content .events-table tbody tr {
    grid-template-areas:
      "time time class class"
      "type conf dur snap";
  }
  .foodai-content .events-table .cell-time   { grid-area: time;  }
  .foodai-content .events-table .cell-class  { grid-area: class; align-items: flex-end; flex-direction: row; flex-wrap: wrap; gap: .2rem; justify-content: flex-end; }
  .foodai-content .events-table .cell-type   { grid-area: type;  }
  .foodai-content .events-table .cell-conf   { grid-area: conf;  }
  .foodai-content .events-table .cell-dur    { grid-area: dur;   }
  .foodai-content .events-table .cell-snap   { grid-area: snap;  align-items: flex-end; }
  .foodai-content .events-table .cell-loc    { display: none;    }

  /* Revenue: kompaktní 3-řádkový grid + řádek = clickable pro rozbalení.
     row1: date(1-3)        | chevron-hint(4)
     row2: weather(1-2)     | persons(3)  | objects(4)
     row3: est(1-2)         | delta(3)    | actual(4) — actual = input vpravo
     ref + note: schováno (ref edituje se přes detail)
  */
  .foodai-content .rev-table tbody tr {
    grid-template-columns: 1fr 1fr 1fr 1fr;
    grid-template-areas:
      "date    date    date    actual"
      "weather weather persons objects"
      "est     est     delta   ref";
    cursor: pointer;
  }
  .foodai-content .rev-table .cell-date    {
    grid-area: date;
    /* Inline button + datum + dow + víkend badge */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .foodai-content .rev-table .cell-weather {
    grid-area: weather;
    white-space: nowrap;          /* ikona + temp + precip na 1 řádku */
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .foodai-content .rev-table .cell-weather .text-secondary,
  .foodai-content .rev-table .cell-weather .text-white {
    font-size: .8rem;             /* trochu zmenšit ať se vejde */
  }
  /* !important kvůli Bootstrap .text-end rule co je v templatu */
  .foodai-content .rev-table .cell-persons { grid-area: persons; text-align: right !important; }
  .foodai-content .rev-table .cell-objects { grid-area: objects; text-align: right !important; }
  .foodai-content .rev-table .cell-est     { grid-area: est;     text-align: left  !important; }
  .foodai-content .rev-table .cell-actual  { grid-area: actual;  text-align: right !important; }
  .foodai-content .rev-table .cell-delta   { grid-area: delta;   text-align: right !important; }
  .foodai-content .rev-table .cell-ref     { grid-area: ref;     text-align: center !important; }
  .foodai-content .rev-table .cell-note    { display: none; }
  /* Víkend badge: tiny, nelámej řádek (bublina za dnem) */
  .foodai-content .rev-table .cell-date .badge {
    font-size: .55rem !important;
    padding: .1rem .3rem !important;
    vertical-align: middle;
  }
  /* Skryj klasický chevron button — celý row je clickable, viz JS níže */
  .foodai-content .rev-table .rev-expand-btn { display: none; }

  /* Skutečná tržba input — kompaktnější, plná šířka cellu, zvýrazněný */
  .foodai-content .rev-table .cell-actual .rev-actual-input {
    font-size: .9rem !important;
    font-weight: 600;
    color: #fff !important;
    width: 100%;
    max-width: none !important;
    padding: 0 !important;
    text-align: right;
  }

  /* Provozovny listing — 4-řádkový grid + akce na plnou šířku.
     row1: name (1-4)
     row2: kamera (1-2) | otevřeno (3-4)
     row3: spend  (1-2) | prices  (3-4)
     row4: action (1-4) — tlačítko "Nastavení"
     edge zař. (vždy "—") + stav (málokdy neaktivní) schované. */
  .foodai-content .locations-table tbody tr {
    grid-template-columns: 1fr 1fr 1fr 1fr;
    grid-template-areas:
      "name   name   name   name"
      "camera camera open   open"
      "spend  spend  prices prices"
      "action action action action";
    padding: .85rem !important;
  }
  .foodai-content .locations-table .cell-name   { grid-area: name; }
  .foodai-content .locations-table .cell-camera { grid-area: camera; }
  .foodai-content .locations-table .cell-open   { grid-area: open;   text-align: right !important; }
  .foodai-content .locations-table .cell-spend  { grid-area: spend; }
  .foodai-content .locations-table .cell-prices { grid-area: prices; text-align: right !important; }
  .foodai-content .locations-table .cell-action { grid-area: action; text-align: stretch !important; margin-top: .25rem; }
  .foodai-content .locations-table .cell-action .btn { width: 100%; }
  .foodai-content .locations-table .cell-edge   { display: none; }
  .foodai-content .locations-table .cell-status { display: none; }

  /* Detail row (rozbalitelný breakdown) — plná šířka, kompaktní layout.
     Visibility řízena .is-expanded class přes JS (fdToggleDetail). */
  .foodai-content .mobile-grid-table tr.detail-row { display: none; }
  .foodai-content .mobile-grid-table tr.detail-row.is-expanded {
    display: block;
    padding: 0;
    background: rgba(255,255,255,.02);
    border-top: 1px solid rgba(255,255,255,.05);
  }
  .foodai-content .mobile-grid-table tr.detail-row > td {
    display: block;
    padding: .5rem .75rem !important;
  }
  /* Detail tabulky uvnitř — agresivně kompaktní */
  .foodai-content .mobile-grid-table tr.detail-row .table {
    font-size: .78rem !important;
    line-height: 1.15 !important;
    margin-bottom: 0;
    table-layout: auto;
    width: 100%;
  }
  .foodai-content .mobile-grid-table tr.detail-row .table td,
  .foodai-content .mobile-grid-table tr.detail-row .table th {
    padding: .1rem .25rem !important;
    line-height: 1.15 !important;
    border: 0 !important;
    vertical-align: middle;
  }
  /* Hodnotové sloupce (vpravo) — zalévat na 1 řádek */
  .foodai-content .mobile-grid-table tr.detail-row .table td.text-end,
  .foodai-content .mobile-grid-table tr.detail-row .table th.text-end {
    white-space: nowrap;
  }
  /* Sekce header (Osoby / Objekty) — menší margin */
  .foodai-content .mobile-grid-table tr.detail-row .text-info,
  .foodai-content .mobile-grid-table tr.detail-row .text-success {
    font-size: .78rem !important;
    margin-bottom: .15rem !important;
    margin-top: 0 !important;
  }
  /* Bootstrap row gutters → 0 */
  .foodai-content .mobile-grid-table tr.detail-row .row {
    --bs-gutter-x: 0 !important;
    --bs-gutter-y: .35rem !important;
    margin: 0 !important;
  }
  .foodai-content .mobile-grid-table tr.detail-row .row > * {
    padding: 0 !important;
  }
  /* Schovat vysvětlivku "(zadaná v nastavení)" — žere řádky */
  .foodai-content .mobile-grid-table tr.detail-row .opacity-50 {
    display: none;
  }
  /* TR řádky v inner table — žádný extra margin/padding */
  .foodai-content .mobile-grid-table tr.detail-row .table tr {
    line-height: 1.15;
  }

  /* Karty / forms — menší písmo, kompaktnější padding */
  .foodai-content .card-header {
    font-size: .85rem;
    padding: .5rem .75rem !important;
  }
  .foodai-content .card-body {
    padding: .75rem !important;
  }
  .foodai-content .form-label {
    font-size: .82rem;
    margin-bottom: .25rem;
  }

  /* Act-as banner mobile — wrap na 2 řádky, tlačítko na full šířku */
  .foodai-actas-banner {
    flex-wrap: wrap;
    padding: .5rem .75rem;
    gap: .4rem .6rem;
    font-size: .78rem;
  }
  .foodai-actas-banner > i { order: 1; }
  .foodai-actas-banner .actas-text { order: 2; flex-basis: calc(100% - 2rem); }
  .foodai-actas-banner .actas-action { order: 3; flex-basis: 100%; }
  .foodai-actas-banner .actas-action .btn {
    width: 100%;
    font-size: .78rem;
  }

  /* Modal: full-screen na mobilu pro lepší čitelnost */
  .modal-dialog.modal-xl,
  .modal-dialog.modal-lg {
    margin: .5rem;
    max-width: calc(100vw - 1rem);
  }

  /* Dropdown menu: nepřesahuj viewport */
  .dropdown-menu {
    max-width: calc(100vw - 1rem);
    font-size: .85rem;
  }
}

/* Velmi malé telefony (< 480 px) — ještě těsnější */
@media (max-width: 479px) {
  .foodai-content {
    padding: .5rem !important;
  }
  .foodai-topbar h1 {
    font-size: .9rem !important;
  }
  /* Stat boxy v dashboardu: menší font */
  .foodai-stat .stat-value {
    font-size: 1.6rem !important;
  }
}

/* ── Brand ────────────────────────────────────────────────── */
.foodai-brand {
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-height);
}

/* ── Sidebar nav ──────────────────────────────────────────── */
.foodai-nav-link {
  color: #adb5bd;
  border-radius: 6px;
  padding: .45rem .75rem;
  display: flex;
  align-items: center;
  gap: .55rem;
  font-size: .875rem;
  transition: background .15s, color .15s;
}

.foodai-nav-link:hover {
  background: rgba(255,255,255,.06);
  color: #fff;
}

.foodai-nav-link.active {
  background: rgba(13,110,253,.2);
  color: #6ea8fe;
  font-weight: 500;
}

.foodai-nav-link i {
  font-size: 1rem;
  width: 1.2rem;
  text-align: center;
}

.foodai-nav-divider {
  border-top: 1px solid var(--border);
}

/* ── User panel ───────────────────────────────────────────── */
.foodai-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #0d6efd;
  color: #fff;
  font-size: .8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Top bar ──────────────────────────────────────────────── */
.foodai-topbar {
  min-height: var(--topbar-height);
  /* height NESMÍ být fixed — mobile sub-toolbar (foodai-topbar-mobile-actions)
     dělá topbar 2-řádkový. Fixed height clip-uje obsah a způsobí overlap
     s contentem pod topbarem (bug 2026-05-15d). */
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow: visible;   /* Bootstrap dropdown menu musí přesahovat topbar */
}

/* ── Content ──────────────────────────────────────────────── */
.foodai-content {
  flex: 1;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
}

/* ── Tables ───────────────────────────────────────────────── */
.table {
  --bs-table-bg: transparent;
  --bs-table-striped-bg: rgba(255,255,255,.03);
  --bs-table-hover-bg: rgba(255,255,255,.05);
  --bs-table-color: #dee2e6;
  --bs-table-border-color: var(--border);
}

/* ── Stat cards ───────────────────────────────────────────── */
.foodai-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
}

.foodai-stat .stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: #fff;
}

.foodai-stat .stat-label {
  font-size: .78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-top: .25rem;
}

.foodai-stat-highlight {
  border-color: rgba(255, 193, 7, .2);
  background: linear-gradient(135deg, var(--bg-card) 60%, rgba(255,193,7,.04));
}

.foodai-stat-locked {
  opacity: .65;
  border-style: dashed;
}

/* ── Badge overrides ──────────────────────────────────────── */
.badge {
  font-weight: 500;
}

/* ── Forms (dark) ─────────────────────────────────────────── */
.foodai-input {
  background: #0f1117;
  border-color: rgba(255,255,255,.15);
  color: #e0e0e0;
}

.foodai-input:focus {
  background: #0f1117;
  border-color: #0d6efd;
  color: #fff;
  box-shadow: 0 0 0 .2rem rgba(13,110,253,.25);
}

.foodai-input::placeholder {
  color: #555;
}

/* Disabled/readonly state — udrž dark theme (Bootstrap default by jinak dal světlé pozadí). */
.foodai-input:disabled,
.foodai-input[readonly] {
  background: #1a1d24;
  color: #999;
  border-color: rgba(255,255,255,.08);
  cursor: not-allowed;
}

/* Select v disabled stavu má specifické chování — explicit override. */
select.foodai-input:disabled {
  background-color: #1a1d24 !important;
  color: #999 !important;
  opacity: 1;  /* Bootstrap přidává opacity:.65 = příliš tmavé */
}

/* ── Login page ───────────────────────────────────────────── */
.foodai-login-body {
  background: var(--bg-dark);
  min-height: 100vh;
}

.foodai-login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem 2rem;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
}

.foodai-login-logo {
  width: 56px;
  height: 56px;
  background: rgba(13,110,253,.15);
  border: 1px solid rgba(13,110,253,.3);
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: #6ea8fe;
}

/* Input groups in login form — keep dark */
.input-group-text {
  background: #0f1117;
  border-color: rgba(255,255,255,.15);
}

/* ── Device status dot ───────────────────────────────────── */
.foodai-status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}
.foodai-status-dot.online  { background: #198754; box-shadow: 0 0 6px rgba(25,135,84,.6); }
.foodai-status-dot.idle    { background: #ffc107; box-shadow: 0 0 6px rgba(255,193,7,.5); }
.foodai-status-dot.offline { background: #6c757d; }

/* ── Scrollbar (subtle) ───────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.22); }
