* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #111111;
  --bg2: #19191A;
  --bg3: #252526;
  --text-primary: #FFFFFF;
  --text-secondary: rgba(255,255,255,0.55);
  --bg2-alpha: rgba(25,25,26,0.65);
  --bg3-alpha: rgba(37,37,38,0.55);
  --liquid-border: 1px solid rgba(255,255,255,0.06);
  --liquid-blur: blur(20px);
  --accent: #FFFFFF;
  --accent-hover: #B3B3B3;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-width: 280px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

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

button {
  cursor: pointer;
  border: none;
  font-family: inherit;
  font-size: 14px;
}

input, textarea {
  font-family: inherit;
  font-size: 14px;
  background: var(--bg3);
  border: var(--liquid-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 12px 16px;
  outline: none;
  width: 100%;
}

input:focus, textarea:focus {
  border-color: rgba(255,255,255,0.2);
}

/* ============ AUTH SCREEN ============ */

.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: var(--bg);
}

.auth-card {
  background: var(--bg2-alpha);
  border: var(--liquid-border);
  border-radius: 28px;
  padding: 48px;
  width: 100%;
  max-width: 420px;
  backdrop-filter: var(--liquid-blur);
  -webkit-backdrop-filter: var(--liquid-blur);
}

.auth-card h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
}

.auth-card .subtitle {
  color: var(--text-secondary);
  margin-bottom: 32px;
  font-size: 15px;
}

.auth-card .form-group {
  margin-bottom: 16px;
}

.auth-card label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.auth-card .btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: var(--bg);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 15px;
  margin-top: 8px;
  transition: background 0.2s;
}

.auth-card .btn-primary:hover { background: var(--accent-hover); }

.auth-card .switch-link {
  text-align: center;
  margin-top: 20px;
  color: var(--text-secondary);
  font-size: 14px;
}

.auth-card .error-msg {
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

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

.app {
  display: flex;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg2);
  border-right: var(--liquid-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 20px;
  border-bottom: var(--liquid-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-header h2 {
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-header h2 img {
  height: 28px;
  border-radius: 6px;
}

.sidebar-nav {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.nav-item:hover { background: var(--bg3-alpha); color: var(--text-primary); }
.nav-item.active { background: rgba(255,255,255,0.08); color: var(--text-primary); }
.nav-item .icon { font-size: 18px; width: 24px; text-align: center; }

.sidebar-section-title {
  padding: 16px 12px 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  font-weight: 600;
}

.channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 12px;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.channel-item:hover { background: var(--bg3-alpha); color: var(--text-primary); }
.channel-item.active { background: rgba(255,255,255,0.08); color: var(--text-primary); }
.channel-item .hash { opacity: 0.5; font-weight: 600; }

/* User footer in sidebar */
.sidebar-user {
  padding: 16px;
  border-top: var(--liquid-border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-user .user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg3);
  object-fit: cover;
  flex-shrink: 0;
}

.sidebar-user .user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user .user-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user .user-status {
  font-size: 12px;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}

.status-dot.online { background: var(--success); }
.status-dot.away { background: var(--warning); }
.status-dot.busy { background: var(--danger); }
.status-dot.offline { background: rgba(255,255,255,0.2); }

/* ============ MAIN CONTENT ============ */

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.content-header {
  padding: 16px 24px;
  border-bottom: var(--liquid-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.content-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.content-header .header-actions {
  display: flex;
  gap: 8px;
}

.content-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ============ CHAT ============ */

.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.messages-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-radius: var(--radius-sm);
}

.message:hover { background: rgba(255,255,255,0.02); }

.message .msg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg3);
  object-fit: cover;
  flex-shrink: 0;
}

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

.message .msg-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.message .msg-name {
  font-weight: 600;
  font-size: 14px;
}

.message .msg-role {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255,255,255,0.1);
  color: var(--text-secondary);
  text-transform: uppercase;
  font-weight: 600;
}

.message .msg-time {
  font-size: 12px;
  color: var(--text-secondary);
}

.message .msg-content {
  font-size: 14px;
  line-height: 1.5;
  color: rgba(255,255,255,0.85);
  word-break: break-word;
}

.message .msg-content a {
  color: var(--accent);
  text-decoration: underline;
}

.message.pinned {
  border-left: 3px solid rgba(255,255,255,0.3);
  padding-left: 12px;
  background: rgba(255,255,255,0.03);
}

.message-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  margin-top: 4px;
  font-size: 13px;
  color: var(--accent);
}

.chat-input-area {
  padding: 16px 24px;
  border-top: var(--liquid-border);
  flex-shrink: 0;
}

.chat-input-wrapper {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.chat-input-wrapper input {
  flex: 1;
  padding: 14px 18px;
  border-radius: 14px;
}

.chat-input-wrapper .send-btn {
  padding: 14px 20px;
  background: var(--accent);
  color: var(--bg);
  border-radius: 14px;
  font-weight: 600;
  transition: background 0.2s;
  white-space: nowrap;
}

.chat-input-wrapper .send-btn:hover { background: var(--accent-hover); }

.chat-input-wrapper .upload-btn {
  padding: 14px;
  background: var(--bg3);
  color: var(--text-secondary);
  border-radius: 14px;
  transition: all 0.2s;
}

.chat-input-wrapper .upload-btn:hover { background: var(--bg3-alpha); color: var(--text-primary); }

.typing-indicator {
  padding: 4px 24px;
  font-size: 12px;
  color: var(--text-secondary);
  height: 20px;
}

/* ============ DASHBOARD ============ */

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.dash-card {
  background: var(--bg2-alpha);
  border: var(--liquid-border);
  border-radius: var(--radius);
  padding: 24px;
  backdrop-filter: var(--liquid-blur);
  -webkit-backdrop-filter: var(--liquid-blur);
}

.dash-card h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dash-card.full-width { grid-column: 1 / -1; }

.announcement-item {
  padding: 12px 0;
  border-bottom: var(--liquid-border);
}

.announcement-item:last-child { border-bottom: none; }
.announcement-item .ann-title { font-weight: 600; margin-bottom: 4px; }
.announcement-item .ann-content { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.announcement-item .ann-meta { font-size: 12px; color: var(--text-secondary); margin-top: 6px; }

.link-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: var(--liquid-border);
}

.link-item:last-child { border-bottom: none; }
.link-item .link-title { font-size: 14px; font-weight: 500; }
.link-item .link-url { font-size: 12px; color: var(--text-secondary); }
.link-item .link-delete {
  background: none;
  color: var(--text-secondary);
  font-size: 16px;
  padding: 4px 8px;
}

.link-item .link-delete:hover { color: var(--danger); }

.stat-number-big {
  font-size: 36px;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.stat-card {
  background: var(--bg2-alpha);
  border: var(--liquid-border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  backdrop-filter: var(--liquid-blur);
}

/* ============ PROFILE ============ */

.profile-page {
  max-width: 640px;
  margin: 0 auto;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 32px;
}

.profile-avatar-large {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--bg3);
  object-fit: cover;
}

.profile-info h2 {
  font-size: 24px;
  font-weight: 700;
}

.profile-info .profile-role {
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(255,255,255,0.1);
  color: var(--text-secondary);
  display: inline-block;
  margin-top: 4px;
  text-transform: capitalize;
}

.profile-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.profile-form label {
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  display: block;
}

.profile-form textarea {
  resize: vertical;
  min-height: 80px;
}

.btn {
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s;
}

.btn-primary { background: var(--accent); color: var(--bg); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg3); color: var(--text-primary); }
.btn-secondary:hover { background: rgba(255,255,255,0.1); }
.btn-danger { background: rgba(239,68,68,0.15); color: #fca5a5; }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-sm { padding: 8px 16px; font-size: 13px; }

/* ============ ADMIN ============ */

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th {
  text-align: left;
  padding: 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  border-bottom: var(--liquid-border);
}

.admin-table td {
  padding: 12px;
  border-bottom: var(--liquid-border);
  font-size: 14px;
}

.admin-table tr:hover td { background: rgba(255,255,255,0.02); }

.admin-table .user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-table .user-cell img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg3);
  object-fit: cover;
}

.role-select {
  background: var(--bg3);
  border: var(--liquid-border);
  border-radius: 6px;
  color: var(--text-primary);
  padding: 6px 10px;
  font-size: 13px;
}

/* ============ MEMBERS LIST ============ */

.members-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.member-card {
  background: var(--bg2-alpha);
  border: var(--liquid-border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: all 0.2s;
  backdrop-filter: var(--liquid-blur);
}

.member-card:hover { transform: translateY(-2px); border-color: rgba(255,255,255,0.12); }

.member-card img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg3);
  object-fit: cover;
}

.member-card .member-name { font-weight: 600; font-size: 14px; }
.member-card .member-role { font-size: 12px; color: var(--text-secondary); text-transform: capitalize; }

/* ============ MODAL ============ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--bg2);
  border: var(--liquid-border);
  border-radius: 20px;
  padding: 32px;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal h3 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
}

.modal .form-group { margin-bottom: 16px; }

.modal .modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ============ SCROLLBAR ============ */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ============ RESPONSIVE ============ */

@media (max-width: 900px) {
  .sidebar { width: 60px; }
  .sidebar-header h2 span,
  .sidebar-section-title,
  .channel-item span:not(.hash),
  .nav-item span:not(.icon),
  .sidebar-user .user-info { display: none; }
  .sidebar-nav, .channel-list { padding: 8px; }
  .nav-item, .channel-item { justify-content: center; padding: 10px; }
  .sidebar-user { justify-content: center; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .sidebar { display: none; }
  .stats-grid { grid-template-columns: 1fr; }
}

/* ============ UTILITY ============ */

.hidden { display: none !important; }
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state p { font-size: 15px; }
