/* =============================================
   FREEBOARD — Chan-style CSS
   Palette: cream, beige, peach, dark maroon
   ============================================= */

/* --- 1. CSS Custom Properties --- */
:root {
  --bg-main:   #ffffee;
  --bg-card:   #f0e0d6;
  --accent:    #eeaa88;
  --text-dark: #800000;
  --border:    #d9bfb7;
  --reply-indent: 2rem;
  --sidebar-width: 240px;
  --max-thumb: 80px;
  --chat-width: 260px;
}

/* --- 2. Base Reset --- */
*, *::before, *::after { box-sizing: border-box; }

body {
  background-color: var(--bg-main);
  color: #333;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
  margin: 0;
  padding: 0;
}

a { color: var(--text-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* --- 3. Auth Screen --- */
#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-main);
}

.auth-card {
  width: 320px;
  background: var(--bg-card);
  border: 1px solid var(--text-dark);
  padding: 1.5rem;
}

.auth-logo-text {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--text-dark);
  text-align: center;
  font-style: italic;
  margin-bottom: 1.25rem;
  letter-spacing: -0.05em;
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--text-dark);
  margin-bottom: 1rem;
}

.auth-tab-btn {
  flex: 1;
  background: var(--bg-main);
  border: 1px solid var(--text-dark);
  border-bottom: none;
  padding: 0.3rem;
  font-size: 0.7rem;
  font-weight: bold;
  text-transform: uppercase;
  cursor: pointer;
  color: #888;
  margin-bottom: -1px;
}

.auth-tab-btn.active-tab {
  background: var(--bg-card);
  color: var(--text-dark);
  border-bottom: 1px solid var(--bg-card);
}

.auth-error-msg {
  font-size: 10px;
  color: #cc0000;
  font-weight: bold;
  text-align: center;
  min-height: 1rem;
  text-transform: uppercase;
  margin-top: 0.4rem;
}

/* --- 4. Board Layout --- */
#board-screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.board-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--accent);
  border-bottom: 2px solid var(--text-dark);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 1rem;
}

.logo-main {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--text-dark);
  letter-spacing: -0.05em;
  font-style: italic;
}

.header-sep { color: var(--text-dark); opacity: 0.4; }

.user-id {
  font-size: 0.7rem;
  font-weight: bold;
  color: #117743;
}

.logout-link {
  font-size: 10px;
  color: var(--text-dark);
  cursor: pointer;
  margin-left: auto;
}
.logout-link:hover { text-decoration: underline; }

#board-layout {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  align-items: flex-start;
}

#sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  position: sticky;
  top: 3rem;
}

#main-content {
  flex: 1;
  min-width: 0;
}

/* --- 5. Shared Components --- */
.input-field {
  width: 100%;
  padding: 0.35rem 0.5rem;
  border: 1px solid #aaa;
  font-size: 0.8rem;
  outline: none;
  background: white;
  display: block;
  margin-bottom: 0.4rem;
  font-family: inherit;
}

.input-field:focus { border-color: var(--text-dark); }

.post-box {
  background: var(--accent);
  border: 1px solid var(--text-dark);
  padding: 0.75rem;
}

.submit-btn {
  background: white;
  border: 1px solid #888;
  padding: 0.25rem 0.75rem;
  font-size: 0.7rem;
  font-weight: bold;
  text-transform: uppercase;
  cursor: pointer;
  font-family: inherit;
}
.submit-btn:hover { background: #f3f3f3; }

.btn-primary {
  background: var(--accent);
  border: 1px solid var(--text-dark);
  padding: 0.4rem 0.75rem;
  font-weight: bold;
  font-size: 0.7rem;
  text-transform: uppercase;
  cursor: pointer;
  width: 100%;
  font-family: inherit;
}
.btn-primary:hover { background: #e8996e; }

.btn-file {
  font-size: 10px;
  font-weight: bold;
  text-transform: uppercase;
  cursor: pointer;
  background: white;
  border: 1px solid #999;
  padding: 0.2rem 0.5rem;
  font-family: inherit;
}
.btn-file:hover { background: #f0f0f0; }

.status-title {
  font-weight: bold;
  color: var(--text-dark);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
  padding-bottom: 0.25rem;
  font-size: 0.7rem;
  text-transform: uppercase;
}

.back-link {
  display: inline-block;
  font-size: 10px;
  font-weight: bold;
  color: #0000ee;
  cursor: pointer;
  margin-bottom: 0.75rem;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  text-decoration: underline;
}
.back-link:hover { color: #880000; }

/* --- 6. Thread Cards (Feed) --- */
.thread-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.6rem;
  display: flex;
  gap: 0.6rem;
  box-shadow: 2px 2px 0px rgba(0,0,0,0.04);
  margin-bottom: 0.6rem;
}

.thread-thumb {
  width: var(--max-thumb);
  height: var(--max-thumb);
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
  cursor: pointer;
  display: block;
}

.thread-thumb-placeholder {
  width: var(--max-thumb);
  height: var(--max-thumb);
  background: var(--bg-main);
  border: 1px dashed var(--border);
  flex-shrink: 0;
}

.thread-body { flex: 1; min-width: 0; }

.thread-subject {
  font-weight: bold;
  color: var(--text-dark);
  font-size: 0.82rem;
  cursor: pointer;
}
.thread-subject:hover { text-decoration: underline; }

.thread-meta {
  font-size: 10px;
  color: #777;
}

.thread-preview {
  font-size: 0.78rem;
  color: #444;
  margin: 0.2rem 0;
  line-height: 1.4;
  word-break: break-word;
}

/* --- 7. Vote Bar --- */
.vote-bar {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.3rem;
  flex-wrap: wrap;
}

.vote-btn {
  font-size: 10px;
  font-weight: bold;
  border: 1px solid var(--border);
  padding: 1px 5px;
  cursor: pointer;
  background: white;
  color: #555;
  font-family: inherit;
}
.vote-btn:hover { background: #f0f0f0; }

.vote-btn.active-up {
  background: #d4edda;
  color: #155724;
  border-color: #155724;
}
.vote-btn.active-down {
  background: #f8d7da;
  color: #721c24;
  border-color: #721c24;
}

.vote-score {
  font-size: 11px;
  font-weight: bold;
  min-width: 1.5rem;
  text-align: center;
  color: #333;
}

.reply-count {
  font-size: 10px;
  color: #777;
  margin-left: 0.4rem;
}

/* --- 8. Thread View & Reply Chain --- */
.thread-op-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.thread-op-img {
  max-width: 100%;
  max-height: 400px;
  object-fit: contain;
  display: block;
  margin-bottom: 0.5rem;
  border: 1px solid var(--border);
}

.thread-op-text {
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}

.reply-form-box {
  margin-bottom: 0.75rem;
}

.reply-chain {
  margin-left: var(--reply-indent);
  border-left: 2px solid var(--border);
  padding-left: 0.75rem;
}

.reply-card {
  background: white;
  border: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
  margin-bottom: 0.4rem;
}

.reply-author {
  font-size: 10px;
  font-weight: bold;
  color: var(--text-dark);
}

.reply-text {
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 0.2rem;
  line-height: 1.4;
}

/* --- 9. Delete / Action Links --- */
.delete-link {
  font-size: 10px;
  color: #cc0000;
  cursor: pointer;
  margin-left: 0.4rem;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
}
.delete-link:hover { text-decoration: underline; }

/* --- 10. Misc / Badges --- */
.badge {
  display: inline-block;
  padding: 1px 5px;
  font-size: 10px;
  border: 1px solid;
  border-radius: 2px;
}

.no-posts-msg {
  font-size: 0.8rem;
  color: #888;
  padding: 1rem;
  font-style: italic;
}

/* --- 11. Responsive --- */
@media (max-width: 640px) {
  #board-layout {
    flex-direction: column;
    padding: 0.5rem;
  }
  #sidebar {
    width: 100%;
    position: static;
  }
  .thread-card {
    flex-direction: column;
  }
  .thread-thumb,
  .thread-thumb-placeholder {
    width: 100%;
    height: 160px;
  }
  .reply-chain {
    margin-left: 0.5rem;
  }
  #chat-panel {
    width: 100%;
    position: static;
    height: 300px;
  }
}

/* --- 12. Chat Panel --- */
#chat-panel {
  width: var(--chat-width);
  flex-shrink: 0;
  position: sticky;
  top: 3rem;
  height: calc(100vh - 4rem);
  display: flex;
  flex-direction: column;
}

.chat-panel-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

#chat-messages-list {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-height: 0;
}

.chat-bubble {
  background: white;
  border: 1px solid var(--border);
  padding: 0.3rem 0.5rem;
  word-break: break-word;
}

.chat-bubble-own {
  background: #e8f4e8;
  border-color: #aad4aa;
}

.chat-author {
  font-size: 10px;
  font-weight: bold;
  color: var(--text-dark);
  margin-bottom: 1px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.chat-text {
  font-size: 0.78rem;
  line-height: 1.4;
  margin: 0;
}

.chat-time {
  font-size: 9px;
  color: #aaa;
  margin-left: 0.4rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.chat-status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #aaa;
  margin-left: 0.4rem;
  vertical-align: middle;
  transition: background 0.3s;
}
.chat-status-dot.connected { background: #28a745; }
.chat-status-dot.error     { background: #cc0000; }

.chat-empty-msg {
  font-size: 0.75rem;
  color: #aaa;
  font-style: italic;
  text-align: center;
  padding: 1rem 0;
}

.tripcode {
  font-family: monospace;
  color: #228822;
  font-size: 0.8rem;
  margin-left: 0.25rem;
}

.admin-badge {
  background: #800000;
  color: #fff;
  font-size: 0.7rem;
  font-weight: bold;
  padding: 1px 4px;
  border-radius: 2px;
  margin-left: 0.25rem;
  vertical-align: middle;
}

.author-name {
  font-weight: bold;
  color: #228822;
  font-size: 0.8rem;
}

.board-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
}

.board-link {
  font-size: 0.8rem;
  color: #800000;
  text-decoration: none;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--bg-main);
}

.board-link:hover,
.board-link.active-board {
  background: var(--accent);
  border-color: var(--text-dark);
  font-weight: bold;
}

.chat-link {
  font-size: 0.8rem;
  color: #800000;
  text-decoration: none;
  margin-left: auto;
  font-weight: bold;
}

.chat-link:hover { text-decoration: underline; }
