/* ============================================================
   LAYOUT.CSS — Topbar, Sidebar, Main Content
   Think LAB — Laboratório Dinâmico de Empresas
   ============================================================ */

/* ── APP SHELL ── */
#screen-app {
  display: none;
}
#screen-app.active {
  display: block;
}

/* ── LOGIN SCREEN — styles in css/login-landing.css ── */
#screen-login {
  display: block;
}

/* Video background */
.login-video-bg {
  position: absolute;
  top: 50%;
  left: 50%;
  min-width: 100%;
  min-height: 100%;
  width: auto;
  height: auto;
  transform: translate(-50%, -50%);
  object-fit: cover;
  z-index: 0;
}

/* Blue-tinted overlay on top of video */
.login-video-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(10,16,80,0.82) 0%, rgba(21,101,192,0.75) 100%);
  z-index: 1;
}

.login-badge {
  background: linear-gradient(135deg, var(--gold), #e6c84a, var(--gold));
  color: #1a1a1a;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 0.3rem 1.1rem;
  border-radius: var(--radius-full);
  margin-bottom: 1rem;
  box-shadow: 0 2px 8px rgba(201,162,39,0.4);
}

.login-logo {
  font-size: 3rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: -2px;
  margin-bottom: 0.25rem;
  line-height: 1;
  position: relative;
  z-index: 2;
}
.login-logo span { color: var(--accent-light); }

.login-subtitle {
  color: rgba(255,255,255,0.6);
  font-size: 0.9rem;
  margin-bottom: 2rem;
  letter-spacing: 0.06em;
  text-align: center;
  position: relative;
  z-index: 2;
}

.login-card {
  background: rgba(255,255,255,0.97);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,0.1);
  padding: 2.5rem 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 2;
}

.login-card h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1.5rem;
  text-align: center;
}

.login-rules-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1.2rem;
  color: rgba(255,255,255,0.75);
  font-size: 0.9rem;
  text-decoration: none;
  position: relative;
  z-index: 2;
  transition: color 0.2s;
}
.login-rules-link:hover {
  color: #fff;
  text-decoration: underline;
}

.login-footer {
  margin-top: 1.5rem;
  color: rgba(255,255,255,0.7);
  font-size: 0.75rem;
  text-align: center;
  position: relative;
  z-index: 2;
}

/* ── TOPBAR ── */
#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: var(--primary);
  display: flex;
  align-items: center;
  padding: 0 1rem 0 0;
  z-index: var(--z-topbar);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  gap: 0.75rem;
}

/* Hamburger */
#btn-menu {
  width: var(--topbar-height);
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
  border-radius: 0;
}
#btn-menu:hover { background: rgba(255,255,255,0.1); color: #fff; }

#btn-menu .hamburger {
  width: 22px;
  height: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}
#btn-menu .hamburger span {
  display: block;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: all var(--transition);
}

/* Logo */
.topbar-logo {
  font-size: 1.35rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: -0.5px;
  margin-right: 0.5rem;
  flex-shrink: 0;
  line-height: 1;
}
.topbar-logo span { color: var(--accent-light); }

/* Divider */
.topbar-divider {
  width: 1px;
  height: 28px;
  background: rgba(255,255,255,0.2);
  flex-shrink: 0;
}

/* Company badge */
.topbar-company {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius-full);
  padding: 0.25rem 0.75rem 0.25rem 0.4rem;
  flex-shrink: 0;
}
.topbar-company-icon {
  width: 26px;
  height: 26px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}
#topbar-company-name {
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Round badge */
.topbar-round {
  background: rgba(245,124,0,0.25);
  border: 1px solid rgba(245,124,0,0.4);
  color: var(--accent-light);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  letter-spacing: 0.03em;
}

/* Spacer */
.topbar-spacer { flex: 1; }

/* Connection status */
.topbar-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.6);
  flex-shrink: 0;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  transition: background var(--transition);
  flex-shrink: 0;
}
.status-dot.connected    { background: #4caf50; box-shadow: 0 0 6px #4caf50; }
.status-dot.disconnected { background: var(--danger); }
.status-dot.connecting   { background: var(--warning); animation: pulse 1.2s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Topbar actions */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.topbar-username {
  color: rgba(255,255,255,0.7);
  font-size: 0.8rem;
  font-weight: 500;
}

#btn-logout {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.9);
  padding: 0.3rem 0.9rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
#btn-logout:hover { background: rgba(255,255,255,0.22); border-color: rgba(255,255,255,0.35); }

/* ── SIDEBAR ── */
#sidebar {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--topbar-height) - var(--footer-height));
  background: #fff;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: var(--z-sidebar);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-slow), box-shadow var(--transition-slow);
  box-shadow: 2px 0 8px rgba(0,0,0,0.04);
}

.sidebar-header {
  padding: 1.25rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border-light);
}

.sidebar-game-info {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  color: #fff;
}

.sidebar-game-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.7;
  margin-bottom: 0.2rem;
}

.sidebar-game-name {
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.3;
}

.sidebar-game-status {
  font-size: 0.72rem;
  opacity: 0.75;
  margin-top: 0.2rem;
}

/* Nav */
.sidebar-nav {
  padding: 0.75rem 0;
  flex: 1;
}

.sidebar-section {
  margin-bottom: 0.25rem;
}

.sidebar-section-label {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted-light);
  padding: 0.6rem 1rem 0.3rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  position: relative;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.sidebar-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity var(--transition);
}

.sidebar-link:hover {
  background: var(--bg-alt);
  color: var(--primary);
}
.sidebar-link:hover svg { opacity: 1; }

.sidebar-link.active {
  background: linear-gradient(90deg, rgba(57,73,171,0.1), rgba(57,73,171,0.05));
  color: var(--primary);
  font-weight: 700;
  border-right: 3px solid var(--primary);
}
.sidebar-link.active svg { opacity: 1; }

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
}

/* Admin only */
.sidebar-link.admin-only { display: none; }
.sidebar-section.admin-only { display: none; }

/* Sidebar footer */
.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border-light);
}

.sidebar-round-info {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  font-size: 0.78rem;
}

.sidebar-round-info .round-label {
  color: var(--muted);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.sidebar-round-info .round-value {
  color: var(--primary);
  font-weight: 800;
  font-size: 1.1rem;
  line-height: 1;
  margin-top: 0.1rem;
}

.sidebar-round-info .round-status {
  color: var(--muted);
  font-size: 0.72rem;
  margin-top: 0.1rem;
}

/* ── MAIN CONTENT ── */
#main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  min-height: calc(100vh - var(--topbar-height) - var(--footer-height));
  padding: 2rem 2rem calc(var(--footer-height) + 1.5rem);
  transition: margin-left var(--transition-slow);
}

/* ── RODAPÉ FIXO (app shell) ── */
#app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--footer-height);
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 1rem;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.2;
  z-index: var(--z-footer);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.18);
}

/* Content panels */
.panel {
  display: none;
  animation: fadeIn 0.25s ease;
}
.panel.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Page header */
.page-header {
  margin-bottom: 1.75rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
}

.page-subtitle {
  color: var(--muted);
  font-size: 0.875rem;
  margin-top: 0.2rem;
  font-weight: 400;
}

.page-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

/* Grid layouts */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.full-row {
  grid-column: 1 / -1;
}

/* ── SIDEBAR COLLAPSED STATE ── */
body.sidebar-collapsed #sidebar {
  transform: translateX(calc(-1 * var(--sidebar-width)));
  box-shadow: none;
}

body.sidebar-collapsed #main-content {
  margin-left: 0;
}

/* ── SIDEBAR OVERLAY (mobile) ── */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: calc(var(--z-sidebar) - 1);
  cursor: pointer;
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .charts-row { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  :root {
    --topbar-height: 56px;
  }

  /* On mobile: sidebar is off-canvas by default */
  #sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
    box-shadow: none;
  }

  body.sidebar-open #sidebar {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  body.sidebar-open #sidebar-overlay {
    display: block;
  }

  /* Reset collapsed state on mobile */
  body.sidebar-collapsed #sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
  }

  #main-content {
    margin-left: 0;
    padding: 1.25rem 1rem calc(var(--footer-height) + 1rem);
  }

  body.sidebar-collapsed #main-content {
    margin-left: 0;
  }

  .topbar-company { display: none; }
  .topbar-username { display: none; }
  .topbar-divider { display: none; }
  .topbar-status .status-text { display: none; }

  .page-header { flex-direction: column; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  #main-content { padding: 1rem 0.75rem calc(var(--footer-height) + 0.75rem); }
}

/* ── TOAST NOTIFICATIONS ── */
#toast-container {
  position: fixed;
  bottom: calc(var(--footer-height) + 1.25rem);
  right: 1.5rem;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: var(--primary-dark);
  color: #fff;
  padding: 0.75rem 1.1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  font-size: 0.875rem;
  font-weight: 500;
  max-width: 340px;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: toastIn 0.3s ease;
  border-left: 4px solid var(--accent-light);
}

.toast.toast-success { background: var(--success); border-left-color: #a5d6a7; }
.toast.toast-danger  { background: var(--danger);  border-left-color: #ef9a9a; }
.toast.toast-warning { background: #6d4c0f; border-left-color: var(--accent-light); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(20px); }
}
