/* ── INFOTECH IoT Panel ── layout.css ── */

/* ── App Shell ── */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Top Bar ── */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-height);
  background: var(--md-surface);
  border-bottom: 1px solid var(--md-outline);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  z-index: 200;
  box-shadow: var(--md-elevation-1);
}

.topbar-logo {
  display: flex;
  align-items: center;
}

.topbar-logo-img {
  height: 32px;
  width: auto;
  /* shift SVG palette toward primary teal */
  filter: brightness(0) saturate(100%) invert(79%) sepia(40%) saturate(600%) hue-rotate(136deg) brightness(1.05);
  transition: filter 300ms ease;
}

.topbar-logo-img:hover {
  filter: brightness(0) saturate(100%) invert(82%) sepia(50%) saturate(700%) hue-rotate(136deg) brightness(1.15);
}

.topbar-device {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
  padding: 4px 12px 4px 8px;
  background: var(--md-surface-2);
  border-radius: 20px;
  border: 1px solid var(--md-outline);
}

.device-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--md-on-surface);
  white-space: nowrap;
}

.device-online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--md-success);
  box-shadow: 0 0 6px var(--md-success);
  animation: pulse-dot 2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px var(--md-success); }
  50%       { opacity: 0.7; box-shadow: 0 0 12px var(--md-success); }
}

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

.topbar-menu-btn { display: flex; }

/* ── Sidebar ── */
#sidebar {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--md-surface);
  border-right: 1px solid var(--md-outline);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
  overflow: hidden;
}

.sidebar-header {
  padding: 20px 16px 12px;
}

.sidebar-device-card {
  background: var(--md-primary-container);
  border: 1px solid var(--md-primary-border);
  border-radius: var(--radius-lg);
  padding: 14px;
}

.sidebar-device-name {
  font-family: var(--font-head);
  font-size: 15px;
  font-weight: 700;
  color: var(--md-primary);
  letter-spacing: 0.3px;
  margin-bottom: 4px;
}

.sidebar-device-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--md-on-surface-var);
  letter-spacing: 0.5px;
}

.sidebar-device-loc {
  font-size: 11px;
  color: var(--md-on-surface-var);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.sidebar-device-loc .material-symbols-rounded {
  font-size: 14px;
}

#nav-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 8px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--md-on-surface-var);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  text-align: left;
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1px;
  position: relative;
  overflow: hidden;
}

.nav-item:hover {
  background: var(--md-surface-2);
  color: var(--md-on-surface);
}

.nav-item.active {
  background: var(--md-primary-container);
  color: var(--md-primary);
}

.nav-item.active .nav-icon {
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}

.nav-icon { font-size: 22px; }

.sidebar-footer {
  padding: 12px 16px 20px;
  border-top: 1px solid var(--md-outline);
}

.sidebar-version {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--md-on-surface-var);
  opacity: 0.6;
}

/* ── Sidebar Overlay ── */
#sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 150;
  opacity: 0;
  pointer-events: none;   /* invisible = non-interactive */
  transition: opacity var(--transition);
}

#sidebar-overlay.visible {
  opacity: 1;
  pointer-events: auto;   /* visible = clickable to close */
}

/* ── Desktop sidebar collapse ── */
body.sidebar-collapsed #sidebar {
  transform: translateX(-100%);
}

body.sidebar-collapsed #content-area {
  margin-left: 0;
  align-items: center;   /* center all children when sidebar is gone */
}

body.sidebar-collapsed #main-content,
body.sidebar-collapsed .app-footer {
  max-width: 1280px;
}

/* ── Main Content ── */
#content-area {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  min-height: calc(100vh - var(--topbar-height));
  transition: margin-left 260ms cubic-bezier(0.2, 0, 0, 1);
  display: flex;
  flex-direction: column;
  align-items: stretch;  /* default: fill full width */
}

#main-content {
  padding: 24px;
  width: 100%;           /* fill available space (up to max-width) */
  max-width: 100%;       /* uncapped when sidebar is open */
}

/* ── View transitions ── */
#main-content.fade-out {
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 150ms ease, transform 150ms ease;
}

#main-content.fade-in {
  animation: fadeInUp 300ms cubic-bezier(0.2, 0, 0, 1);
}

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

/* ── Sidebar reflow pulse — fires when layout shifts ── */
#main-content.reflow-pulse {
  animation: reflowPulse 280ms cubic-bezier(0.2, 0, 0, 1);
}

@keyframes reflowPulse {
  0%   { opacity: 0.7; }
  100% { opacity: 1; }
}

/* ── App Footer ── */
.app-footer {
  margin-top: auto;
  width: 100%;           /* needed so max-width centering works */
  max-width: 100%;
  padding: 14px 24px;
  border-top: 1px solid var(--md-outline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-footer-brand {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--md-on-surface-var);
  opacity: 0.55;
  letter-spacing: 0.5px;
}

.app-footer-logo {
  height: 18px;
  width: auto;
  filter: brightness(0) saturate(100%) invert(79%) sepia(40%) saturate(600%) hue-rotate(136deg) brightness(1.0);
  opacity: 0.5;
}

/* ── Light-mode logo overrides ── */
.light-theme .topbar-logo-img {
  filter: brightness(0) saturate(100%) invert(34%) sepia(68%) saturate(550%) hue-rotate(148deg) brightness(0.88);
}

.light-theme .topbar-logo-img:hover {
  filter: brightness(0) saturate(100%) invert(34%) sepia(68%) saturate(600%) hue-rotate(148deg) brightness(0.78);
}

.light-theme .app-footer-logo {
  filter: brightness(0) saturate(100%) invert(34%) sepia(68%) saturate(550%) hue-rotate(148deg) brightness(0.88);
  opacity: 0.45;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  #main-content { padding: 16px; }
}

@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
    z-index: 300;
  }
  #sidebar.open {
    transform: translateX(0);
    box-shadow: var(--md-elevation-3);
  }

  /* On mobile sidebar-collapsed class is not used; overlay handles it */
  body.sidebar-collapsed #sidebar { transform: translateX(-100%); }
  body.sidebar-collapsed #content-area { margin-left: 0; }

  #content-area { margin-left: 0; }
  #main-content { padding: 12px; }

  .topbar-device { display: none; }
  .app-footer { padding: 12px 16px; }
}
