/* =====================================================
   app.css – Shared layout: Header / Main / Footer
   ===================================================== */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  background: #080808;
  color: #e2e8f0;
  font-family: monospace;
}

/* ===== APP HEADER ===== */
#app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: 44px;
  background: #0a0a0a;
  border-bottom: 1px solid rgba(0,255,65,0.15);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
}

.header-logo {
  color: #00ff41;
  text-decoration: none;
  font-size: .78rem;
  font-weight: bold;
  letter-spacing: 1px;
  white-space: nowrap;
  flex-shrink: 0;
}
.header-logo:hover { color: #22ff55; }

#header-game-name {
  flex: 1;
  font-size: .78rem;
  color: #64748b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}

/* Connection indicator */
.header-conn-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ef4444;
  flex-shrink: 0;
  transition: background .4s;
}
.header-conn-dot.connected { background: #22c55e; }

#header-conn-text {
  font-size: .68rem;
  color: #64748b;
  white-space: nowrap;
}

/* Header buttons */
.header-btn {
  background: transparent;
  border: 1px solid rgba(0,255,65,0.3);
  color: #00ff41;
  font-family: monospace;
  font-size: .7rem;
  padding: 4px 9px;
  cursor: pointer;
  letter-spacing: .5px;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.header-btn:hover { background: rgba(0,255,65,0.1); }
.header-btn.header-btn-leave  { border-color: rgba(239,68,68,.4); color: #ef4444; }
.header-btn.header-btn-leave:hover { background: rgba(239,68,68,.1); }
.header-btn.header-btn-logout { border-color: rgba(100,116,139,.3); color: #94a3b8; }

#header-player-name {
  font-size: .75rem;
  color: #00e5ff;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== MAIN CONTENT ===== */
#app-main {
  flex: 1;
  width: 100dvw;
  min-height: calc(100dvh + 44px /* header */ + 44px /* footer */);
  flex-direction: column;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
}

/* ===== APP FOOTER (CHAT) ===== */
#app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 900;
}

#chat-footer {
  background: #0a0a0a;
  border-top: 1px solid rgba(0,255,65,0.15);
  font-family: monospace;
}

#chat-footer-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  cursor: pointer;
  user-select: none;
  height: 36px;
}
#chat-footer-header:hover { background: rgba(0,255,65,0.04); }

.chat-footer-label {
  color: #00ff41;
  font-size: .8rem;
}

#chat-footer-room {
  font-size: .72rem;
  color: #64748b;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-badge {
  background: #f59e0b;
  color: #000;
  font-size: .6rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 8px;
  min-width: 16px;
  text-align: center;
}

#chat-footer-chevron {
  color: #475569;
  font-size: .75rem;
  transition: transform .2s;
}

#chat-footer-body {
  display: none;
  flex-direction: column;
  max-height: 280px;
  border-top: 1px solid rgba(0,255,65,0.08);
}
#chat-footer-body.open { display: flex; }
#chat-footer-header.open #chat-footer-chevron { transform: rotate(180deg); }

#chat-footer-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: .78rem;
  max-height: 230px;
}

#chat-footer-messages .chat-msg { padding: 3px 0; }
#chat-footer-messages .chat-msg.system { color: #475569; font-style: italic; }
#chat-footer-messages .chat-msg.self   { color: #e2e8f0; }
#chat-footer-messages .chat-msg.other  { color: #e2e8f0; }
#chat-footer-messages .chat-msg.admin-msg { color: #f59e0b; }
#chat-footer-messages .chat-name { font-size: .65rem; color: #64748b; margin-bottom: 1px; }
#chat-footer-messages .chat-name.self-name { color: #00e5ff; }
#chat-footer-messages .chat-text { }

#chat-footer-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-top: 1px solid rgba(0,255,65,0.08);
}

#chat-sender-name {
  font-size: .65rem;
  color: #475569;
  white-space: nowrap;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
}

#chat-footer-input {
  flex: 1;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(0,255,65,0.15);
  color: #e2e8f0;
  font-family: monospace;
  font-size: .78rem;
  padding: 5px 8px;
  outline: none;
}
#chat-footer-input:focus { border-color: rgba(0,255,65,0.4); }

#chat-footer-send {
  background: transparent;
  border: 1px solid rgba(0,255,65,0.2);
  color: #00ff41;
  font-size: .8rem;
  padding: 4px 8px;
  cursor: pointer;
}
#chat-footer-send:hover { background: rgba(0,255,65,0.1); }

/* ===== SHARED MODALS ===== */
.app-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4000;
  backdrop-filter: blur(4px);
}
.app-modal.hidden { display: none; }

.app-modal-box {
  background: #0a0a0a;
  border: 1px solid rgba(0,255,65,0.25);
  padding: 28px 22px;
  width: min(360px, 92vw);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-family: monospace;
}

.app-modal-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  color: #00ff41;
  font-size: 1.1rem;
  cursor: pointer;
}

.app-modal-title {
  font-size: .9rem;
  color: #00ff41;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.app-input {
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(0,255,65,0.25);
  color: #e2e8f0;
  font-family: monospace;
  font-size: .85rem;
  padding: 9px 12px;
  width: 100%;
  outline: none;
}
.app-input:focus { border-color: rgba(0,255,65,0.5); }

.app-btn {
  background: transparent;
  border: 1px solid rgba(0,255,65,0.4);
  color: #00ff41;
  font-family: monospace;
  font-size: .78rem;
  padding: 9px 16px;
  cursor: pointer;
  letter-spacing: 1px;
  width: 100%;
  margin-top: 4px;
}
.app-btn:hover { background: rgba(0,255,65,0.1); }
.app-btn-green { }

.app-error {
  color: #f87171;
  font-size: .78rem;
  padding: 4px 0;
}
.app-error.hidden { display: none; }

/* Auth tabs */
.app-modal .auth-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
}
.app-modal .auth-tab {
  flex: 1;
  background: transparent;
  border: 1px solid rgba(0,255,65,0.2);
  color: #475569;
  font-family: monospace;
  font-size: .72rem;
  padding: 6px;
  cursor: pointer;
}
.app-modal .auth-tab.active { border-color: #00ff41; color: #00ff41; }

.auth-tab-content.hidden { display: none; }

/* Snackbar (global) */
#app-snackbar {
  position: fixed;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #e2e8f0;
  font-family: monospace;
  font-size: .8rem;
  padding: 10px 20px;
  border: 1px solid rgba(0,255,65,0.2);
  border-radius: 4px;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s;
  white-space: nowrap;
  max-width: 90vw;
  text-align: center;
}
#app-snackbar.show { opacity: 1; }
