:root {
  --bg-main: #0a0a0a;
  --bg-panel: #171717;
  --bg-hover: #262626;
  --border: #262626;
  --yellow: #facc15;
  --yellow-hover: #eab308;
  --text-main: #ffffff;
  --text-muted: #a3a3a3;
  --error-bg: rgba(239, 68, 68, 0.1);
  --error-text: #f87171;
  --error-border: rgba(239, 68, 68, 0.5);
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
}

/* Utility Classes */
.hidden { display: none !important; }
.screen { height: 100vh; width: 100vw; }

.fade-in {
  animation: fadeIn 0.4s ease-out forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ---------------- AUTH SCREEN ---------------- */
#auth-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-box {
  background-color: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.title {
  color: var(--yellow);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 24px;
}

.error {
  background-color: var(--error-bg);
  color: var(--error-text);
  border: 1px solid var(--error-border);
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 20px;
}

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

input {
  background-color: var(--bg-main);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 14px;
  border-radius: 12px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

input:focus {
  border-color: var(--yellow);
}

button[type="submit"] {
  background-color: var(--yellow);
  color: #000;
  border: none;
  padding: 14px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}

button[type="submit"]:hover {
  background-color: var(--yellow-hover);
}

button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.text-btn {
  background: none !important;
  color: var(--text-muted) !important;
  font-size: 13px !important;
  padding: 8px !important;
  margin-top: -8px;
  font-weight: 500 !important;
}

.text-btn:hover {
  color: var(--text-main) !important;
  text-decoration: underline;
  background: none !important;
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(0,0,0,0.3);
  border-radius: 50%;
  border-top-color: #000;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------------- APP SCREEN ---------------- */
#app-screen {
  display: flex;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  z-index: 30;
  transition: transform 0.3s ease;
}

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

.sidebar-header h2 {
  color: var(--yellow);
  font-size: 16px;
  letter-spacing: 1px;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
}

.channel-section {
  margin-bottom: 24px;
}

.section-title {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  padding: 0 16px;
  margin-bottom: 8px;
}

.chat-btn {
  width: 100%;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 10px 16px;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s;
}

.chat-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
}

.chat-btn.active {
  background-color: rgba(250, 204, 21, 0.1);
  color: var(--yellow);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg-panel);
  position: absolute;
  bottom: 0;
  right: 0;
}

.status-dot.online { background-color: #22c55e; }
.status-dot.offline { background-color: #525252; }

.user-avatar-wrapper {
  position: relative;
  display: inline-block;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  text-transform: uppercase;
}

.chat-btn.active .avatar {
  background-color: rgba(250, 204, 21, 0.2);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.current-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.current-user .avatar {
  background-color: var(--yellow);
  color: #000;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 8px;
  border-radius: 8px;
  transition: color 0.2s;
}

.icon-btn:hover {
  color: var(--text-main);
}

.logout-btn:hover {
  color: var(--error-text);
}

/* Chat Area */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-main);
  height: 100vh;
  min-width: 0;
}

.chat-header {
  height: 64px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  background-color: rgba(23, 23, 23, 0.8);
  backdrop-filter: blur(10px);
}

.chat-title-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-title-info .avatar {
  background-color: rgba(250, 204, 21, 0.1);
  color: var(--yellow);
}

#chat-name {
  font-size: 16px;
  font-weight: 600;
}

#chat-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.message-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 75%;
}

.message-wrapper.me {
  align-self: flex-end;
  align-items: flex-end;
}

.message-wrapper.other {
  align-self: flex-start;
  align-items: flex-start;
}

.message-info {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
  padding: 0 4px;
}

.message-wrapper.me .message-info {
  flex-direction: row-reverse;
}

.msg-user {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.msg-time {
  font-size: 10px;
  color: #525252;
}

.message-bubble {
  padding: 10px 16px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.4;
  word-wrap: break-word;
}

.message-wrapper.me .message-bubble {
  background-color: var(--yellow);
  color: #000;
  border-top-right-radius: 4px;
}

.message-wrapper.other .message-bubble {
  background-color: var(--bg-panel);
  color: var(--text-main);
  border-top-left-radius: 4px;
}

.chat-input-area {
  padding: 16px;
  border-top: 1px solid var(--border);
  background-color: var(--bg-main);
}

#message-form {
  display: flex;
  flex-direction: row;
  background-color: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 6px;
  gap: 8px;
}

#message-form:focus-within {
  border-color: rgba(250, 204, 21, 0.5);
}

#message-input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 10px 16px;
  border-radius: 0;
}

#message-input:focus {
  border: none;
}

#send-btn {
  background-color: var(--yellow);
  color: #000;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s;
}

#send-btn:hover {
  background-color: var(--yellow-hover);
}

.empty-state {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 16px;
}

.empty-icon {
  font-size: 32px;
  opacity: 0.5;
}

/* Mobile Responsiveness */
.mobile-only {
  display: none;
}

@media (max-width: 768px) {
  .mobile-only {
    display: block;
  }

  .sidebar {
    position: fixed;
    left: -100%;
    top: 0;
  }

  .sidebar.open {
    left: 0;
  }

  #mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0,0,0,0.6);
    z-index: 20;
  }

  #mobile-overlay.open {
    display: block;
  }

  .message-wrapper {
    max-width: 85%;
  }
}
