/* style.css */

/* --- Custom Variables & Themes --- */
:root {
  --bg-primary: #f3f4f6;
  --bg-secondary: #ffffff;
  --bg-sidebar: #f9fafb;
  --bg-active: #e0e7ff;
  --bg-hover: #f3f4f6;
  
  --text-primary: #1f2937;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  
  --border-color: #e5e7eb;
  
  --accent-color: #4f46e5;
  --accent-hover: #4338ca;
  --accent-light: rgba(79, 70, 229, 0.08);
  
  --bubble-outgoing: linear-gradient(135deg, #6366f1, #4f46e5);
  --bubble-outgoing-text: #ffffff;
  --bubble-incoming: #ffffff;
  --bubble-incoming-text: #1f2937;
  
  --danger-color: #ef4444;
  --danger-hover: #dc2626;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  
  --glass-bg: rgba(255, 255, 255, 0.65);
  --glass-border: rgba(0, 0, 0, 0.08);
  --glass-blur: blur(16px);
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  --sidebar-width: 320px;
  --transition-speed: 0.25s;
}

[data-theme="dark"] {
  --bg-primary: #090d16;
  --bg-secondary: #0f172a;
  --bg-sidebar: #151c2c;
  --bg-active: #1e1b4b;
  --bg-hover: #1e293b;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --border-color: #1e293b;
  
  --accent-color: #6366f1;
  --accent-hover: #4f46e5;
  --accent-light: rgba(99, 102, 241, 0.15);
  
  --bubble-outgoing: linear-gradient(135deg, #6366f1, #4f46e5);
  --bubble-outgoing-text: #ffffff;
  --bubble-incoming: #1e293b;
  --bubble-incoming-text: #f8fafc;
  
  --danger-color: #f87171;
  --danger-hover: #ef4444;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
  
  --glass-bg: rgba(15, 23, 42, 0.65);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-blur: blur(16px);
}

/* --- Base resets & general --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  outline: none;
}

html, body {
  height: 100%;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  background-image: radial-gradient(at 0% 0%, rgba(79, 70, 229, 0.05) 0, transparent 40%),
                    radial-gradient(at 100% 0%, rgba(139, 92, 246, 0.05) 0, transparent 40%),
                    radial-gradient(at 50% 100%, rgba(224, 231, 255, 0.4) 0, transparent 40%);
  background-attachment: fixed;
  color: var(--text-primary);
  display: flex;
  transition: background-color var(--transition-speed), color var(--transition-speed);
}

[data-theme="dark"] body {
  background-image: radial-gradient(at 0% 0%, rgba(30, 27, 75, 0.4) 0, transparent 40%),
                    radial-gradient(at 50% 0%, rgba(79, 70, 229, 0.08) 0, transparent 40%),
                    radial-gradient(at 100% 0%, rgba(139, 92, 246, 0.08) 0, transparent 40%),
                    radial-gradient(at 50% 100%, rgba(15, 23, 42, 0.5) 0, transparent 40%);
}

ul {
  list-style: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  transition: all var(--transition-speed) ease;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* --- Shared Icons & Animation Helpers --- */
.hidden {
  display: none !important;
}

/* --- Login Page Styles --- */
.login-body {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  background: var(--bg-primary);
}

.login-glow-bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.glow-sphere {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.15;
}

.sphere-1 {
  width: 400px;
  height: 400px;
  background: var(--accent-color);
  top: -100px;
  left: -100px;
}

.sphere-2 {
  width: 500px;
  height: 500px;
  background: #ec4899;
  bottom: -150px;
  right: -100px;
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 20px;
  z-index: 10;
}

.login-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
  padding: 40px 30px;
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

.login-header {
  text-align: center;
  margin-bottom: 30px;
}

.logo-wrapper {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  filter: drop-shadow(0 4px 12px rgba(79, 70, 229, 0.3));
}

.login-logo {
  width: 100%;
  height: 100%;
}

.login-header h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.login-header p {
  font-size: 14px;
  color: var(--text-secondary);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.password-input-wrapper {
  position: relative;
  width: 100%;
}

.password-input-wrapper input {
  width: 100%;
  padding: 14px 16px;
  padding-right: 50px;
  border-radius: 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  transition: all var(--transition-speed);
}

.password-input-wrapper input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.toggle-password-btn {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.toggle-password-btn:hover {
  color: var(--text-secondary);
}

.eye-icon {
  width: 20px;
  height: 20px;
}

.error-banner {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--danger-color);
  padding: 12px 14px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  line-height: 1.4;
}

.alert-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Button UI */
.btn-primary {
  background: var(--accent-color);
  color: #ffffff;
  font-weight: 600;
  font-size: 15px;
  padding: 14px;
  border-radius: 14px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.25);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.35);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: rotate 0.8s linear infinite;
}

/* --- Layout Components --- */
.app-layout {
  display: flex;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

/* --- Sidebar Style --- */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 100;
  transition: transform var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
}

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

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo {
  width: 32px;
  height: 32px;
  filter: drop-shadow(0 2px 6px rgba(79, 70, 229, 0.2));
}

.logo-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.sidebar-actions-top {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--text-secondary);
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

/* Search Box */
.search-section {
  padding: 14px 20px;
}

.search-bar {
  position: relative;
  display: flex;
  align-items: center;
}

.search-bar input {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 10px 14px 10px 38px;
  font-size: 14px;
  color: var(--text-primary);
  transition: all var(--transition-speed);
}

.search-bar input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.search-icon {
  position: absolute;
  left: 12px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.clear-btn {
  position: absolute;
  right: 12px;
  color: var(--text-muted);
}

.clear-btn:hover {
  color: var(--text-secondary);
}

.clear-btn svg {
  width: 16px;
  height: 16px;
}

/* Filter Tabs */
.filter-tabs {
  display: flex;
  padding: 0 20px 14px;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
}

.filter-tab {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  text-align: center;
}

.filter-tab:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.filter-tab.active {
  background: var(--accent-light);
  color: var(--accent-color);
}

/* Channel list items */
.channel-list-container {
  flex: 1;
  overflow-y: auto;
  padding: 14px 0;
}

.channel-list-header {
  padding: 0 20px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.icon-btn-text {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-color);
  font-size: 12px;
  font-weight: 600;
}

.icon-btn-text:hover {
  opacity: 0.8;
}

.plus-icon {
  width: 14px;
  height: 14px;
}

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

.channel-item-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 12px;
  width: 100%;
  text-align: left;
  transition: all var(--transition-speed);
}

.channel-item-link:hover {
  background: var(--bg-hover);
}

.channel-item-link.active {
  background: var(--bg-active);
  color: var(--accent-color);
}

.channel-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.channel-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 14px;
}

.channel-item-link.active .channel-icon {
  background: var(--accent-color);
  color: #ffffff;
}

.channel-name-txt {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-item-link.active .channel-name-txt {
  color: var(--accent-color);
  font-weight: 600;
}

.channel-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pin-icon, .archive-icon {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
}

.badge-count {
  font-size: 10px;
  font-weight: 700;
  background: var(--border-color);
  color: var(--text-secondary);
  padding: 2px 6px;
  border-radius: 10px;
}

.channel-item-link.active .badge-count {
  background: var(--accent-color);
  color: #ffffff;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.user-status-card {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-indicator-dot.online {
  background: var(--success-color);
  box-shadow: 0 0 8px var(--success-color);
}

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

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

.logout-btn {
  color: var(--danger-color);
}

.logout-btn:hover {
  background: rgba(239, 68, 68, 0.08);
  color: var(--danger-color);
}

/* --- Chat Workspace Component --- */
.chat-workspace {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  position: relative;
}

/* Empty State */
.empty-state {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px;
  z-index: 10;
  background: var(--bg-secondary);
}

.empty-state-card {
  text-align: center;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.empty-icon-wrapper {
  width: 96px;
  height: 96px;
  margin-bottom: 24px;
}

.empty-logo {
  width: 100%;
  height: 100%;
}

.empty-state-card h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 12px;
}

.empty-state-card p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 24px;
}

.empty-state-shortcuts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  border-top: 1px dashed var(--border-color);
  padding-top: 20px;
}

.shortcut-item {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

.shortcut-item span {
  font-family: monospace;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: bold;
}

/* Chat container actual layout */
.chat-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.chat-header {
  height: 72px;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
  z-index: 90;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.channel-details {
  min-width: 0;
}

.channel-details h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

/* Search inside Channel */
.channel-search-bar {
  position: relative;
  display: flex;
  align-items: center;
  width: 180px;
  margin-right: 8px;
}

.channel-search-bar input {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 6px 10px 6px 28px;
  font-size: 12px;
  color: var(--text-primary);
  transition: all var(--transition-speed);
}

.channel-search-bar input:focus {
  border-color: var(--accent-color);
  width: 240px; /* Expand on focus! */
  z-index: 10;
}

.channel-search-icon {
  position: absolute;
  left: 8px;
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.mobile-only {
  display: none !important;
}

.pin-icon-svg, .archive-icon-svg {
  width: 18px;
  height: 18px;
}

/* Dropdown Menu styling */
.dropdown-menu {
  position: absolute;
  top: 48px;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  width: 180px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 200;
  animation: scaleUp 0.15s ease-out;
}

.dropdown-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: left;
}

.dropdown-menu button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.dropdown-menu button.danger {
  color: var(--danger-color);
}

.dropdown-menu button.danger:hover {
  background: rgba(239, 68, 68, 0.08);
}

.drop-icon {
  width: 16px;
  height: 16px;
}

/* --- Message Feed Component --- */
.message-feed-container {
  flex: 1;
  overflow-y: auto;
  background-color: var(--bg-primary);
  background-image: radial-gradient(rgba(79, 70, 229, 0.03) 1px, transparent 1px);
  background-size: 24px 24px;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.message-feed {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

/* Date separator group */
.date-separator {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 8px 0;
}

.date-separator-label {
  font-size: 11px;
  font-weight: 600;
  background: var(--border-color);
  color: var(--text-secondary);
  padding: 4px 12px;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Message Bubble */
.message-group {
  display: flex;
  width: 100%;
  position: relative;
}

.message-bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  box-shadow: var(--shadow-sm);
  position: relative;
  word-wrap: break-word;
  word-break: break-word;
  white-space: pre-wrap;
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition-speed);
}

/* Incoming */
.message-group.incoming {
  justify-content: flex-start;
}

.message-group.incoming .message-bubble {
  background: var(--bubble-incoming);
  color: var(--bubble-incoming-text);
  border-top-left-radius: 4px;
}

/* Outgoing */
.message-group.outgoing {
  justify-content: flex-start; /* Align all bubbles to the left */
}

.message-group.outgoing .message-bubble {
  background: var(--bubble-outgoing);
  color: var(--bubble-outgoing-text);
  border-top-left-radius: 4px; /* Curve consistently on the left wall */
}

/* Message Text & links */
.message-text {
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal; /* Disables raw newline rendering, marked handles breaks with HTML tags */
}

.message-text a {
  color: inherit;
  font-weight: 500;
  text-decoration: underline;
  word-break: break-all;
}

/* Pinned Banner inside message */
.message-pin-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: bold;
  color: var(--accent-color);
  margin-bottom: 4px;
  text-transform: uppercase;
}

.message-group.outgoing .message-pin-indicator {
  color: #c7d2fe;
}

.msg-pin-svg {
  width: 10px;
  height: 10px;
}

/* Message Meta (time/edited) */
.message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  align-self: flex-end;
  font-size: 10px;
  margin-top: 4px;
  color: var(--text-muted);
}

.message-group.outgoing .message-meta {
  color: rgba(255, 255, 255, 0.7);
}

.status-check {
  display: flex;
}

.status-check svg {
  width: 12px;
  height: 12px;
}

/* Rich Preview Card */
.rich-preview-card {
  margin-top: 10px;
  background: rgba(0, 0, 0, 0.03);
  border-left: 3px solid var(--accent-color);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-width: 100%;
}

.message-group.outgoing .rich-preview-card {
  background: rgba(255, 255, 255, 0.1);
  border-left-color: #c7d2fe;
}

.preview-media-container {
  width: 100%;
  position: relative;
  background: transparent;
}

.preview-image-link {
  display: block;
  width: 100%;
  text-decoration: none !important;
}

.preview-thumbnail {
  width: 100%;
  height: auto;
  display: block;
}

.video-container {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 */
  height: 0;
  overflow: hidden;
}

.video-container iframe,
.video-container video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.preview-content {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.preview-site {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.message-group.outgoing .preview-site {
  color: rgba(255, 255, 255, 0.8);
}

.preview-favicon {
  width: 14px;
  height: 14px;
  border-radius: 2px;
}

.preview-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.message-group.outgoing .preview-title {
  color: #ffffff;
}

.preview-desc {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.message-group.outgoing .preview-desc {
  color: rgba(255, 255, 255, 0.7);
}

/* Sending State Style */
.message-bubble.sending {
  opacity: 0.7;
}

.message-bubble.failed {
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* --- Composer Section --- */
.composer-container {
  padding: 16px 24px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--glass-border);
  flex-shrink: 0;
  z-index: 90;
}

.composer-info-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--accent-light);
  border-radius: 10px;
  padding: 8px 14px;
  margin-bottom: 12px;
  border-left: 3px solid var(--accent-color);
  animation: slideInDown 0.2s ease-out;
}

.banner-content {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.edit-banner-icon {
  width: 16px;
  height: 16px;
  color: var(--accent-color);
  flex-shrink: 0;
}

.edit-text-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.banner-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-color);
}

.banner-snippet {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.composer-inputs {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.textarea-wrapper {
  flex: 1;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
}

.textarea-wrapper textarea {
  width: 100%;
  background: transparent;
  border: none;
  resize: none;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  max-height: 180px;
  line-height: 1.5;
  padding-right: 4px;
}

.composer-right-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sync-status {
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent-color);
  color: #ffffff;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: var(--shadow-md);
}

.send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  background: var(--border-color);
  color: var(--text-muted);
  box-shadow: none;
}

.send-btn svg {
  width: 18px;
  height: 18px;
  margin-left: 2px; /* optical centering */
}

/* --- Context Menu Layout --- */
.context-menu {
  position: fixed;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  width: 160px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 500;
  animation: scaleUp 0.1s ease-out;
}

.context-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: left;
}

.context-menu button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.context-menu button.danger {
  color: var(--danger-color);
}

.context-menu button.danger:hover {
  background: rgba(239, 68, 68, 0.08);
}

.ctx-icon {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
}

.context-menu button:hover .ctx-icon {
  color: var(--text-primary);
}

.context-menu button.danger .ctx-icon {
  color: var(--danger-color);
}

.ctx-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 6px;
}

/* --- Modals Overlay --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 20px;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: scaleUp 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.modal-body {
  padding: 24px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  transition: all var(--transition-speed);
}

.form-group input:focus {
  border-color: var(--accent-color);
  background: var(--bg-secondary);
}

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

.btn-secondary {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  font-weight: 600;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 10px;
}

.btn-secondary:hover {
  background: var(--border-color);
}

.btn-danger {
  background: var(--danger-color);
  color: #ffffff;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(239, 68, 68, 0.2);
}

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

/* Settings Specific styles */
.settings-sections {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-section h4 {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 6px;
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: var(--text-primary);
}

.setting-item.flex-column {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.setting-label-bold {
  font-weight: 600;
}

.setting-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.about-card {
  background: var(--bg-primary);
  border-radius: 12px;
  padding: 14px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.about-card p {
  margin-bottom: 6px;
}

.about-card p.credits {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 10px;
  margin-bottom: 0;
}

/* Switch UI */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-round {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-color);
  transition: .3s;
  border-radius: 34px;
}

.slider-round:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

.switch input:checked + .slider-round {
  background-color: var(--accent-color);
}

.switch input:checked + .slider-round:before {
  transform: translateX(20px);
}

/* --- Toast Notifications --- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
  max-width: 340px;
  width: 100%;
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--accent-color);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  animation: slideInLeft 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.toast-error {
  border-left-color: var(--danger-color);
}

.toast.toast-success {
  border-left-color: var(--success-color);
}

.toast-close {
  color: var(--text-muted);
}

.toast-close:hover {
  color: var(--text-secondary);
}

.toast-close svg {
  width: 14px;
  height: 14px;
}

/* --- Loading Skeletons --- */
.skeleton-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 10px;
}

.skeleton-item {
  height: 52px;
  border-radius: 12px;
  background: linear-gradient(90deg, var(--border-color) 25%, var(--bg-primary) 50%, var(--border-color) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

.skeleton-feed {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

.skeleton-bubble {
  height: 64px;
  max-width: 50%;
  width: 100%;
  border-radius: 16px;
  background: linear-gradient(90deg, var(--border-color) 25%, var(--bg-primary) 50%, var(--border-color) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

.skeleton-bubble.left {
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.skeleton-bubble.right {
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

/* --- Keyframe Animations --- */
@keyframes rotate {
  100% { transform: rotate(360deg); }
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes scaleUp {
  0% { transform: scale(0.95); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes slideInDown {
  0% { transform: translateY(-10px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

@keyframes slideInLeft {
  0% { transform: translateX(20px); opacity: 0; }
  100% { transform: translateX(0); opacity: 1; }
}

.shake-animation {
  animation: shake 0.5s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* Pinned Message Glow & Highlight (Warm Gold Theme) */
.message-bubble.pinned {
  border: 2px solid #f59e0b !important;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.45) !important;
  position: relative;
}

[data-theme="dark"] .message-bubble.pinned {
  border-color: #fbbf24 !important;
  box-shadow: 0 0 20px rgba(251, 191, 36, 0.55) !important;
}

.message-group.outgoing .message-bubble.pinned {
  border-color: #fde047 !important;
  box-shadow: 0 0 24px rgba(253, 224, 71, 0.6) !important;
}

.message-pin-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  color: #d97706; /* Gold text */
  margin-bottom: 6px;
  text-transform: uppercase;
}

[data-theme="dark"] .message-pin-indicator {
  color: #fbbf24;
}

.message-group.outgoing .message-pin-indicator {
  color: #fef08a; /* Light gold text on outgoing blue background */
}

.msg-pin-svg {
  height: 12px;
  width: auto;
  flex-shrink: 0;
  display: inline-block;
}

/* --- Pinned Messages Panel Styles --- */
.pinned-messages-panel {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--glass-border);
  max-height: 250px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 85;
  animation: slideInDown 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.pinned-messages-panel.hidden {
  display: none !important;
}

.pinned-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px dashed var(--border-color);
}

.pinned-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pinned-panel-title h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.title-pin-icon {
  width: 14px;
  height: 14px;
  color: var(--accent-color);
  transform: rotate(45deg);
}

.pinned-messages-list {
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.pinned-empty-state {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 16px 0;
}

/* Glassmorphic Pinned Message Card */
.pinned-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 10px 14px;
  gap: 16px;
  transition: all var(--transition-speed);
  cursor: pointer;
}

[data-theme="dark"] .pinned-card {
  background: rgba(30, 41, 59, 0.4);
}

.pinned-card:hover {
  background: rgba(255, 255, 255, 0.7);
  border-color: var(--accent-color);
  transform: translateY(-1px);
}

[data-theme="dark"] .pinned-card:hover {
  background: rgba(30, 41, 59, 0.7);
}

.pinned-card-content {
  flex: 1;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pinned-card-content strong {
  color: var(--text-primary);
  margin-right: 6px;
}

/* Actions in card */
.pinned-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.pinned-card-actions button {
  padding: 6px;
  border-radius: 8px;
  color: var(--text-secondary);
}

.pinned-card-actions button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.pinned-card-actions .unpin-action-btn:hover {
  color: var(--danger-color);
}

/* Scroll jump highlight animation */
@keyframes flashHighlight {
  0% { background-color: var(--accent-light); }
  50% { background-color: var(--accent-light); }
  100% { background-color: transparent; }
}

.flash-highlight {
  animation: flashHighlight 1.5s ease-out;
}

/* Markdown Rendering Clean Layout Rules */
.message-text p {
  margin-bottom: 8px;
  line-height: 1.5;
}

.message-text p:last-child {
  margin-bottom: 0;
}

.message-text ul, .message-text ol {
  margin: 6px 0 10px 20px;
}

.message-text ul {
  list-style-type: disc;
}

.message-text ol {
  list-style-type: decimal;
}

.message-text li {
  margin-bottom: 4px;
}

.message-text code {
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 85%;
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
}

[data-theme="dark"] .message-text code {
  background: rgba(255, 255, 255, 0.1);
}

.message-text pre {
  margin: 10px 0;
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  background: #1e1e1e !important;
}

.message-text pre code {
  padding: 0;
  background: transparent;
  font-size: 13px;
  color: #f8f8f2;
}

.message-text blockquote {
  border-left: 4px solid var(--accent-color);
  padding-left: 12px;
  margin: 8px 0;
  color: var(--text-secondary);
}

/* --- Responsive Layout Adjustments --- */
@media (max-width: 768px) {
  body {
    position: relative;
  }
  
  /* Hide Dedicated Pin and Archive header options on mobile */
  #pinChannelBtn, #archiveChannelBtn {
    display: none !important;
  }

  /* Mobile View Switching Rules */
  /* By default (No active chat), show channels list, hide workspace */
  .sidebar {
    position: relative;
    width: 100% !important;
    transform: none !important;
    box-shadow: none !important;
    border-right: none;
  }
  
  .chat-workspace {
    display: none !important;
  }
  
  /* When chat is active, show workspace, hide channels list */
  .app-layout.chat-active .sidebar {
    display: none !important;
  }
  
  .app-layout.chat-active .chat-workspace {
    display: flex !important;
    width: 100% !important;
    height: 100% !important;
  }

  .mobile-only {
    display: flex !important;
  }
  
  .chat-header {
    padding: 0 16px;
  }
  
  .message-bubble {
    max-width: 85%;
  }

  /* Expanding Mobile Search Bar (Prevents text overlap issues) */
  .channel-search-bar {
    width: auto;
    margin-right: 0;
    position: relative;
    display: flex;
    align-items: center;
  }

  .channel-search-bar input {
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    color: transparent;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
  }

  .channel-search-bar input::placeholder {
    color: transparent;
  }

  .channel-search-bar input:focus {
    width: 140px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    padding: 6px 10px 6px 32px;
    color: var(--text-primary);
    cursor: text;
    border-radius: 10px;
  }

  .channel-search-bar input:focus::placeholder {
    color: var(--text-muted);
  }

  .channel-search-icon {
    position: absolute;
    left: 10px;
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
    pointer-events: none;
    z-index: 1;
  }
  
  /* Top-Center Toast Alignment on Mobile */
  .toast-container {
    top: 20px;
    bottom: auto;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    max-width: 90%;
    padding: 0 10px;
  }

  .toast {
    width: 100%;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(8px);
    animation: slideInDown 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  }

  [data-theme="dark"] .toast {
    background: rgba(21, 28, 44, 0.98);
    border-color: var(--border-color);
  }
  
  /* Auto hide option label text on mobile to save space */
  .icon-btn-text span {
    display: none;
  }
  
  .composer-container {
    padding: 12px 16px;
  }
  
  .composer-inputs {
    gap: 8px;
  }

  /* Pinned Panel Mobile Responsiveness */
  .pinned-messages-panel {
    max-height: 200px;
  }
  
  .pinned-panel-header {
    padding: 10px 16px;
  }
  
  .pinned-messages-list {
    padding: 10px 16px;
    gap: 8px;
  }
  
  .pinned-card {
    padding: 8px 12px;
    gap: 12px;
  }
  
  .pinned-card-content {
    font-size: 12px;
  }
}

/* Messages Skeleton Loader */
.skeleton-feed {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  margin-bottom: 20px;
}

.skeleton-bubble {
  height: 48px;
  border-radius: 16px;
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-hover) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: pulse-glow 1.5s infinite ease-in-out;
  opacity: 0.7;
}

.skeleton-bubble.left {
  align-self: flex-start;
  width: 60%;
  border-bottom-left-radius: 4px;
}

.skeleton-bubble.right {
  align-self: flex-start;
  width: 45%;
  border-bottom-left-radius: 4px;
}

@keyframes pulse-glow {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Composer Formatting Toolbar & Live Preview Bubble */
.composer-format-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
  width: 100%;
}

.format-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.format-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.format-btn.active {
  background: var(--accent-color);
  color: #ffffff;
  border-color: var(--accent-color);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
}

.format-icon {
  width: 16px;
  height: 16px;
}

.composer-live-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 10px;
  border-radius: 12px;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
  animation: slideUpFade 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.preview-header-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--accent-color);
}

.preview-content-rendered {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  max-height: 140px;
  overflow-y: auto;
}

/* Animations */
@keyframes slideUpFade {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
