/*
 * TabIS — rám aplikace (sidebar, header, mobilní lišta, rychlé hledání).
 * Markup: @layout.latte, chování: js/layout-shell.js, data menu: App\Model\Navigation.
 *
 * Sidebar je VŽDY tmavý (i ve světlém režimu); světlý/tmavý režim přepíná jen header a obsah.
 * Barvy jsou tokeny na :root, tmavý režim je přepisuje pod html[data-theme="dark"].
 */

:root {
	--tb-header-h: 56px;
	--tb-sidebar-w: 248px;
	--tb-rail-w: 72px;
	--tb-tabbar-h: 60px;

	--tb-accent: #1f7a4d;
	--tb-accent-hover: #18633e;
	--tb-accent-soft: #e2f0e7;

	--tb-surface: #ffffff;
	--tb-text: #1c2420;
	--tb-muted: #5d6862;
	--tb-border: #e2e6e2;
	--tb-hover: #eef1ee;
	--tb-input: #f3f5f2;
	--tb-shadow: 0 14px 36px rgba(0, 0, 0, .14);

	/* Sidebar — stejný v obou režimech */
	--tb-sb-bg: #13201a;
	--tb-sb-text: #c8d3cc;
	--tb-sb-muted: #8b9b92;
	--tb-sb-hover: rgba(255, 255, 255, .06);
	--tb-sb-active-bg: rgba(76, 195, 138, .16);
	--tb-sb-active-text: #ffffff;
	--tb-sb-active-icon: #5fd39c;
	--tb-sb-border: rgba(255, 255, 255, .09);
	--tb-sb-pop: #1b2a23;
}

html[data-theme="dark"] {
	--tb-accent: #2a8f5c;
	--tb-accent-hover: #33a56b;
	--tb-accent-soft: rgba(76, 195, 138, .16);
	--tb-surface: var(--dm-bg2, #22262e);
	--tb-text: var(--dm-text, #d8dce6);
	--tb-muted: var(--dm-text-muted, #8890a0);
	--tb-border: var(--dm-border, #383d4a);
	--tb-hover: var(--dm-bg3, #2a2f3a);
	--tb-input: var(--dm-bg, #1a1d23);
	--tb-shadow: 0 14px 36px rgba(0, 0, 0, .5);
	--tb-sb-bg: #111a15;
}

/* ===== Kostra ===== */
.tb-shell { min-height: 100vh; }

.tb-main {
	margin-left: var(--tb-sidebar-w);
	min-width: 0;
	transition: margin-left .2s;
}

.tb-content {
	display: block;
	padding: 1.25rem 1.5rem .5rem;
	min-width: 0;
}
.tb-footer { margin-top: 2rem; padding-top: .75rem; border-top: 1px solid var(--tb-border); }

/* ===== Sidebar ===== */
.tb-sidebar {
	position: fixed;
	top: 0;
	bottom: 0;
	left: 0;
	z-index: 1035; /* nad headerem, pod modály (1040+) a celoobrazovkovou mapou Průzkumníka (1050) */
	width: var(--tb-sidebar-w);
	display: flex;
	flex-direction: column;
	background: var(--tb-sb-bg);
	color: var(--tb-sb-text);
	border-right: 1px solid var(--tb-sb-border);
	transition: width .2s, transform .25s;
}

.tb-brand {
	display: flex;
	align-items: center;
	justify-content: space-between;
	height: var(--tb-header-h);
	padding: 0 14px 0 18px;
	flex: none;
}
.tb-brand-link, .tb-brand-link:hover {
	display: flex;
	align-items: center;
	gap: 10px;
	color: var(--tb-sb-active-text) !important;
	font-size: 17px;
	font-weight: 700;
	letter-spacing: -.01em;
	text-decoration: none;
}
.tb-brand-link img { border-radius: 8px; flex: none; }
.tb-sb-close { color: var(--tb-sb-text); background: none; border: 0; font-size: 1.2rem; width: 40px; height: 40px; border-radius: 10px; }
.tb-sb-close:hover { background: var(--tb-sb-hover); }

/* Výběr tábora (rok) */
.tb-camp { padding: 0 12px 10px; flex: none; }
.tb-camp-btn {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	min-height: 48px;
	padding: 6px 10px;
	border-radius: 10px;
	border: 1px solid var(--tb-sb-border);
	background: var(--tb-sb-hover);
	color: var(--tb-sb-text);
	text-align: left;
}
.tb-camp-btn:hover, .tb-camp-btn:focus { background: rgba(255, 255, 255, .1); outline: none; }
.tb-camp-btn > .fa-campground { color: var(--tb-sb-active-icon); font-size: 1rem; }
.tb-camp-text { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.25; }
.tb-camp-text small { font-size: 11px; color: var(--tb-sb-muted); }
.tb-camp-text strong { color: var(--tb-sb-active-text); font-weight: 600; }
.tb-camp-caret { color: var(--tb-sb-muted); font-size: .8rem; }
html .tb-sidebar .tb-camp-menu { /* html … = přebít dark.css .dropdown-menu */
	width: calc(var(--tb-sidebar-w) - 24px);
	max-height: 60vh;
	overflow-y: auto;
	padding: 6px;
	background: var(--tb-sb-pop);
	border: 1px solid var(--tb-sb-border);
	border-radius: 12px;
	box-shadow: 0 12px 32px rgba(0, 0, 0, .35);
}
html .tb-sidebar .tb-camp-menu .dropdown-item { color: var(--tb-sb-text); border-radius: 7px; padding: .45rem .75rem; }
html .tb-sidebar .tb-camp-menu .dropdown-item:hover, html .tb-sidebar .tb-camp-menu .dropdown-item:focus { background: var(--tb-sb-hover); color: #fff; }
html .tb-sidebar .tb-camp-menu .dropdown-item.active { background: var(--tb-sb-active-bg); color: #fff; font-weight: 600; }

/* Položky menu */
.tb-nav-scroll {
	flex: 1;
	overflow-y: auto;
	overflow-x: hidden;
	padding: 0 12px 12px;
	overscroll-behavior-y: contain;
	scrollbar-width: thin;
	scrollbar-color: rgba(255, 255, 255, .15) transparent;
}
.tb-group-items { display: flex; flex-direction: column; gap: 2px; }
.tb-group-title {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	padding: 16px 12px 6px;
	background: none;
	border: 0;
	color: var(--tb-sb-muted);
	font-size: 11px;
	font-weight: 600;
	letter-spacing: .06em;
	text-transform: uppercase;
}
.tb-group-title:hover { color: var(--tb-sb-text); }
.tb-group-title:focus { outline: none; }
.tb-group-title:focus-visible { outline: 2px solid var(--tb-sb-active-icon); outline-offset: -2px; border-radius: 6px; }
.tb-group-caret { font-size: .65rem; transition: transform .15s; }
.tb-group.collapsed .tb-group-caret { transform: rotate(-90deg); }
.tb-group.collapsed .tb-group-items { display: none; }

.tb-sidebar .tb-nav-link {
	display: flex;
	align-items: center;
	gap: 12px;
	min-height: 38px;
	padding: 0 12px;
	border-radius: 9px;
	color: var(--tb-sb-text);
	font-size: 14px;
	font-weight: 500;
	text-decoration: none;
	white-space: nowrap;
}
.tb-sidebar .tb-nav-link .fa-fw { color: var(--tb-sb-muted); font-size: 15px; }
.tb-sidebar .tb-nav-link:hover { background: var(--tb-sb-hover); color: #fff; }
.tb-sidebar .tb-nav-link:hover .fa-fw { color: var(--tb-sb-text); }
.tb-sidebar .tb-nav-link.active { background: var(--tb-sb-active-bg); color: var(--tb-sb-active-text); }
.tb-sidebar .tb-nav-link.active .fa-fw { color: var(--tb-sb-active-icon); }
.tb-sidebar .tb-nav-link .tb-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }

.tb-badge {
	display: inline-flex;
	align-items: center;
	height: 20px;
	padding: 0 7px;
	border-radius: 10px;
	font-size: 11px;
	font-weight: 700;
}
.tb-badge-new { background: #f5c451; color: #3d2c00; }

.tb-sb-footer {
	flex: none;
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: 8px 12px 12px;
	border-top: 1px solid var(--tb-sb-border);
}
.tb-sidebar .tb-version { padding: 6px 12px 0; font-size: 11px; color: var(--tb-sb-muted); text-decoration: none; }
.tb-sidebar .tb-version:hover { color: var(--tb-sb-text); }

/* ===== Sbalené menu (jen ikony) — desktop ===== */
@media (min-width: 768px) {
	.tb-rail .tb-sidebar { width: var(--tb-rail-w); }
	.tb-rail .tb-main { margin-left: var(--tb-rail-w); }
	.tb-rail .tb-sidebar .tb-label,
	.tb-rail .tb-sidebar .tb-badge { display: none; }
	.tb-rail .tb-brand { justify-content: center; padding: 0; }
	.tb-rail .tb-camp-btn { justify-content: center; padding: 6px 0; }
	.tb-rail .tb-sidebar .tb-nav-link { justify-content: center; padding: 0; }
	.tb-rail .tb-group-title { justify-content: center; padding: 12px 0 4px; }
	.tb-rail .tb-group.collapsed .tb-group-items { display: flex; } /* v liště ikon se skupiny nesbalují */
	.tb-rail .tb-group.collapsed .tb-group-caret { transform: none; }
}

/* ===== Header ===== */
.tb-header {
	position: sticky;
	top: 0;
	z-index: 1020;
	display: flex;
	align-items: center;
	gap: 8px;
	height: var(--tb-header-h);
	padding: 0 16px 0 10px;
	background: var(--tb-surface);
	border-bottom: 1px solid var(--tb-border);
	color: var(--tb-text);
}

.tb-icon-btn {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	flex: none;
	border-radius: 10px;
	border: 0;
	background: none;
	color: var(--tb-text) !important;
	font-size: 1.05rem;
	text-decoration: none !important;
}
.tb-icon-btn:hover, .tb-icon-btn:focus { background: var(--tb-hover); outline: none; }
#notifBadge {
	position: absolute;
	top: 4px;
	right: 3px;
	min-width: 17px;
	padding: 2px 4px;
	border-radius: 9px;
	font-size: 10px;
	line-height: 1.1;
	border: 2px solid var(--tb-surface);
}

.tb-title { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; margin-right: 8px; }
.tb-title small { font-size: 11px; color: var(--tb-muted); }
.tb-title span { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 28vw; }

.tb-search {
	flex: 1 1 260px;
	max-width: 460px;
	margin: 0 auto;
	display: flex;
	align-items: center;
	gap: 10px;
	height: 40px;
	padding: 0 12px;
	border-radius: 10px;
	border: 1px solid var(--tb-border);
	background: var(--tb-input);
	color: var(--tb-muted);
	text-align: left;
	font-size: 14px;
}
.tb-search:hover { border-color: var(--tb-muted); }
.tb-search:focus { outline: none; box-shadow: 0 0 0 3px var(--tb-accent-soft); }
.tb-search-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tb-shell kbd, .tb-palette kbd {
	font-family: inherit;
	font-size: 11px;
	padding: 2px 6px;
	border-radius: 5px;
	border: 1px solid var(--tb-border);
	background: var(--tb-surface);
	color: var(--tb-muted);
	box-shadow: none;
}

.tb-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; flex: none; }

.tb-btn-new, .tb-btn-new:focus {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	height: 40px;
	padding: 0 14px;
	border-radius: 10px;
	background: var(--tb-accent);
	color: #fff !important;
	font-weight: 600;
	font-size: 14px;
	border: 0;
	margin-right: 4px;
}
.tb-btn-new:hover { background: var(--tb-accent-hover); }

.tb-user-btn {
	display: flex;
	align-items: center;
	gap: 8px;
	height: 44px;
	padding: 0 6px 0 4px;
	border-radius: 10px;
	border: 0;
	background: none;
	color: var(--tb-text);
	text-align: left;
}
.tb-user-btn:hover, .tb-user-btn:focus { background: var(--tb-hover); outline: none; }
.tb-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: none; }
.tb-user-text { display: flex; flex-direction: column; line-height: 1.15; max-width: 140px; }
.tb-user-text strong { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-user-text small { font-size: 11px; color: var(--tb-muted); white-space: nowrap; }
.tb-user-caret { font-size: .65rem; color: var(--tb-muted); }

/* Rozbalovací menu v headeru */
.tb-menu {
	min-width: 240px;
	padding: 6px;
	border-radius: 12px;
	border: 1px solid var(--tb-border);
	background: var(--tb-surface);
	box-shadow: var(--tb-shadow);
	margin-top: 6px;
}
.tb-menu .dropdown-item {
	display: flex;
	align-items: center;
	gap: 8px;
	min-height: 38px;
	padding: 0 12px;
	border-radius: 8px;
	color: var(--tb-text);
	font-size: 14px;
}
.tb-menu .dropdown-item .fa-fw { color: var(--tb-muted); }
.tb-menu .dropdown-item:hover, .tb-menu .dropdown-item:focus { background: var(--tb-hover); color: var(--tb-text); }
.tb-menu .dropdown-item.active { background: var(--tb-accent-soft); color: var(--tb-text); font-weight: 600; }
.tb-menu .dropdown-item.text-danger, .tb-menu .dropdown-item.text-danger .fa-fw { color: #c92a2a !important; }
html[data-theme="dark"] .tb-menu .dropdown-item.text-danger, html[data-theme="dark"] .tb-menu .dropdown-item.text-danger .fa-fw { color: #ff8a8a !important; }
.tb-menu .dropdown-divider { border-color: var(--tb-border); margin: 6px 0; }
.tb-user-menu { width: 280px; }
.tb-user-head { display: flex; flex-direction: column; padding: 8px 12px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--tb-border); }
.tb-user-head small { color: var(--tb-muted); }

.tb-theme { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 6px 4px 12px; font-size: 13px; color: var(--tb-muted); }
.tb-theme-seg { display: inline-flex; padding: 3px; border-radius: 9px; background: var(--tb-input); border: 1px solid var(--tb-border); }
.tb-theme-seg button {
	border: 0;
	background: none;
	color: var(--tb-muted);
	font-size: 12px;
	padding: 4px 8px;
	border-radius: 6px;
	white-space: nowrap;
}
.tb-theme-seg button:hover { color: var(--tb-text); }
.tb-theme-seg button.active { background: var(--tb-surface); color: var(--tb-text); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); font-weight: 600; }

/* Popup notifikací (pozici a zobrazení řídí notifications.js) */
.tb-notif-popup {
	position: fixed;
	z-index: 9999;
	max-height: 400px;
	overflow-y: auto;
	padding: 4px;
	background: var(--tb-surface);
	color: var(--tb-text);
	border: 1px solid var(--tb-border);
	border-radius: 12px;
	box-shadow: var(--tb-shadow);
}
.tb-notif-popup .dropdown-header { border-bottom: 1px solid var(--tb-border); color: var(--tb-text); font-weight: 600; }
.tb-notif-popup .dropdown-item { border-radius: 8px; white-space: normal; color: var(--tb-text); }
.tb-notif-popup .dropdown-item:hover { background: var(--tb-hover); }

/* ===== Rychlé hledání (Ctrl K) ===== */
.tb-palette {
	position: fixed;
	inset: 0;
	z-index: 10000;
	display: flex;
	justify-content: center;
	align-items: flex-start;
	padding: 12vh 16px 16px;
	background: rgba(10, 16, 13, .45);
}
.tb-palette[hidden] { display: none; }
.tb-palette-box {
	width: 600px;
	max-width: 100%;
	border-radius: 16px;
	background: var(--tb-surface);
	color: var(--tb-text);
	border: 1px solid var(--tb-border);
	box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
	overflow: hidden;
}
.tb-palette-input { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--tb-border); color: var(--tb-muted); }
.tb-palette-input input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 16px; color: var(--tb-text); min-width: 0; }
.tb-palette-list { max-height: 50vh; overflow-y: auto; padding: 8px; }
.tb-palette-sec { padding: 8px 14px 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--tb-muted); }
.tb-palette-item {
	display: flex;
	align-items: center;
	gap: 12px;
	min-height: 42px;
	padding: 0 14px;
	border-radius: 9px;
	color: var(--tb-text) !important;
	text-decoration: none !important;
	font-size: 14px;
}
.tb-palette-item .fa-fw { color: var(--tb-muted); }
.tb-palette-item.on { background: var(--tb-hover); }
.tb-palette-item.on .fa-fw { color: var(--tb-accent); }
.tb-palette-empty { padding: 18px 14px; color: var(--tb-muted); }
.tb-palette-help { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--tb-border); font-size: 12px; color: var(--tb-muted); }

/* ===== Mobilní spodní lišta ===== */
.tb-tabbar {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 1030;
	display: flex;
	align-items: stretch;
	height: calc(var(--tb-tabbar-h) + env(safe-area-inset-bottom, 0px));
	padding: 0 4px env(safe-area-inset-bottom, 0px);
	background: var(--tb-surface);
	border-top: 1px solid var(--tb-border);
}
.tb-tab {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 3px;
	min-width: 0;
	border: 0;
	background: none;
	color: var(--tb-muted) !important;
	font-size: 11px;
	font-weight: 500;
	text-decoration: none !important;
}
.tb-tab i { font-size: 1.15rem; }
.tb-tab span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tb-tab.active { color: var(--tb-accent) !important; }
html[data-theme="dark"] .tb-tab.active { color: var(--tb-sb-active-icon) !important; }
.tb-tab-plus {
	width: 52px;
	height: 52px;
	margin-top: -20px;
	border-radius: 50%;
	border: 4px solid var(--tb-surface);
	background: var(--tb-accent);
	color: #fff;
	font-size: 1.2rem;
	box-shadow: 0 8px 20px rgba(31, 122, 77, .4);
}
.tb-tabbar .dropup .dropdown-menu { left: 50% !important; transform: translateX(-50%) !important; top: auto !important; bottom: 100%; margin-bottom: 10px; }

/* ===== Mobil: sidebar jako zásuvka ===== */
.tb-backdrop { display: none; }

@media (max-width: 767.98px) {
	.tb-main { margin-left: 0; }
	.tb-sidebar {
		width: min(300px, 86vw);
		transform: translateX(-105%);
		box-shadow: none;
		z-index: 1045;
	}
	.tb-drawer-open .tb-sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .4); }
	.tb-drawer-open .tb-backdrop {
		display: block;
		position: fixed;
		inset: 0;
		z-index: 1044;
		background: rgba(10, 16, 13, .5);
	}
	.tb-drawer-open body { overflow: hidden; }
	html .tb-sidebar .tb-camp-menu { width: calc(min(300px, 86vw) - 24px); }

	.tb-header { padding: 0 6px 0 4px; gap: 4px; }
	#tbNavToggle { display: none; } /* na mobilu menu otevírá spodní lišta */
	.tb-title { margin-left: 8px; }
	.tb-title span { max-width: 40vw; }
	.tb-search { flex: none; width: 40px; padding: 0; justify-content: center; margin: 0 0 0 auto; border: 0; background: none; color: var(--tb-text); }
	.tb-search-text, .tb-search kbd { display: none; }
	.tb-actions { margin-left: 0; }
	.tb-actions .tb-btn-new { display: none; } /* „+ Nový" je na mobilu uprostřed spodní lišty */
	.tb-user-text, .tb-header .tb-user-caret { display: none; } /* .tb-header … = přebít .fas z fontawesome.min.css */
	.tb-actions > a.tb-btn-new { display: inline-flex; } /* „Přihlásit" pro nepřihlášené zůstává */

	.tb-content { padding: 1rem .9rem .5rem; padding-bottom: calc(var(--tb-tabbar-h) + 1rem); }

	/* Chat nesmí ležet pod spodní lištou */
	#chatToggleBtn { bottom: calc(var(--tb-tabbar-h) + 12px + env(safe-area-inset-bottom, 0px)); }
	#chatDrawer { bottom: calc(var(--tb-tabbar-h) + 68px); }
	.chat-popup { bottom: calc(var(--tb-tabbar-h) + 8px); height: calc(70vh - var(--tb-tabbar-h)); }
}

@media (min-width: 768px) and (max-width: 991.98px) {
	.tb-user-text { display: none; }
	.tb-search kbd { display: none; }
}

@media print {
	.tb-main { margin-left: 0 !important; }
	.tb-content { padding: 0 !important; }
}
