/* layout.css — Header, ResBar, TabNav, Sidebar, Content */

/* ── Game Header ────────────────────────────────────────────── */
#game-header {
  height: var(--header-height);
  background: var(--bg-header);
  background-image: url('../img/ui_texture_stone.png');
  background-size: 512px 512px;
  background-repeat: repeat;
  border-bottom: 2px solid var(--border-dark);
  display: flex;
  align-items: center;
  padding: 0 var(--gap-md);
  gap: var(--gap-lg);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

#game-header .header-logo {
  font-family: var(--font-header);
  font-size: 18px;
  font-weight: bold;
  color: var(--text-header);
  white-space: nowrap;
  letter-spacing: 1px;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.6);
}

#game-header .header-village {
  color: var(--amber-light);
  font-size: var(--font-size-base);
  white-space: nowrap;
}

#game-header .header-spacer {
  flex: 1;
}

#game-header .header-user {
  display: flex;
  align-items: center;
  gap: var(--gap-md);
  color: var(--text-light);
  font-size: var(--font-size-sm);
}

#game-header .header-points {
  color: var(--amber-light);
  font-weight: bold;
}

#game-header .btn-logout {
  background: var(--red);
  color: var(--text-light);
  border: 1px solid var(--border-dark);
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--font-size-sm);
  transition: background 0.15s;
}
#game-header .btn-logout:hover {
  background: var(--red-light);
}

#game-header .btn-new-ui {
  background: linear-gradient(135deg, #2a5a2a, #3d8b3d);
  color: #c8e6c8;
  border: 1px solid #4caf50;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
  display: inline-block;
  margin-right: 8px;
  transition: background 0.2s;
}
#game-header .btn-new-ui:hover {
  background: linear-gradient(135deg, #3d8b3d, #4caf50);
  color: #fff;
}


/* ── Player Avatar (Header) ────────────────────────────────────── */
#header-avatar.header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#header-avatar.header-avatar:hover {
  border-color: var(--amber);
  box-shadow: 0 0 6px rgba(200,150,50,0.5);
}

/* ── Global Chat Ticker ──────────────────────────────────────── */
#global-chat-ticker {
  height: 26px;
  background: #0f0a04;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  font-size: 12px;
  cursor: pointer;
  overflow: hidden;
  white-space: nowrap;
}
#global-chat-ticker:hover {
  background: #1a0f06;
}
.gct-label {
  color: var(--gold, #d4a853);
  font-weight: bold;
  flex-shrink: 0;
}
.gct-text {
  color: #c9a96e;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  animation: gctFadeIn 0.4s ease;
}
@keyframes gctFadeIn {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: translateX(0); }
}
.gct-author {
  color: var(--amber, #e8a840);
  font-weight: 600;
}

/* ── Resource Bar ────────────────────────────────────────────── */
#resource-bar {
  height: var(--resbar-height);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--gap-md);
  gap: var(--gap-lg);
  font-size: 14px;
}

.res-item {
  display: flex;
  align-items: center;
  gap: var(--gap-xs);
  white-space: nowrap;
}

.res-icon {
  font-size: 14px;
}

.res-label {
  color: #1a0f06;
  font-weight: bold;
  font-size: 14px;
}

.res-value {
  color: #1a0f06;
  min-width: 50px;
  font-size: 14px;
  font-weight: bold;
}

.res-wood   { color: var(--res-wood);  }
.res-clay   { color: var(--res-clay);  }
.res-iron   { color: var(--res-iron);  }
.res-pop    { color: var(--res-pop);   }
.res-tokens { color: var(--amber);     }

.res-separator {
  color: var(--border);
  margin: 0 var(--gap-xs);
}

/* ── Tab Navigation ──────────────────────────────────────────── */
#tab-nav {
  height: var(--tabnav-height);
  background: var(--bg-nav);
  background-image: url('../img/ui_texture_wood.png');
  background-size: 256px 256px;
  background-repeat: repeat;
  border-bottom: 2px solid var(--border-dark);
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  scrollbar-width: none;
}
#tab-nav::-webkit-scrollbar { display: none; }

.tab-btn {
  background: transparent;
  border: none;
  border-right: 1px solid var(--border-dark);
  color: var(--text-light);
  font-size: 15px;
  font-weight: bold;
  padding: 0 var(--gap-md);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  font-family: var(--font-ui);
  height: 100%;
}

.tab-btn:hover {
  background: rgba(255,255,255,0.1);
}

.tab-btn.active {
  background: var(--bg-nav-active);
  color: #1a0f06;
  font-weight: bold;
  border-bottom: 2px solid var(--amber);
}

/* ── Game Layout (Sidebar + Main) ────────────────────────────── */
#game-layout {
  display: flex;
  min-height: calc(100vh - var(--header-height) - var(--resbar-height) - var(--tabnav-height));
  background: var(--bg-page);
}

/* ── Building Sidebar ────────────────────────────────────────── */
#building-nav {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-panel);
  background-image: url('../img/ui_texture_wood.png');
  background-size: 256px 256px;
  background-repeat: repeat;
  border-right: 1px solid var(--border);
  padding: var(--gap-sm) 0;
  overflow-y: auto;
}

.building-nav-item {
  display: flex;
  align-items: center;
  gap: var(--gap-xs);
  padding: 5px var(--gap-sm);
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  font-size: 13px;
  color: #2c1a0e;
  transition: background 0.1s;
}

.building-nav-item:hover {
  background: var(--bg-row-even);
}

.building-nav-item.active {
  background: var(--bg-content);
  font-weight: bold;
  color: var(--text-link);
}

.building-nav-icon {
  font-size: 14px;
  width: 18px;
  text-align: center;
}

.building-nav-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.building-nav-level {
  color: #1a0f06;
  font-size: 13px;
  font-weight: bold;
}

/* ── Hide building sidebar on map tab ────────────────────── */
#game-layout:has(#tab-map:not(.hidden)) #building-nav { display: none; }

/* ── Hide building sidebar globally (UI-Redesign Sprint) ── */
#building-nav { display: none !important; }

/* ── Main Content ────────────────────────────────────────────── */
#main-content {
  flex: 1;
  padding: var(--gap-md);
  background: var(--bg-content);
  background-image: url('../img/ui_texture_parchment.png');
  background-size: 512px 512px;
  background-repeat: repeat;
  overflow-y: auto;
  min-width: 0;
}

/* ── Tab Panels ──────────────────────────────────────────────── */
.tab-panel {
  display: block;
  background-image: url('../img/ui_texture_parchment.png');
  background-size: 512px 512px;
  background-repeat: repeat;
  position: relative;    /* NEU — für absolut-positioniertes Video */
  overflow: hidden;      /* NEU — Video nicht außerhalb sichtbar */
}
.tab-panel.hidden {
  display: none;
}

/* ── Section Headers ─────────────────────────────────────────── */
.section-header {
  background: var(--bg-header-row);
  border: 1px solid var(--border);
  padding: var(--gap-xs) var(--gap-sm);
  margin-bottom: var(--gap-sm);
  font-family: var(--font-header);
  font-size: 16px;
  color: #1a0f06;
  font-weight: bold;
  background-image: url('../img/ui_panel_header.png');
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
}

/* ── Content Panel ───────────────────────────────────────────── */
.content-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  margin-bottom: var(--gap-md);
  box-shadow: var(--shadow-panel);
}

.content-panel-header {
  background: var(--bg-header-row);
  border-bottom: 1px solid var(--border);
  padding: var(--gap-xs) var(--gap-md);
  font-family: var(--font-header);
  font-size: 15px;
  font-weight: bold;
  color: #1a0f06;
  background-image: url('../img/ui_panel_header.png');
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
}

.content-panel-body {
  padding: var(--gap-md);
}

/* ── Tab-specific wrap padding ───────────────────────────────── */
.barracks-wrap,
.buildings-wrap,
.smithy-wrap,
.stable-wrap,
.workshop-wrap,
.noble-court-wrap { padding: 12px; }

/* ── Buildings / Smithy Tables ───────────────────────────────── */
.buildings-table,
.smithy-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.buildings-table th,
.smithy-table th {
  color: #1a0f06;
  font-weight: bold;
  text-align: left;
  padding: 5px 8px;
  border-bottom: 1px solid #3a2810;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.buildings-table td,
.smithy-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #2a1a08;
  vertical-align: middle;
  font-size: 14px;
  color: #2c1a0e;
}
/* Group header rows (used in smithy.js table) */
.table-group-header td {
  background: rgba(90,62,27,0.2);
  color: var(--text-muted);
  font-size: 13px;
  text-transform: uppercase;
  padding: 4px 8px;
  letter-spacing: 0.05em;
}

/* ── Minimap ────────────────────────────────────────────────────── */
#minimap-container {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(20, 15, 10, 0.92);
  border: 1px solid #8b6914;
  border-radius: 4px;
  z-index: 10;
  padding: 4px;
}
#minimap-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #c8a84b;
  font-size: 11px;
  padding: 2px 4px 4px;
  font-family: 'MedievalSharp', serif;
}
#minimap-zoom-btns button {
  background: #3a2a10;
  border: 1px solid #8b6914;
  color: #c8a84b;
  width: 20px;
  height: 20px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  margin-left: 2px;
  border-radius: 2px;
}
#minimap-canvas {
  display: block;
  cursor: crosshair;
}

/* ── Minimap Sidebar Mode (largest zoom level) ──────────────────── */
#minimap-container.sidebar-mode {
  position: relative;
  top: auto;
  right: auto;
  border-left: 2px solid #8b6914;
  border-radius: 0;
  align-self: flex-start;
  z-index: 1;
}

/* Karten-Tab: echtes Vollbild */
#game-layout:has(#tab-map:not(.hidden)) #game-header  { display: none; }
#game-layout:has(#tab-map:not(.hidden)) #resource-bar { display: none; }
#game-layout:has(#tab-map:not(.hidden)) #tab-nav      { display: none; }

/* Karten-Tab: #game-layout + #main-content + #tab-map volle Höhe */
#game-layout:has(#tab-map:not(.hidden)) {
  height: 90vh;
  min-height: 0;
}
#game-layout:has(#tab-map:not(.hidden)) #main-content {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
}
#tab-map {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ═══════════════════════════════════════════════════════════════
   SPRINT 26 — Gebäude-Tab Lesbarkeit (2026-03-19)
   ═══════════════════════════════════════════════════════════════ */

/* ── Gebäude-Namen (1. Spalte td) ──────────────────────────────── */
.buildings-table td:first-child {
  font-size: 15px !important;
  font-weight: bold !important;
  color: #1a0f06 !important;
  white-space: nowrap;
}

/* ── Gebäude-Icons ─────────────────────────────────────────────── */
.building-icon {
  width: 48px !important;
  height: 48px !important;
  min-width: 48px;
  min-height: 48px;
  object-fit: cover;
  border-radius: 3px;
  border: 1px solid var(--border, #5a3e1b);
  vertical-align: middle;
  display: inline-block;
  filter: brightness(1.1);
}

/* ── Ressourcenkosten ──────────────────────────────────────────── */
.res-cost {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 14px !important;
  font-weight: bold !important;
  color: #2c1a0e;
  white-space: nowrap;
  margin-right: 6px;
}

.res-insufficient {
  color: #8b1a1a !important;
  font-weight: bold !important;
}

/* ── Bauzeit-Spalte ────────────────────────────────────────────── */
.buildings-table td:last-child {
  font-size: 14px !important;
  font-weight: bold !important;
  color: #2c1a0e !important;
  text-align: right;
  white-space: nowrap;
}

/* ── Voraussetzungen-Block ─────────────────────────────────────── */
.buildings-table td:nth-child(3) > div {
  background: rgba(90,62,27,0.08);
  border: 1px solid rgba(90,62,27,0.25);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 13px !important;
  font-style: italic;
  color: #2c1a0e !important;
}

.buildings-table td:nth-child(3) > div > div {
  font-size: 13px !important;
  color: #2c1a0e !important;
  font-style: italic;
}

/* ── Globale Minimum-Regel: kein Text < 13px im Gebäude-Tab ───── */
.buildings-wrap * {
  font-size: max(13px, inherit);
}
.buildings-wrap {
  color: #1a0f06;
}

/* ── Sicherstellung: alle Farben dunkler als #666 ──────────────── */
.buildings-table td {
  color: #2c1a0e !important;
}
.buildings-table th {
  color: #1a0f06 !important;
}

/* ── Offline-Banner ─────────────────────────────────────────────── */
#offline-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 9999;
  background: #c0392b;
  color: #fff;
  text-align: center;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 0.3px;
}
