/* ===== VARIABLES ===== */
:root {
  --blue-1: #e3f0fb;
  --blue-2: #b8d8f5;
  --blue-3: #5fa8e0;
  --blue-4: #1565c0;
  --blue-5: #0d3b7a;
  --bg: #f0f7ff;
  --card-bg: #ffffff;
  --border: #c0d8ef;
  --text: #1a2740;
  --text-light: #4a6080;
  --official-bg: #e8f2ff;
  --official-border: #1565c0;
  --shadow: 0 2px 8px rgba(21,101,192,0.08);
  --radius: 10px;
  --font: 'Lato', 'Segoe UI', Arial, sans-serif;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 30px;
}

/* ===== LAYOUT ===== */
.container {
  max-width: 700px;
  margin: 0 auto;
  padding: 12px 10px;
}

/* ===== INFO BLOCK ===== */
#info-block {
  background: var(--card-bg);
  border: 1.5px solid var(--blue-3);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  min-height: 80px;
}

/* ===== CHAT SECTION ===== */
#chat-section {
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

#chat-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 8px 12px;
  background: var(--blue-1);
  border-bottom: 1px solid var(--border);
}

#filter-label {
  font-size: 0.85em;
  color: var(--blue-4);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
#filter-label input[type="checkbox"] {
  accent-color: var(--blue-4);
  width: 15px; height: 15px;
  cursor: pointer;
}

/* Chat messages container */
#messages-container {
  height: 360px;
  overflow-y: auto;
  padding: 10px 10px 6px 10px;
  scroll-behavior: smooth;
}

/* Individual message */
.msg-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #fafcff;
  position: relative;
  transition: background 0.15s;
}
.msg-item.officiel {
  background: var(--official-bg);
  border-color: var(--official-border);
  border-left: 3px solid var(--official-border);
}
.msg-item:last-child { margin-bottom: 0; }

.msg-body {
  font-size: 0.93em;
  line-height: 1.55;
  color: var(--text);
  word-break: break-word;
  white-space: pre-wrap;
}
/* Allow safe HTML inside messages */
.msg-body a { color: var(--blue-4); text-decoration: underline; }
.msg-body img { max-width: 100%; border-radius: 6px; margin-top: 4px; }
.msg-body iframe { max-width: 100%; margin-top: 4px; }

.msg-meta {
  text-align: right;
  font-size: 0.78em;
  color: var(--text-light);
  font-style: italic;
  margin-top: 6px;
}
.msg-meta .badge-officiel {
  color: var(--blue-4);
  font-weight: bold;
  font-style: normal;
  margin-right: 4px;
}

/* Admin controls on messages */
.msg-admin-controls {
  position: absolute;
  top: 6px; right: 6px;
  display: flex;
  gap: 4px;
}
.btn-del, .btn-edit {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 0.85em;
  line-height: 1;
  transition: background 0.15s;
}
.btn-del { color: #c0392b; }
.btn-del:hover { background: #fde; }
.btn-edit { color: var(--blue-4); }
.btn-edit:hover { background: var(--blue-1); }

/* Edit inline area */
.edit-area {
  width: 100%;
  min-height: 60px;
  padding: 6px;
  border: 1px solid var(--blue-3);
  border-radius: 6px;
  font-size: 0.9em;
  margin-top: 6px;
  resize: vertical;
  font-family: var(--font);
}
.btn-save-edit {
  margin-top: 4px;
  background: var(--blue-4);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px 12px;
  cursor: pointer;
  font-size: 0.85em;
}
.btn-save-edit:hover { background: var(--blue-5); }
.btn-cancel-edit {
  margin-top: 4px;
  margin-left: 6px;
  background: #eee;
  color: #333;
  border: none;
  border-radius: 6px;
  padding: 4px 12px;
  cursor: pointer;
  font-size: 0.85em;
}

/* Loading / empty */
#chat-loading, #chat-empty {
  text-align: center;
  color: var(--text-light);
  font-size: 0.9em;
  padding: 20px 0;
}

/* ===== POST FORM ===== */
#post-section {
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 12px 10px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

#drop-zone {
  position: relative;
  border: 2px dashed var(--blue-3);
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--blue-1);
  transition: border-color 0.2s, background 0.2s;
  cursor: text;
}
#drop-zone.drag-over {
  border-color: var(--blue-4);
  background: var(--blue-2);
}
#drop-zone textarea {
  display: block;
  width: 100%;
  min-height: 80px;
  background: transparent;
  border: none;
  outline: none;
  padding: 10px;
  font-size: 0.95em;
  font-family: var(--font);
  color: var(--text);
  resize: vertical;
}
#drop-zone textarea::placeholder { color: #8ab4d4; }
#drop-hint {
  position: absolute;
  bottom: 6px; right: 10px;
  font-size: 0.72em;
  color: #8ab4d4;
  pointer-events: none;
}

/* Image preview in drop zone */
#file-preview {
  padding: 0 10px 8px;
}
#file-preview img {
  max-width: 100%;
  max-height: 180px;
  border-radius: 6px;
  border: 1px solid var(--border);
}
#file-preview a {
  color: var(--blue-4);
  font-size: 0.88em;
  text-decoration: underline;
}
#file-preview .remove-file {
  display: inline-block;
  margin-left: 8px;
  color: #c0392b;
  cursor: pointer;
  font-size: 0.85em;
}

.post-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
#signature-input {
  flex: 1;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 0.92em;
  background: #f8fbff;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}
#signature-input:focus { border-color: var(--blue-3); }
#signature-input::placeholder { color: #8ab4d4; }

#btn-send {
  padding: 8px 20px;
  background: var(--blue-4);
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 0.95em;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  letter-spacing: 0.03em;
}
#btn-send:hover { background: var(--blue-5); }
#btn-send:disabled { background: var(--blue-3); cursor: not-allowed; }

#hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

#post-status {
  font-size: 0.82em;
  min-height: 18px;
  margin-top: 5px;
  text-align: right;
}
#post-status.ok { color: #27ae60; }
#post-status.err { color: #c0392b; }

/* ===== LINK TILES ===== */
#links-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.link-tile {
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 10px;
  text-align: center;
  text-decoration: none;
  color: var(--blue-4);
  font-size: 0.92em;
  font-weight: 600;
  box-shadow: var(--shadow);
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70px;
  word-break: break-word;
}
.link-tile:hover {
  background: var(--blue-1);
  border-color: var(--blue-3);
  transform: translateY(-2px);
}
.link-tile .tile-icon { font-size: 1.3em; margin-bottom: 4px; display: block; }

/* ===== ADMIN BAR ===== */
#admin-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 0 0;
  margin-top: 4px;
}
#admin-code {
  padding: 6px 10px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 0.88em;
  width: 200px;
  background: #f8fbff;
  color: var(--text);
  outline: none;
}
#admin-code:focus { border-color: var(--blue-3); }
#btn-admin-go {
  padding: 6px 14px;
  background: var(--blue-4);
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 0.88em;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.15s;
}
#btn-admin-go:hover { background: var(--blue-5); }
#admin-status {
  font-size: 0.8em;
  min-height: 16px;
}
#admin-status.ok { color: #27ae60; }
#admin-status.err { color: #c0392b; }

/* Admin logout */
#admin-active-bar {
  background: var(--blue-1);
  border: 1px solid var(--blue-3);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.83em;
  color: var(--blue-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  gap: 10px;
}
#btn-logout {
  background: none;
  border: 1px solid var(--blue-3);
  border-radius: 5px;
  padding: 2px 8px;
  color: var(--blue-4);
  cursor: pointer;
  font-size: 0.9em;
}
#btn-logout:hover { background: #fff; }

/* ===== SCROLLBAR ===== */
#messages-container::-webkit-scrollbar { width: 6px; }
#messages-container::-webkit-scrollbar-track { background: var(--blue-1); }
#messages-container::-webkit-scrollbar-thumb { background: var(--blue-3); border-radius: 4px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
  body { font-size: 15px; }
  #links-section { grid-template-columns: 1fr 1fr; }
  .link-tile { font-size: 0.85em; padding: 14px 6px; min-height: 60px; }
  #messages-container { height: 300px; }
  .post-row { flex-wrap: wrap; }
  #signature-input { min-width: 0; }
  #admin-code { width: 150px; }
}
