/* =========================================================
   LAYOUT
   ========================================================= */

.site-shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  width: 100%;
}

/* ===== HEADER ===== */

/* Header container with fixed minimum height to prevent layout shift during dynamic loading */
[data-include="header"] {
  min-height: 45px;
  display: block;
}

.core-header {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.4);
  z-index: 100;
}

/* メインヘッダ・ブランド + スローガン */
.header-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 9px;
  border-bottom: 1px solid rgba(91, 255, 169, 0.2);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.brand:hover {
  color: var(--green-bright);
  text-shadow: var(--glow-green);
}

.brand-mark {
  width: 48px;
  height: 48px;
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-name {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.brand-name .ja {
  font-family: var(--font-ja-serif);
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: -0.06em;
  line-height: 1.2;
}

.brand-name .en {
  font-size: 0.6rem;
  letter-spacing: -0.1em;
  text-align: center;
  line-height: 0.8;
  white-space: normal;
  margin-top: 2px;
  text-transform: uppercase;
  font-family: var(--font-en);
  color: var(--text-muted);
}

.header-tools {
  display: flex;
  gap: 12px;
  align-items: center;
}

.header-time {
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

/* 管理サイド用ナビゲーション・監視 */
.header-admin {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 9px;
  border-bottom: 1px solid rgba(91, 255, 169, 0.15);
  gap: 12px;
}

.utility-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
}

.utility-nav a {
  color: var(--green);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.utility-nav a:hover {
  color: var(--green-bright);
  text-shadow: var(--glow-green);
}

.divider {
  color: var(--text-muted);
  opacity: 0.6;
}

.header-message {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.8rem;
  flex: 1;
  justify-content: center;
}

.header-message .en {
  font-size: 0.65em;
  letter-spacing: 0.08em;
}

/* Logout link */
.logout-link {
  font-size: 0.85rem;
  color: var(--green);
  text-decoration: underline;
  transition: all 0.2s ease;
  white-space: nowrap;
  cursor: pointer;
}

.logout-link:hover {
  color: var(--green-bright);
  text-shadow: var(--glow-green);
}

/* System info: 3 rows layout */
.system-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-left: 12px;
  border-left: 1px solid rgba(91, 255, 169, 0.2);
  align-self: stretch;
  justify-content: center;
}

/* システム状況 */
.header-system {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
  padding: 8px 9px;
  font-size: 0.85rem;
  background: rgba(0, 0, 0, 0.15);
}

.system-item {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.system-label {
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.05em;
  min-width: 110px;
  opacity: 0.85;
}

.system-value {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--green);
  font-family: ui-monospace, monospace;
}

.system-value .timestamp {
  letter-spacing: 0.02em;
}

.system-value .connection {
  display: flex;
  align-items: center;
}

.connection-bars {
  display: flex;
  align-items: center;
  gap: 2px;
  width: 80px;
  height: 14px;
}

.connection-bars span {
  flex: 1;
  background: var(--green);
  box-shadow: var(--glow-green);
  animation: pulse 0.8s ease-in-out infinite;
  animation-delay: calc(var(--index, 0) * 0.1s);
}

.status-dot {
  width: 8px;
  height: 8px;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 4px var(--green);
  animation: pulse 2s ease-in-out infinite;
}

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

/* ===== MAIN DASHBOARD GRID ===== */

.dashboard {
  display: grid;
  grid-template-columns: 275px minmax(0, 1fr) 375px;
  gap: 9px;
  padding: 9px;
  flex: 1;
  min-height: 0;
  align-items: start;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 9px;
  overflow-y: auto;
  max-height: 100%;
}

.main-column {
  min-width: 0;
}

.right-column {
  display: flex;
  flex-direction: column;
  gap: 9px;
  position: sticky;
  top: 9px;
  height: fit-content;
  max-height: calc(100vh - 18px);
  overflow-y: auto;
}

/* ===== PANELS ===== */

.panel {
  position: relative;
  padding: 9px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 2px;
}

.panel::before,
.panel::after {
  content: "";
  position: absolute;
  width: 9px;
  height: 9px;
  border: 1px solid var(--line);
}

.panel::before {
  top: -4px;
  left: -4px;
  border-right: none;
  border-bottom: none;
}

.panel::after {
  bottom: -4px;
  right: -4px;
  border-left: none;
  border-top: none;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: -9px -9px 9px -9px;
  padding: 9px;
  border-bottom: 1px solid var(--line-strong);
  gap: 8px;
}

.panel-heading-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.panel-heading-main .ja {
  font-family: var(--font-ja-serif);
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: -0.045em;
}

.panel-heading-main .en {
  font-size: 0.6rem;
}

.panel-heading a {
  white-space: nowrap;
  font-size: 0.75rem;
  color: var(--green);
  transition: all 0.2s ease;
}

.panel-heading a:hover {
  color: var(--green-bright);
}
