/* ════════════════════════════════════════════════
   Hoodstars — Mobile-First CSS
   ════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&display=swap');

/* ── Μεταβλητές ──────────────────────────────────── */
:root {
  --bg-0:        #0f0f14;   /* πιο σκοτεινό */
  --bg-1:        #16161e;   /* sidebar */
  --bg-2:        #1e1e2a;   /* channel sidebar */
  --bg-3:        #252533;   /* cards, input */
  --bg-hover:    #2d2d3d;
  --bg-active:   #35354a;

  --text-1:      #f0f0f8;
  --text-2:      #a0a0b8;
  --text-3:      #606078;

  --brand:       #7c6af7;   /* μοβ-μπλε */
  --brand-2:     #9d8fff;
  --brand-glow:  rgba(124,106,247,.25);
  --gold:        #f5c842;
  --gold-dim:    rgba(245,200,66,.15);
  --green:       #3dd68c;
  --red:         #f05a5a;
  --red-hover:   #c43e3e;
  --yellow:      #f5c842;

  --divider:     rgba(255,255,255,.06);
  --radius-sm:   6px;
  --radius:      10px;
  --radius-lg:   14px;
  --radius-xl:   20px;

  --font: 'Outfit', 'Segoe UI', system-ui, sans-serif;

  /* Layout */
  --server-w:    68px;
  --sidebar-w:   230px;
  --members-w:   220px;
  --topbar-h:    52px;
}

/* ── Reset ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg-0);
  color: var(--text-1);
  height: 100%; overflow: hidden;
  font-size: 15px; line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ───────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 3px; }

/* ════════════════════════════════════════════════
   MOBILE TOPBAR
   ════════════════════════════════════════════════ */
#mobile-topbar {
  display: none;
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--bg-1);
  z-index: 50;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  border-bottom: 1px solid var(--divider);
}
#mobile-title {
  font-weight: 700; font-size: 17px;
  display: flex; align-items: center; gap: 6px;
}
.hs-logo { font-size: 20px; }
.mobile-icon-btn {
  width: 40px; height: 40px;
  background: none; border: none;
  color: var(--text-2); font-size: 18px;
  cursor: pointer; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.mobile-icon-btn:hover, .mobile-icon-btn:active {
  background: var(--bg-hover); color: var(--text-1);
}

/* ── Sidebar Overlay ─────────────────────────────── */
#sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 40;
}
#sidebar-overlay.visible { display: block; }

/* ════════════════════════════════════════════════
   LAYOUT (Desktop)
   ════════════════════════════════════════════════ */
#app {
  display: flex;
  height: 100vh; width: 100vw;
}

/* ── Left Panel ──────────────────────────────────── */
#left-panel {
  display: flex;
  width: calc(var(--server-w) + var(--sidebar-w));
  flex-shrink: 0;
}

/* ── Server List ─────────────────────────────────── */
#server-list {
  width: var(--server-w);
  background: var(--bg-0);
  display: flex; flex-direction: column;
  align-items: center;
  padding: 10px 0;
  gap: 6px;
  overflow-y: auto; overflow-x: hidden;
  border-right: 1px solid var(--divider);
}

/* Logo at top */
#server-list::before {
  content: '⭐';
  font-size: 26px;
  display: flex; align-items: center; justify-content: center;
  width: 46px; height: 46px;
  background: linear-gradient(135deg, var(--brand), var(--gold));
  border-radius: var(--radius);
  flex-shrink: 0;
  margin-bottom: 2px;
  box-shadow: 0 4px 16px var(--brand-glow);
}

.server-divider {
  width: 28px; height: 2px;
  background: var(--divider); border-radius: 1px; flex-shrink: 0;
}

.server-icon {
  width: 46px; height: 46px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
  background: var(--bg-3);
  color: var(--text-2);
  position: relative;
  transition: border-radius .2s ease, background .2s, color .2s, box-shadow .2s;
  overflow: hidden; flex-shrink: 0;
  user-select: none;
}
.server-icon img { width: 100%; height: 100%; object-fit: cover; }
.server-icon:hover {
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 12px var(--brand-glow);
}
.server-icon.active {
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 16px var(--brand-glow);
}
.server-icon.active::before {
  content: '';
  position: absolute; left: -14px; top: 50%;
  transform: translateY(-50%);
  width: 4px; height: 36px;
  background: var(--text-1); border-radius: 0 3px 3px 0;
}
.server-icon.add-server {
  background: var(--bg-3); color: var(--green); font-size: 22px;
}
.server-icon.add-server:hover { background: var(--green); color: #fff; }

/* ── Channel Sidebar ─────────────────────────────── */
#channel-sidebar {
  width: var(--sidebar-w);
  background: var(--bg-2);
  display: flex; flex-direction: column;
  overflow: hidden;
}

#sidebar-header {
  height: 50px; flex-shrink: 0;
  padding: 0 14px;
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; font-size: 15px;
  border-bottom: 1px solid var(--divider);
  background: var(--bg-2);
}
.close-btn {
  display: none;
  background: none; border: none;
  color: var(--text-2); font-size: 16px;
  cursor: pointer; padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.close-btn:hover { color: var(--text-1); background: var(--bg-hover); }

#channel-list {
  flex: 1; overflow-y: auto;
  padding: 6px 6px 0;
}

.channel-category {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-3);
  padding: 14px 8px 4px;
  display: flex; align-items: center; justify-content: space-between;
  cursor: default;
}
.category-add {
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; cursor: pointer; border-radius: 4px;
  color: var(--text-3);
  transition: color .1s, background .1s;
}
.category-add:hover { color: var(--text-1); background: var(--bg-hover); }

.channel-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer; font-size: 14px; font-weight: 500;
  color: var(--text-3);
  transition: background .1s, color .1s;
  min-height: 36px;
}
.channel-item:hover { background: var(--bg-hover); color: var(--text-2); }
.channel-item.active { background: var(--bg-active); color: var(--text-1); }
.ch-icon { font-size: 16px; flex-shrink: 0; color: var(--text-3); }
.channel-item.active .ch-icon,
.channel-item:hover .ch-icon { color: var(--text-2); }

/* ── User Area ───────────────────────────────────── */
#user-area {
  height: 56px; flex-shrink: 0;
  background: var(--bg-0);
  display: flex; align-items: center;
  padding: 0 8px; gap: 8px;
  border-top: 1px solid var(--divider);
}
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0; overflow: hidden; cursor: pointer;
  position: relative;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.status-dot {
  position: absolute; bottom: 0; right: 0;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--green);
  border: 2px solid var(--bg-0);
}
.user-info { flex: 1; min-width: 0; }
.user-name {
  font-size: 13px; font-weight: 600; color: var(--text-1);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-tag { font-size: 11px; color: var(--text-3); }
.user-actions { display: flex; }
.icon-btn {
  width: 32px; height: 32px;
  border: none; background: none;
  color: var(--text-3); cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; transition: color .1s, background .1s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-1); }

/* ════════════════════════════════════════════════
   MAIN CHAT
   ════════════════════════════════════════════════ */
#main {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; background: var(--bg-1); min-width: 0;
}

#chat-header {
  height: 50px; flex-shrink: 0;
  border-bottom: 1px solid var(--divider);
  display: flex; align-items: center;
  padding: 0 16px; gap: 8px;
  font-weight: 600; font-size: 15px;
  background: var(--bg-1);
}
.ch-hash { color: var(--text-3); font-size: 20px; }

#messages-container {
  flex: 1; overflow-y: auto;
  padding: 12px 0 0;
  display: flex; flex-direction: column;
  overscroll-behavior: contain;
}

/* Message Groups */
.message-group {
  display: flex; gap: 12px;
  padding: 3px 16px;
  transition: background .05s;
}
.message-group:hover { background: var(--bg-hover); }

.msg-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  flex-shrink: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  margin-top: 2px; cursor: pointer;
}
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; }

.msg-content { flex: 1; min-width: 0; }
.msg-header {
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px;
  flex-wrap: wrap;
}
.msg-author {
  font-weight: 600; font-size: 14px; cursor: pointer;
}
.msg-author:hover { text-decoration: underline; }
.msg-time { font-size: 11px; color: var(--text-3); }
.msg-text {
  font-size: 14px; color: var(--text-2);
  word-wrap: break-word; white-space: pre-wrap;
  line-height: 1.5;
}
.msg-edited { font-size: 10px; color: var(--text-3); margin-left: 4px; }
.msg-delete-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-3); font-size: 13px; padding: 0 4px;
  opacity: 0; transition: opacity .15s, color .15s;
}
.message-group:hover .msg-delete-btn { opacity: 1; }
.msg-delete-btn:hover { color: var(--red); }

/* Compact (συνέχεια από ίδιο χρήστη) */
.message-compact {
  padding: 1px 16px 1px 66px;
}
.message-compact:hover { background: var(--bg-hover); }
.message-compact .msg-text { font-size: 14px; }

/* ── Chat Input ───────────────────────────────────── */
#chat-input-area {
  padding: 8px 12px 12px;
  flex-shrink: 0;
}
#chat-input-wrap {
  background: var(--bg-3);
  border-radius: var(--radius-lg);
  display: flex; align-items: flex-end;
  padding: 4px 6px 4px 14px; gap: 4px;
  border: 1.5px solid transparent;
  transition: border-color .2s;
}
#chat-input-wrap:focus-within {
  border-color: var(--brand);
}
#chat-input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text-1); font-family: var(--font);
  font-size: 15px; padding: 7px 0;
  resize: none; max-height: 120px; overflow-y: auto;
  line-height: 1.4;
}
#chat-input::placeholder { color: var(--text-3); }
#send-btn {
  width: 36px; height: 36px;
  background: var(--brand);
  border: none; border-radius: var(--radius-sm);
  cursor: pointer; color: #fff; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
}
#send-btn:hover { background: var(--brand-2); }
#send-btn:active { transform: scale(.92); }

/* ── Members Sidebar ─────────────────────────────── */
#members-sidebar {
  width: var(--members-w); min-width: var(--members-w);
  background: var(--bg-2);
  overflow-y: auto; padding: 10px 6px;
  border-left: 1px solid var(--divider);
  display: none;
}
#members-sidebar.open { display: block; }
.member-category {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-3);
  padding: 14px 8px 4px;
}
.member-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: var(--radius-sm);
  cursor: pointer;
}
.member-item:hover { background: var(--bg-hover); }
.member-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  position: relative; flex-shrink: 0; overflow: hidden;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
}
.member-name {
  font-size: 14px; font-weight: 500; color: var(--text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.member-item:hover .member-name { color: var(--text-1); }

/* ════════════════════════════════════════════════
   AUTH SCREEN
   ════════════════════════════════════════════════ */
#auth-screen {
  position: fixed; inset: 0;
  background: var(--bg-0);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 16px;
}
.auth-box {
  background: var(--bg-2);
  border-radius: var(--radius-xl);
  padding: 32px 28px;
  width: 100%; max-width: 440px;
  box-shadow: 0 12px 48px rgba(0,0,0,.6);
}
.auth-logo {
  text-align: center; margin-bottom: 8px;
  font-size: 40px;
}
.auth-brand {
  text-align: center;
  font-size: 26px; font-weight: 800;
  margin-bottom: 4px;
  background: linear-gradient(135deg, var(--brand-2), var(--gold));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.auth-box > p {
  text-align: center; color: var(--text-2);
  margin-bottom: 24px; font-size: 14px;
}
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-3); margin-bottom: 6px;
}
.form-group input {
  width: 100%; padding: 11px 14px;
  background: var(--bg-3); border: 1.5px solid var(--bg-3);
  border-radius: var(--radius-sm); color: var(--text-1);
  font-family: var(--font); font-size: 15px; outline: none;
  transition: border-color .15s;
  -webkit-appearance: none;
}
.form-group input:focus { border-color: var(--brand); }
.btn-primary {
  width: 100%; padding: 13px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; border: none; border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 15px; font-weight: 600;
  cursor: pointer; transition: opacity .15s, transform .1s;
  -webkit-appearance: none;
}
.btn-primary:hover { opacity: .92; }
.btn-primary:active { transform: scale(.98); }
.auth-switch {
  text-align: center; margin-top: 12px;
  font-size: 13px; color: var(--text-3);
}
.auth-switch a { color: var(--brand-2); cursor: pointer; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }
.error-msg { color: var(--red); font-size: 12px; margin-top: 5px; }
.hidden { display: none !important; }

/* ── Modal ───────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 16px;
}
.modal {
  background: var(--bg-2); border-radius: var(--radius-xl);
  padding: 24px 22px; width: 100%; max-width: 400px;
  box-shadow: 0 12px 48px rgba(0,0,0,.6);
}
.modal h2 { font-size: 18px; margin-bottom: 6px; }
.modal p  { color: var(--text-2); font-size: 13px; margin-bottom: 14px; }
.modal-actions {
  display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px;
}
.btn-secondary {
  padding: 9px 16px; background: var(--bg-3);
  color: var(--text-2); border: none;
  font-family: var(--font); font-size: 14px;
  cursor: pointer; border-radius: var(--radius-sm);
  transition: background .1s;
}
.btn-secondary:hover { background: var(--bg-hover); color: var(--text-1); }
.btn-danger {
  padding: 9px 16px; background: var(--red); color: #fff;
  border: none; border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 14px; cursor: pointer;
}
.btn-danger:hover { background: var(--red-hover); }

/* ── Toast ───────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 20px; right: 16px;
  display: flex; flex-direction: column; gap: 8px; z-index: 300;
  max-width: calc(100vw - 32px);
}
.toast {
  background: var(--bg-3); color: var(--text-1);
  padding: 11px 18px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,.5);
  animation: toastIn .2s ease;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
@keyframes toastIn {
  from { transform: translateX(110%); opacity: 0 }
  to   { transform: none; opacity: 1 }
}

/* ── Welcome ─────────────────────────────────────── */
#welcome-screen {
  flex: 1; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 14px; color: var(--text-3);
  text-align: center; padding: 24px;
}
.welcome-logo { font-size: 60px; }
#welcome-screen h2 { font-size: 22px; color: var(--text-2); font-weight: 700; }
#welcome-screen p  { font-size: 14px; max-width: 320px; line-height: 1.6; }

/* ════════════════════════════════════════════════
   MOBILE RESPONSIVE  (≤ 768px)
   ════════════════════════════════════════════════ */
@media (max-width: 768px) {
  #mobile-topbar { display: flex; }

  #app {
    flex-direction: column;
    padding-top: var(--topbar-h);
  }

  /* Left panel γίνεται slide-in drawer */
  #left-panel {
    position: fixed;
    top: var(--topbar-h); left: 0; bottom: 0;
    width: calc(var(--server-w) + var(--sidebar-w));
    max-width: 90vw;
    z-index: 45;
    transform: translateX(-110%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
  }
  #left-panel.open { transform: translateX(0); }

  /* Server list πιο στενό σε mobile */
  #server-list { width: 58px; }
  #channel-sidebar { width: calc(100% - 58px); }

  /* Κουμπί κλεισίματος ορατό σε mobile */
  .close-btn { display: flex; }

  /* Members sidebar γίνεται bottom sheet ή κρύβεται */
  #members-sidebar {
    position: fixed;
    top: var(--topbar-h); right: 0; bottom: 0;
    width: min(280px, 85vw);
    z-index: 45;
    transform: translateX(110%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    display: block !important;
  }
  #members-sidebar.open { transform: translateX(0); }

  /* Chat παίρνει ολόκληρο το πλάτος */
  #main { width: 100%; }

  /* Messages με λιγότερο padding */
  .message-group { padding: 3px 10px; }
  .message-compact { padding: 1px 10px 1px 60px; }

  /* Input area */
  #chat-input-area { padding: 6px 8px 8px; }

  /* Toggle members button στο header */
  #toggle-members-btn { display: flex; }

  /* Μεγαλύτερα touch targets */
  .channel-item { min-height: 44px; padding: 10px; }
  .server-icon  { width: 44px; height: 44px; }

  /* Auth box full-width */
  .auth-box { padding: 28px 20px; }
}

/* Πολύ μικρές οθόνες */
@media (max-width: 380px) {
  #left-panel { width: 90vw; }
  .auth-box { padding: 24px 16px; }
  .auth-brand { font-size: 22px; }
}

/* ════════════════════════════════════════════════
   TABLET  (768px – 1024px)
   ════════════════════════════════════════════════ */
@media (min-width: 769px) and (max-width: 1024px) {
  :root {
    --sidebar-w: 200px;
    --members-w: 0px;
  }
  #members-sidebar { display: none !important; }
  #toggle-members-btn { display: none; }
}

/* Desktop: κρύψε toggle members αν sidebar ανοιχτό */
@media (min-width: 1025px) {
  #toggle-members-btn { display: none; }
}

/* ── Utility ─────────────────────────────────────── */
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
