@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,300;0,400;0,500;0,700;0,900;1,400&display=swap');

/* ==========================================
   DESIGN TOKENS & ROOT VARIABLES
   ========================================== */
:root {
  /* Premium Light Sky Blue & Modern Slate Palette */
  --bg-primary: #F1F5F9; /* Clean modern slate-100 background */
  --bg-card: #FFFFFF;
  --text-main: #0F172A; /* Deep slate-900 for absolute contrast and readability */
  --text-muted: #475569; /* Slate-600 for high readability secondary text */
  --accent: #3FA2F6; /* Vibrant premium Light Sky Blue */
  --accent-light: #E0F2FE; /* Softest sky blue-50 highlight background */
  --border: rgba(63, 162, 246, 0.15);
  --border-light: rgba(63, 162, 246, 0.08);
  --shadow-sm: 0 2px 8px rgba(63, 162, 246, 0.05);
  --shadow-md: 0 10px 30px rgba(63, 162, 246, 0.08);
  --shadow-lg: 0 20px 50px rgba(63, 162, 246, 0.12);

  /* Rounded Corner Tokens (approx 18%) */
  --border-radius-lg: 18px;
  --border-radius-md: 12px;
  --border-radius-sm: 8px;

  /* Typography - Unified Roboto Font Family */
  --font-serif: 'Roboto', sans-serif;
  --font-sans: 'Roboto', sans-serif;

  /* Transitions */
  --transition-smooth: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Dark Theme Variables */
body.dark-theme-crm {
  --bg-primary: #0F172A; /* Deep slate-900 */
  --bg-card: #1E293B; /* Slate-800 */
  --text-main: #F8FAFC; /* Slate-50 */
  --text-muted: #94A3B8; /* Slate-400 */
  --accent: #38BDF8; /* Radiant Light Sky Blue for dark mode */
  --accent-light: #0C4A6E; /* Slate-800 deep sky highlight */
  --border: rgba(56, 189, 248, 0.25);
  --border-light: rgba(56, 189, 248, 0.12);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.5);
}

/* ==========================================
   RESET & BASE STYLES
   ========================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
}

body {
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  line-height: 1.5;
  transition: background-color 0.4s ease, color 0.4s ease;
}

input, button {
  font-family: inherit;
  font-size: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

/* Fine Editorial Architectural Gridlines */
.grid-lines {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  opacity: 0.35;
}

.grid-line {
  border-right: 1px solid var(--border);
  height: 100%;
}

.grid-line:last-child {
  border-right: none;
}

/* Animations & Reveals */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.active {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================
   1. LOGIN PORTAL STYLE
   ========================================== */
.login-wrapper {
  position: relative;
  z-index: 10;
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  background: radial-gradient(circle at 10% 20%, var(--accent-light) 0%, transparent 40%),
              radial-gradient(circle at 90% 80%, var(--accent-light) 0%, transparent 40%);
}

.login-card {
  width: 100%;
  max-width: 460px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 3.5rem 3rem;
  box-shadow: var(--shadow-lg);
  border-radius: var(--border-radius-lg);
  position: relative;
  transition: background-color 0.4s ease, border-color 0.4s ease;
}

.login-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.login-logo {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.login-header h2 {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
}

.login-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Form Styles */
.form-group-login {
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group-login label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 1rem;
  width: 18px;
  height: 18px;
  fill: var(--text-muted);
  opacity: 0.7;
}

.input-wrapper input {
  width: 100%;
  padding: 0.9rem 1rem 0.9rem 2.8rem;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: var(--border-radius-md);
  outline: none;
  transition: var(--transition-fast);
}

.input-wrapper input:focus {
  border-color: var(--accent);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(188, 158, 108, 0.15);
}

.btn-toggle-password {
  position: absolute;
  right: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.eye-icon {
  width: 18px;
  height: 18px;
  fill: var(--text-muted);
  opacity: 0.6;
  transition: var(--transition-fast);
}

.btn-toggle-password:hover .eye-icon,
.btn-toggle-password.active .eye-icon {
  fill: var(--accent);
  opacity: 1;
}

.btn-submit-login {
  width: 100%;
  padding: 1.1rem;
  background: var(--text-main);
  color: #FFFFFF;
  border-radius: var(--border-radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  border: 1px solid var(--text-main);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-fast);
  margin-top: 1rem;
}

.btn-submit-login:hover {
  background: var(--accent);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

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

.login-footer {
  text-align: center;
  margin-top: 2.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* ==========================================
   2. MAIN APPLICATION PORTAL LAYOUT
   ========================================== */
.app-root-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  position: relative;
  z-index: 5;
  background: var(--bg-primary);
}

/* LEFT NAVIGATION SIDEBAR */
.portal-sidebar {
  width: 280px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 2rem 1.5rem;
  z-index: 20;
  transition: var(--transition-smooth);
}

.sidebar-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2.5rem;
  padding-left: 0;
}

.logo-text {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--text-main);
  line-height: 1.2;
}

.logo-sub {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: 0.2rem;
}

.sidebar-user-wrapper:hover .sidebar-user-dropdown {
  display: block !important;
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.sidebar-user-badge {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.2rem;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--border-radius-md);
  transition: var(--transition-fast);
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 1px;
  box-shadow: var(--shadow-sm);
}

.sidebar-user-badge .info h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.sidebar-user-badge .info span {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Sidebar Menu Navigation */
.sidebar-menu {
  flex: 1;
}

.sidebar-menu ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.2rem;
  border-radius: var(--border-radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.9rem;
  transition: var(--transition-fast);
  cursor: pointer;
}

.menu-item svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  transition: var(--transition-fast);
}

.menu-item:hover, .menu-item.active {
  color: var(--text-main);
  background: var(--accent-light);
}

.menu-item.active {
  font-weight: 600;
  border-left: 3px solid var(--accent);
  padding-left: calc(1.2rem - 3px);
}

/* Sidebar Footer */
.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
}

.footer-btn {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.2rem;
  border-radius: var(--border-radius-sm);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  width: 100%;
  text-align: left;
  transition: var(--transition-fast);
}

.footer-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

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

.btn-logout-app-portal:hover {
  color: #EF4444;
  background: rgba(239, 68, 68, 0.05);
}

/* RIGHT MAIN WORKSPACE */
.portal-main-workspace {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* DASHBOARD COMMON ELEMENTS */
.dashboard-wrapper {
  width: 100%;
  height: 100%;
  display: none; /* Controlled via JS switch */
}

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

/* Topbar Header */
.dashboard-topbar {
  height: 80px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 3rem;
  flex-shrink: 0;
}

.topbar-title-group h2 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--text-main);
}

.breadcrumbs {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  font-weight: 500;
}

.breadcrumbs span.portal-breadcrumb-home {
  cursor: pointer;
  transition: var(--transition-fast);
}

.breadcrumbs span.portal-breadcrumb-home:hover {
  color: var(--accent);
}

.breadcrumbs .sep {
  margin: 0 0.4rem;
  opacity: 0.5;
}

.breadcrumbs .active-crumb {
  color: var(--accent);
}

.user-profile-badge-inline {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.profile-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.profile-info-desktop {
  display: flex;
  flex-direction: column;
}

.profile-info-desktop .name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.profile-info-desktop .role {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ==========================================
   3. CHAT CANVAS SYSTEM (TELEGRAM LAYOUT)
   ========================================== */
.chat-canvas-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  background: var(--bg-primary);
}

/* Chat Sidebar (Left Threads List) */
.chat-sidebar {
  width: 320px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.chat-sidebar-search {
  padding: 1.5rem;
  position: relative;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
}

.chat-sidebar-search .search-icon {
  position: absolute;
  left: 2.2rem;
  width: 16px;
  height: 16px;
  fill: var(--text-muted);
  opacity: 0.6;
}

.chat-sidebar-search input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 20px;
  outline: none;
  font-size: 0.85rem;
  transition: var(--transition-fast);
}

.chat-sidebar-search input:focus {
  border-color: var(--accent);
  background: var(--bg-card);
}

.chat-threads-list {
  flex: 1;
  overflow-y: auto;
}

.chat-thread-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: var(--transition-fast);
}

.chat-thread-item:hover {
  background: var(--bg-primary);
}

.chat-thread-item.active {
  background: var(--accent-light);
}

.chat-thread-details {
  flex: 1;
  min-width: 0;
}

.chat-thread-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.25rem;
}

.chat-thread-header .title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-thread-header .time {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}

.chat-thread-preview {
  display: flex;
  justify-content: space-between;
}

.chat-thread-preview .message {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Unread Message Threads & Badges */
.chat-thread-item.unread .chat-thread-header .title {
  font-weight: 700 !important;
  color: #000000 !important;
}

.chat-thread-item.unread .chat-thread-preview .message {
  font-weight: 700 !important;
  color: #111827 !important; /* Elegant deep-black */
}

.unread-badge {
  background: #EF4444;
  color: #ffffff !important;
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  margin-left: 8px;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
  animation: badgeAppear 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes badgeAppear {
  from {
    transform: scale(0.6);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Chat Window Area (Right) */
.chat-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-primary);
}

.chat-window-header {
  height: 70px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2rem;
  flex-shrink: 0;
  z-index: 10;
}

.active-chat-info {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.avatar-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--text-main);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: var(--shadow-sm);
}

.active-chat-details h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

.active-chat-details span {
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 500;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: var(--transition-fast);
}

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

.header-icon-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Inline Message Search Bar */
.chat-search-bar-inline {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  padding: 0 2rem;
  gap: 1rem;
  z-index: 15;
  animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.chat-search-bar-inline .search-icon {
  width: 18px;
  height: 18px;
  fill: var(--text-muted);
}

.chat-search-bar-inline input {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  color: var(--text-main);
  font-size: 0.9rem;
}

.btn-close-inline-search {
  font-size: 1.5rem;
  color: var(--text-muted);
  transition: var(--transition-fast);
}

.btn-close-inline-search:hover {
  color: var(--text-main);
}

/* Messages Container */
.chat-messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  background: radial-gradient(circle at center, var(--border-light) 0%, transparent 80%);
}

.chat-bubble-row {
  display: flex;
  gap: 1rem;
  max-width: 75%;
}

.chat-bubble-row.sent {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-bubble-row.received {
  align-self: flex-start;
}

.chat-bubble {
  padding: 1rem 1.2rem;
  border-radius: 12px;
  position: relative;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  line-height: 1.5;
}

.chat-bubble-row {
  position: relative;
}

.chat-bubble-row:hover .chat-bubble-actions {
  display: flex !important;
}

.chat-bubble-row.sent .chat-bubble {
  background: var(--accent-light);
  color: var(--text-main);
  border-top-right-radius: 0;
  border: 1px solid rgba(188, 158, 108, 0.2);
}

.chat-bubble-row.received .chat-bubble {
  background: var(--bg-card);
  color: var(--text-main);
  border-top-left-radius: 0;
  border: 1px solid var(--border);
}

.sender-name {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
}

.chat-bubble .content {
  font-size: 0.9rem;
  word-break: break-word;
}

.time-stamp {
  font-size: 0.65rem;
  color: var(--text-muted);
  align-self: flex-end;
  margin-top: 0.2rem;
  font-weight: 500;
}

.highlight-match {
  background: rgba(212, 175, 55, 0.3);
  color: var(--text-main);
  padding: 0 2px;
  border-radius: 2px;
}

/* Chat Input Bar */
.chat-input-bar {
  height: 80px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 2rem;
  gap: 1rem;
  flex-shrink: 0;
}

.chat-input-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: var(--transition-fast);
}

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

.chat-input-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.chat-input-bar input {
  flex: 1;
  padding: 0.9rem 1.5rem;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 24px;
  outline: none;
  font-size: 0.9rem;
  transition: var(--transition-fast);
}

.chat-input-bar input:focus {
  border-color: var(--accent);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(188, 158, 108, 0.1);
}

.btn-send-message {
  background: var(--text-main);
  color: #FFFFFF;
}

.btn-send-message:hover {
  background: var(--accent);
  color: #FFFFFF;
}

/* Emoji Picker Popup */
.chat-emoji-picker-popup {
  position: absolute;
  bottom: 85px;
  left: 2rem;
  width: 320px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.chat-emoji-grid button:hover {
  transform: scale(1.2);
  transition: transform 0.15s ease;
}

/* ==========================================
   4. STAFF CREATION DASHBOARD (ADMIN PANEL)
   ========================================== */
.users-page-wrapper .dashboard-canvas {
  flex: 1;
  padding: 3rem;
  overflow-y: auto;
}

.users-split-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 3rem;
  max-width: 1400px;
  margin: 0 auto;
}

.user-form-card, .user-list-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius-lg);
  padding: 2.5rem;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.4s ease, border-color 0.4s ease;
}

.user-form-card h3, .user-list-card h3 {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--text-main);
  letter-spacing: 1px;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 1rem;
}

.user-form-card form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.user-form-card input {
  width: 100%;
  padding: 0.8rem 1rem;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: var(--border-radius-md);
  outline: none;
  transition: var(--transition-fast);
}

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

/* Unified High-Quality Premium Input & Form Styles for Modals */
#studentForm input,
#studentForm select,
#studentForm textarea,
#profileForm input {
  width: 100%;
  padding: 0.8rem 1.2rem;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: var(--border-radius-md);
  outline: none;
  font-family: inherit;
  font-size: 0.9rem;
  transition: var(--transition-fast);
}

#studentForm input:focus,
#studentForm select:focus,
#studentForm textarea:focus,
#profileForm input:focus {
  border-color: var(--accent);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(188, 158, 108, 0.15);
}

#studentForm select {
  height: 44px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23526E8D'%3E%3Cpath d='M7 10l5 5 5-5H7z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1.5rem;
  padding-right: 2.5rem;
}

/* Financial-table style list with floating rounded rows */
.mini-table-container {
  overflow-x: auto;
}

.financial-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 8px;
  text-align: left;
}

.financial-table th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  padding: 1rem;
  border-bottom: none;
  text-align: center;
}

.financial-table td {
  padding: 1.2rem 1rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-main);
  vertical-align: middle;
  background: var(--bg-primary);
  transition: var(--transition-fast);
  text-align: center;
}

.financial-table td:first-child {
  border-left: 1px solid var(--border);
  border-top-left-radius: var(--border-radius-md);
  border-bottom-left-radius: var(--border-radius-md);
}

.financial-table td:last-child {
  border-right: 1px solid var(--border);
  border-top-right-radius: var(--border-radius-md);
  border-bottom-right-radius: var(--border-radius-md);
}

.financial-table tr:hover td {
  background: var(--accent-light);
  border-color: var(--accent);
}

.font-mono {
  font-family: monospace;
}

/* Status Badges */
.crm-badge {
  display: inline-flex;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-danghoc {
  background: rgba(188, 158, 108, 0.15);
  color: var(--accent);
}

.badge-waiting {
  background: rgba(245, 166, 35, 0.15);
  color: #D97706;
}

.badge-selected {
  background: rgba(16, 185, 129, 0.15);
  color: #10B981;
}

.badge-processing {
  background: rgba(82, 110, 141, 0.15);
  color: var(--text-muted);
}

.btn-delete-staff:hover {
  background: rgba(239, 68, 68, 0.08) !important;
  color: #DC2626 !important;
}

/* ==========================================
   5. TOAST SYSTEM STYLING
   ========================================== */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 320px;
  max-width: 450px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--text-main);
  padding: 1.2rem 1.5rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  border-radius: var(--border-radius-md);
  animation: slideInLeft 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: var(--transition-fast);
}

.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.toast-icon svg {
  width: 100%;
  height: 100%;
}

.toast-message {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text-main);
  font-weight: 500;
  line-height: 1.4;
}

.toast-close {
  font-size: 1.2rem;
  color: var(--text-muted);
  opacity: 0.6;
  transition: var(--transition-fast);
}

.toast-close:hover {
  opacity: 1;
  color: var(--text-main);
}

/* Toast Color States */
.toast-success {
  border-left-color: #10B981;
}
.toast-success svg {
  fill: #10B981;
}

.toast-error {
  border-left-color: #EF4444;
}
.toast-error svg {
  fill: #EF4444;
}

.toast-warning {
  border-left-color: #F5A623;
}
.toast-warning svg {
  fill: #F5A623;
}

.toast-info {
  border-left-color: var(--accent);
}
.toast-info svg {
  fill: var(--accent);
}

.toast-fade-out {
  opacity: 0;
  transform: translateY(20px) scale(0.95);
}

/* Custom Webkit Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ==========================================
   ANIMATIONS
   ========================================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(100%) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

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

/* Responsive Hacks */
@media (max-width: 1024px) {
  .users-split-grid {
    grid-template-columns: 1fr;
  }
  .portal-sidebar {
    width: 80px;
    padding: 2rem 0.5rem;
    align-items: center;
  }
  .sidebar-logo .logo-sub,
  .sidebar-user-badge .info,
  .menu-item span,
  .footer-btn span {
    display: none;
  }
  .sidebar-logo {
    align-items: center;
    padding: 0;
  }
  .logo-text {
    font-size: 1.3rem;
  }
  .sidebar-user-badge {
    padding: 0.5rem;
    justify-content: center;
  }
  .menu-item {
    justify-content: center;
    padding: 1rem;
  }
  .footer-btn {
    justify-content: center;
    padding: 0.9rem;
  }
}

@media (max-width: 768px) {
  .app-root-container {
    flex-direction: column;
  }
  .portal-sidebar {
    width: 100%;
    height: auto;
    flex-direction: row;
    justify-content: space-between;
    padding: 1rem 2rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-logo, .sidebar-user-badge, .sidebar-footer {
    display: none;
  }
  .sidebar-menu ul {
    flex-direction: row;
  }
  .chat-sidebar {
    display: none; /* Hide threads list on mobile for full chat canvas */
  }
  .dashboard-topbar {
    padding: 0 1.5rem;
  }
}

/* Topbar User Profile Hover Dropdown */
.topbar-user-wrapper:hover .topbar-user-dropdown {
  display: block !important;
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.topbar-user-wrapper:hover .user-profile-badge-inline {
  background: var(--accent-light);
}

.topbar-user-dropdown .footer-btn:hover {
  background: var(--bg-primary) !important;
  color: var(--text-main) !important;
}

.topbar-user-dropdown .footer-btn.btn-logout-app-portal:hover {
  background: rgba(239, 68, 68, 0.05) !important;
  color: #EF4444 !important;
}

/* Student Search Input Focus Effect */
#studentSearchInput:focus {
  border-color: var(--accent) !important;
  background: var(--bg-card) !important;
  box-shadow: 0 0 0 3px rgba(188, 158, 108, 0.15) !important;
}

/* ==========================================
   4. STUDENT PORTAL SPECIFIC STYLING (PALAIS SYSTEM)
   ========================================== */
.student-header-navbar {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  background: rgba(255, 255, 255, 0.85) !important;
  transition: var(--transition-smooth);
}
body.dark-theme-crm .student-header-navbar {
  background: rgba(22, 22, 26, 0.85) !important;
}

.student-nav-item {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: var(--transition-fast);
}

.student-nav-item:hover {
  color: var(--text-main);
}

.student-nav-item.active {
  color: var(--text-main) !important;
  font-weight: 600;
}

.student-tab-content {
  display: none;
  animation: fadeInStudentTab 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.student-tab-content.active {
  display: block;
}

/* Timeline Customization */
.milestone-timeline {
  margin-top: 1.5rem;
}

.milestone-dot {
  transition: var(--transition-smooth);
}

.milestone-dot.completed {
  box-shadow: 0 0 0 4px rgba(188, 158, 108, 0.2);
}

.milestone-dot.active {
  box-shadow: 0 0 0 6px rgba(188, 158, 108, 0.3);
  animation: pulseGold 2s infinite;
}

@keyframes pulseGold {
  0% {
    box-shadow: 0 0 0 0px rgba(188, 158, 108, 0.4);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(188, 158, 108, 0);
  }
  100% {
    box-shadow: 0 0 0 0px rgba(188, 158, 108, 0);
  }
}

/* Asymmetric Blog Grid & Elegant Card zoom */
.blog-card img {
  transition: var(--transition-smooth);
}

.blog-card:hover img {
  transform: scale(1.03);
}

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

/* VietQR simulator style */
.student-nav-menu button {
  border-top: none;
  border-left: none;
  border-right: none;
  border-radius: 0;
  outline: none;
}

/* Chat bubble actions toolbar & new message features */
.chat-bubble-actions {
  display: none;
  align-items: center;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 4px 6px;
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
  z-index: 100;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  transition: opacity 0.2s ease, visibility 0.2s ease;
  pointer-events: auto;
}

.chat-bubble-row.sent .chat-bubble-actions {
  left: -4px;
  transform: translate(-100%, -50%);
}

.chat-bubble-row.received .chat-bubble-actions {
  right: -4px;
  transform: translate(100%, -50%);
}

/* Invisible hover bridge to prevent toolbar from disappearing when cursor crosses the gap */
.chat-bubble-actions::after {
  content: '';
  position: absolute;
  top: -10px;
  bottom: -10px;
  width: 25px;
  background: transparent;
  z-index: -1;
}

.chat-bubble-row.sent .chat-bubble-actions::after {
  right: -15px;
}

.chat-bubble-row.received .chat-bubble-actions::after {
  left: -15px;
}

.chat-action-btn {
  background: none;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
}

.chat-action-btn:hover {
  background: var(--bg-primary);
  color: var(--text-main);
  transform: scale(1.1);
}

.chat-action-btn.btn-recall-action:hover {
  color: var(--accent);
  background: var(--accent-light);
}

.chat-action-btn.btn-delete-action:hover {
  color: #EF4444;
  background: rgba(239, 68, 68, 0.1);
}

.chat-action-btn svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.chat-bubble.recalled {
  background: rgba(0, 0, 0, 0.03) !important;
  border: 1px dashed var(--border) !important;
  color: var(--text-muted) !important;
  font-style: italic;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.8rem 1.2rem;
  border-radius: var(--border-radius-md);
  font-size: 0.85rem;
}

.chat-bubble.recalled .recalled-icon {
  width: 14px;
  height: 14px;
  opacity: 0.6;
  fill: currentColor;
  display: inline-block;
}

.chat-bubble .forwarded-tag {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  color: var(--accent);
  font-style: italic;
  margin-bottom: 4px;
  font-weight: 600;
  opacity: 0.9;
}

.chat-bubble .forwarded-tag svg {
  width: 10px;
  height: 10px;
  fill: currentColor;
}

/* Premium Glassmorphic Modal for Forwarding */
.premium-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(10px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.premium-modal-glass {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 460px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUpModal 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.premium-modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.premium-modal-header h3 {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main);
  margin: 0;
}

.premium-modal-header .btn-close-modal {
  background: none;
  border: none;
  font-size: 1.8rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.premium-modal-header .btn-close-modal:hover {
  color: var(--text-main);
}

.premium-modal-body {
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
}

.premium-modal-body .search-wrapper input {
  width: 100%;
  padding: 0.75rem 1.2rem;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 20px;
  outline: none;
  font-size: 0.85rem;
  transition: var(--transition-fast);
}

.premium-modal-body .search-wrapper input:focus {
  border-color: var(--accent);
  background: var(--bg-card);
}

.forward-targets-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
}

.forward-target-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-light);
  cursor: pointer;
  transition: var(--transition-fast);
  background: var(--bg-primary);
}

.forward-target-item:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}

.forward-target-item .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.forward-target-item .name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.forward-target-item .role {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: auto;
  font-weight: 600;
  text-transform: uppercase;
  flex-shrink: 0;
}

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

/* Premium custom context menu */
.premium-context-menu {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius-sm);
  box-shadow: var(--shadow-lg);
  min-width: 150px;
  padding: 4px 0;
  backdrop-filter: blur(10px);
  animation: fadeInFast 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.context-menu-content {
  display: flex;
  flex-direction: column;
}

.context-item {
  background: none;
  border: none;
  padding: 10px 14px;
  text-align: left;
  font-size: 0.85rem;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition-fast);
  width: 100%;
}

.context-item:hover {
  background: var(--accent-light);
  color: var(--text-main);
}

.context-item svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  opacity: 0.8;
}

@keyframes fadeInFast {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-5px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.btn-connect-friend {
  background: var(--accent);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: var(--border-radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  margin-left: auto;
}

.btn-connect-friend:hover {
  background: var(--text-main);
  transform: scale(1.05);
}

.badge-connected-friend {
  background: rgba(16, 185, 129, 0.15);
  color: #10B981;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-left: auto;
}

/* Thread Menu dropdown styling */
.thread-menu-btn {
  opacity: 0;
  transition: opacity 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.chat-thread-item:hover .thread-menu-btn,
.thread-menu-btn.active {
  opacity: 1;
}

.thread-menu-btn:hover {
  background: var(--border-light);
  color: var(--text-main);
}

.btn-delete-thread:hover {
  background: rgba(239, 68, 68, 0.08) !important;
}

/* Friend Requests Badge */
.friend-badge {
  position: absolute !important;
  top: -5px !important;
  right: -5px !important;
  background: #EF4444 !important;
  color: white !important;
  border-radius: 50% !important;
  width: 18px !important;
  height: 18px !important;
  font-size: 0.65rem !important;
  font-weight: 700 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border: 2px solid var(--bg-card) !important;
  box-shadow: var(--shadow-sm) !important;
  z-index: 99999 !important;
}