/* MADCHAT MODERN DARK THEME */
:root {
  --bg-darkest: #0f172a;
  --bg-dark: #1e293b;
  --bg-card: #334155;
  --bg-card-hover: #475569;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --accent: #38bdf8;
  --online: #10b981;
  --offline: #ef4444;
  --border: #334155;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body, html {
  height: 100%;
  background-color: var(--bg-darkest);
  color: var(--text-main);
  overflow: hidden;
}

/* HELPER CLASSES */
.hidden {
  display: none !important;
}

/* AUTH SCREEN */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(circle at top right, #1e1b4b, #0f172a 70%);
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: rgba(30, 41, 59, 0.85);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 14px;
  font-size: 26px;
  color: white;
  margin-bottom: 12px;
  box-shadow: 0 8px 16px rgba(99, 102, 241, 0.3);
}

.auth-header h2 {
  font-size: 22px;
  font-weight: 700;
}

.brand-highlight {
  color: var(--accent);
}

.auth-header p {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

.input-group {
  margin-bottom: 16px;
}

.input-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.input-group input {
  width: 100%;
  padding: 12px 14px;
  background-color: var(--bg-darkest);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: white;
  font-size: 14px;
  transition: all 0.2s ease;
}

.input-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: white;
}

.btn-primary:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.quick-login-section {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.quick-title {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.quick-login-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-quick {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease;
}

.btn-quick:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--primary);
}

/* APP SCREEN LAYOUT */
.app-screen {
  display: grid;
  grid-template-columns: 240px 1fr 280px;
  height: 100vh;
  width: 100vw;
}

/* SIDEBAR LEFT */
.sidebar-left {
  background-color: #0f172a;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.workspace-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}

.workspace-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
}

.brand-icon {
  color: var(--accent);
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 8px;
}

.section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  padding: 0 8px 8px;
}

.channel-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

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

.channel-item:hover {
  background-color: var(--bg-dark);
  color: var(--text-main);
}

.channel-item.active {
  background-color: var(--primary);
  color: white;
  font-weight: 600;
}

.current-user-card {
  padding: 12px;
  border-top: 1px solid var(--border);
  background-color: #0b1120;
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar-wrapper {
  position: relative;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

.status-indicator {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #0b1120;
}

.status-indicator.online {
  background-color: var(--online);
}

.status-indicator.offline {
  background-color: var(--offline);
}

.user-details {
  flex: 1;
  overflow: hidden;
}

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

.user-role-badge {
  font-size: 10px;
  color: var(--accent);
  font-weight: 500;
}

.user-action-buttons {
  display: flex;
  gap: 2px;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
}

.btn-icon:hover {
  color: white;
  background-color: var(--bg-card);
}

/* AVATAR IMAGE SUPPORT */
.user-avatar img, .member-avatar img, .message-avatar img, .profile-preview-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.profile-preview-box {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  border: 1px solid var(--border);
}

.profile-preview-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: var(--primary);
  color: white;
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}

.color-picker-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  border: 2px solid transparent;
}

.color-swatch:hover {
  transform: scale(1.15);
}

.color-swatch.active {
  border-color: white;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
  transform: scale(1.15);
}

.modal-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

.modal-lg {
  max-width: 500px;
}

.text-center {
  text-align: center;
}

/* CHAT AREA CENTER */
.chat-area {
  display: flex;
  flex-direction: column;
  background-color: var(--bg-dark);
  height: 100%;
}

.chat-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1e293b;
}

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

.channel-hash {
  font-size: 20px;
  color: var(--text-muted);
}

.channel-title {
  font-size: 16px;
  font-weight: 700;
}

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

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

.message-item {
  position: relative;
  display: flex;
  gap: 12px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}

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

.message-item:hover .message-hover-actions {
  opacity: 1;
  pointer-events: auto;
}

.message-hover-actions {
  position: absolute;
  top: -12px;
  right: 12px;
  display: flex;
  gap: 4px;
  background: var(--bg-darkest);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 10px rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 10;
}

.btn-msg-action {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  transition: all 0.15s ease;
}

.btn-msg-action:hover {
  color: white;
  background: var(--bg-card);
}

.btn-msg-action.delete-action:hover {
  color: var(--offline);
  background: rgba(239, 68, 68, 0.15);
}

.message-reactions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.reaction-pill:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--primary);
}

.reaction-pill.active {
  background: rgba(99, 102, 241, 0.25);
  border-color: var(--primary);
  color: white;
}

.message-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.message-content {
  flex: 1;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

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

.sender-role-pill {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.3);
  font-weight: 500;
}

.message-timestamp {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

.message-text {
  font-size: 14px;
  line-height: 1.5;
  color: #e2e8f0;
  word-break: break-word;
}

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

.input-wrapper {
  display: flex;
  gap: 10px;
  background-color: var(--bg-darkest);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.input-wrapper input {
  flex: 1;
  background: none;
  border: none;
  color: white;
  font-size: 14px;
  outline: none;
}

.btn-send {
  background: var(--primary);
  color: white;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-send:hover {
  background: var(--primary-hover);
}

/* RIGHT SIDEBAR: TEAM MEMBERS & STATUS */
.sidebar-right {
  background-color: #0f172a;
  border-left: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.sidebar-right-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.sidebar-right-header h4 {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.online-counter {
  font-size: 11px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--online);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

.owner-status-banner {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(56, 189, 248, 0.1));
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: var(--accent);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.team-members-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
}

.member-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background-color: rgba(255, 255, 255, 0.02);
  transition: all 0.15s ease;
  user-select: none;
}

.member-card.draggable {
  cursor: grab;
}

.member-card.dragging {
  opacity: 0.4;
  background-color: rgba(99, 102, 241, 0.2);
  border: 1px dashed var(--primary);
}

.drag-handle {
  color: var(--text-muted);
  font-size: 11px;
  cursor: grab;
  padding: 4px 6px 4px 2px;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}

.drag-handle:hover {
  opacity: 1;
  color: white;
}

.reorder-actions {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-right: 4px;
}

.btn-order-arrow {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 9px;
  cursor: pointer;
  padding: 1px 3px;
  line-height: 1;
  border-radius: 2px;
}

.btn-order-arrow:hover {
  background: var(--bg-card);
  color: white;
}

/* TYPING INDICATOR */
.typing-indicator {
  font-size: 11px;
  color: var(--accent);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-style: italic;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* CHANNEL CHECKBOX GRID IN ADMIN EDIT MODAL */
.channel-checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
  background: rgba(255, 255, 255, 0.02);
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-main);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background-color: rgba(255, 255, 255, 0.02);
  transition: background 0.15s ease;
}

.member-card:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.member-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.dot.online {
  background-color: var(--online);
  box-shadow: 0 0 6px var(--online);
}

.dot.offline {
  background-color: var(--offline);
}

.member-avatar {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-card);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
}

.member-avatar .status-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #0f172a;
}

.member-avatar .status-dot.online {
  background-color: var(--online);
}

.member-avatar .status-dot.offline {
  background-color: var(--offline);
}

.member-meta {
  display: flex;
  flex-direction: column;
}

.member-name {
  font-size: 13px;
  font-weight: 600;
}

.member-role {
  font-size: 10px;
  color: var(--text-muted);
}

/* OWNER STATUS TOGGLE BUTTONS IN SIDEBAR */
.owner-toggle-group {
  display: flex;
  gap: 4px;
}

.btn-status-toggle {
  background: var(--bg-darkest);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-status-toggle.active-online {
  background: var(--online);
  color: white;
  border-color: var(--online);
}

.btn-status-toggle.active-offline {
  background: var(--offline);
  color: white;
  border-color: var(--offline);
}

.btn-status-toggle.active-auto {
  background: var(--accent);
  color: #0f172a;
  border-color: var(--accent);
  font-weight: bold;
}

/* MODAL & ANIMATIONS */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: modalOverlayFade 0.2s ease-out forwards;
}

@keyframes modalOverlayFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 400px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  animation: modalPopIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modalPopIn {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

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

/* MESSAGE STREAM ENTRANCE ANIMATION */
.message-item {
  display: flex;
  gap: 12px;
  animation: messageSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ONLINE STATUS PULSE ANIMATION */
.status-indicator.online, .status-dot.online {
  background-color: var(--online);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: statusGlowPulse 2s infinite;
}

@keyframes statusGlowPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

/* BUTTON & HOVER INTERACTION ANIMATIONS */
.btn {
  transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.15s ease, background 0.15s ease;
}

.btn:active {
  transform: scale(0.96) !important;
}

.channel-item {
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.channel-item:hover {
  background-color: var(--bg-dark);
  color: var(--text-main);
  transform: translateX(4px);
}

.channel-item.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.member-card {
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.member-card:hover {
  background-color: rgba(255, 255, 255, 0.05);
  transform: translateX(-3px);
}

.auth-card {
  animation: authCardFloat 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes authCardFloat {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.logo-icon {
  animation: logoPulse 3s ease-in-out infinite alternate;
}

@keyframes logoPulse {
  0% {
    box-shadow: 0 8px 16px rgba(99, 102, 241, 0.3);
  }
  100% {
    box-shadow: 0 12px 24px rgba(56, 189, 248, 0.5);
  }
}
