@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ─── CSS Variables ─────────────────────────────────────── */
:root {
  --primary:       #1b6e3b;
  --primary-dark:  #145230;
  --primary-light: #2d9c58;
  --accent:        #27ae60;
  --accent-light:  #52d68a;
  --bg:            #f4fbf6;
  --bg-alt:        #eaf5ed;
  --white:         #ffffff;
  --card-bg:       rgba(255,255,255,0.95);
  --text-dark:     #1a2e23;
  --text-mid:      #3d5c47;
  --text-light:    #7a9d84;
  --border:        #c8e6d0;
  --shadow-sm:     0 2px 8px rgba(27,110,59,0.10);
  --shadow-md:     0 8px 32px rgba(27,110,59,0.14);
  --shadow-lg:     0 20px 60px rgba(27,110,59,0.18);
  --radius-sm:     8px;
  --radius-md:     14px;
  --radius-lg:     22px;
  --radius-xl:     32px;
  --transition:    0.25s cubic-bezier(0.4,0,0.2,1);
}

/* ─── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-dark);
  min-height: 100vh;
  line-height: 1.6;
}
a { text-decoration: none; color: inherit; }
img { max-width: 100%; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ─── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-alt); }
::-webkit-scrollbar-thumb { background: var(--primary-light); border-radius: 99px; }

/* ─── Typography ────────────────────────────────────────── */
h1 { font-size: 1.9rem; font-weight: 800; }
h2 { font-size: 1.4rem; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 600; }
p  { font-size: 0.95rem; }

/* ─── Utility ───────────────────────────────────────────── */
.hidden   { display: none !important; }
.flex     { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2    { gap: 0.5rem; }
.gap-3    { gap: 0.75rem; }
.gap-4    { gap: 1rem; }
.mt-1     { margin-top: 0.25rem; }
.mt-2     { margin-top: 0.5rem; }
.mt-3     { margin-top: 0.75rem; }
.mt-4     { margin-top: 1rem; }
.w-full   { width: 100%; }
.text-center { text-align: center; }
.text-sm  { font-size: 0.85rem; }
.text-xs  { font-size: 0.78rem; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-primary { color: var(--primary); }
.text-light   { color: var(--text-light); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.4rem; padding: 0.6rem 1.3rem;
  border: none; border-radius: var(--radius-md);
  font-size: 0.9rem; font-weight: 600;
  cursor: pointer; transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  box-shadow: 0 4px 14px rgba(27,110,59,0.35);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(27,110,59,0.45);
  filter: brightness(1.05);
}
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}
.btn-outline:hover {
  background: var(--primary);
  color: white;
}
.btn-danger {
  background: linear-gradient(135deg, #e53e3e, #c53030);
  color: white;
}
.btn-danger:hover { filter: brightness(1.1); }
.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.82rem; }
.btn-icon { padding: 0.5rem; border-radius: 50%; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ─── Form Elements ─────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-label { font-size: 0.875rem; font-weight: 600; color: var(--text-mid); }
.form-control {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.93rem;
  background: white;
  color: var(--text-dark);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27,110,59,0.12);
}
.form-control::placeholder { color: var(--text-light); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }

/* ─── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
  border: 1px solid var(--border);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.2rem;
  padding-bottom: 0.9rem;
  border-bottom: 1.5px solid var(--border);
}
.card-title { font-size: 1rem; font-weight: 700; color: var(--text-dark); }

/* ─── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 0.2rem;
  padding: 0.22rem 0.7rem; border-radius: 99px;
  font-size: 0.78rem; font-weight: 600;
}
.badge-green  { background: #d4f4e1; color: #1b6e3b; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-orange { background: #fef3c7; color: #d97706; }
.badge-red    { background: #fee2e2; color: #dc2626; }
.badge-gray   { background: #f3f4f6; color: #6b7280; }

/* ─── Toast / Alert ─────────────────────────────────────── */
#toast-container {
  position: fixed; top: 1.2rem; right: 1.2rem;
  z-index: 9999; display: flex; flex-direction: column; gap: 0.6rem;
}
.toast {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.85rem 1.2rem;
  background: white; border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem; font-weight: 500;
  animation: slideInRight 0.3s cubic-bezier(0.4,0,0.2,1);
  min-width: 260px; max-width: 360px;
  border-left: 4px solid var(--primary);
}
.toast-icon {
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  color: var(--primary);
  background: rgba(27,110,59,0.1);
}
.toast.error { border-left-color: #dc2626; }
.toast.error .toast-icon { color: #dc2626; background: rgba(220,38,38,0.1); }
.toast.success { border-left-color: #16a34a; }
.toast.success .toast-icon { color: #16a34a; background: rgba(22,163,74,0.1); }
.toast.info .toast-icon { color: #2563eb; background: rgba(37,99,235,0.1); }
.toast.warning .toast-icon { color: #d97706; background: rgba(217,119,6,0.1); }
@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ─── Modal ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s ease;
}
.modal-box {
  background: white; border-radius: var(--radius-xl);
  padding: 2rem; width: 90%; max-width: 520px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
  max-height: 90vh; overflow-y: auto;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.5rem;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ─── Table ──────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); max-width: 100%; display: block; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
thead tr { background: linear-gradient(135deg, var(--primary), var(--primary-light)); }
thead th {
  padding: 0.8rem 1rem; text-align: left;
  font-weight: 600; color: white;
  white-space: nowrap;
}
thead th:first-child { border-radius: var(--radius-sm) 0 0 0; }
thead th:last-child  { border-radius: 0 var(--radius-sm) 0 0; }
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
tbody tr:hover { background: var(--bg-alt); }
tbody td { padding: 0.75rem 1rem; vertical-align: middle; }

/* ─── Sidebar Layout ─────────────────────────────────────── */
.app-layout {
  display: flex; min-height: 100vh;
}
.sidebar {
  width: 240px; min-height: 100vh;
  background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0;
  z-index: 100;
  box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  transition: transform var(--transition);
}
.sidebar-logo {
  display: flex; flex-direction: column; align-items: center;
  padding: 1.8rem 1rem 1.2rem;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}
.sidebar-logo img { width: 60px; height: 60px; object-fit: contain; border-radius: 50%; }
.sidebar-logo-text {
  color: white; font-size: 0.78rem; font-weight: 600;
  text-align: center; margin-top: 0.5rem; opacity: 0.9;
  line-height: 1.3;
}
.sidebar-nav { flex: 1; padding: 1rem 0; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.75rem 1.3rem;
  color: rgba(255,255,255,0.78);
  font-size: 0.9rem; font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  user-select: none;
}
.nav-item:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}
.nav-item.active {
  background: rgba(255,255,255,0.18);
  color: white;
  border-left-color: var(--accent-light);
  font-weight: 600;
}
.nav-item svg, .nav-item .nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: #ef4444; color: white;
  border-radius: 99px; font-size: 0.7rem;
  padding: 0.1rem 0.45rem; font-weight: 700;
}

.main-content {
  margin-left: 240px; flex: 1;
  display: flex; flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}
.topbar {
  background: white;
  padding: 0.85rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 1.1rem; font-weight: 700; color: var(--text-dark); }
.topbar-user {
  display: flex; align-items: center; gap: 0.7rem;
  font-size: 0.88rem; font-weight: 500; color: var(--text-mid);
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 0.95rem;
}
.page-content { padding: 1.5rem; flex: 1; }

/* ─── Stats Cards ────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.stat-card {
  background: white; border-radius: var(--radius-lg);
  padding: 1.3rem 1.5rem;
  display: flex; align-items: center; gap: 1rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 48px; height: 48px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
}
.stat-icon.green  { background: #d4f4e1; }
.stat-icon.blue   { background: #dbeafe; }
.stat-icon.orange { background: #fef3c7; }
.stat-icon.purple { background: #ede9fe; }
.stat-value { font-size: 1.8rem; font-weight: 800; color: var(--text-dark); line-height: 1; }
.stat-label { font-size: 0.8rem; font-weight: 500; color: var(--text-light); margin-top: 0.2rem; }

/* ─── Login Page ─────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: var(--bg);
  position: relative; overflow: hidden;
}
.login-blob {
  position: absolute; border-radius: 50%;
  background: rgba(27,110,59,0.08);
  pointer-events: none;
}
.login-blob-1 { width: 360px; height: 360px; top: -80px; left: -80px; }
.login-blob-2 { width: 220px; height: 220px; bottom: 60px; right: -40px; }
.login-blob-3 { width: 100px; height: 100px; bottom: 150px; left: 80px;
  background: rgba(27,110,59,0.12); }
.login-blob-4 { width: 80px; height: 80px; top: 200px; right: 140px;
  background: rgba(27,110,59,0.07); }

.login-card {
  background: white;
  border-radius: var(--radius-xl);
  padding: 2.8rem 2.5rem 2.2rem;
  width: 100%; max-width: 440px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  position: relative; z-index: 1;
  animation: slideUp 0.4s ease;
}
.login-logo {
  display: flex; flex-direction: column; align-items: center;
  margin-bottom: 1.8rem;
}
.login-logo img { width: 80px; height: 80px; object-fit: contain; }
.login-logo-name {
  font-size: 0.78rem; font-weight: 600;
  color: var(--primary); margin-top: 0.5rem; text-align: center;
}
.login-title {
  text-align: center; font-size: 1.6rem; font-weight: 800;
  color: var(--text-dark); margin-bottom: 0.3rem;
}
.login-subtitle {
  text-align: center; font-size: 0.85rem; color: var(--primary);
  font-style: italic; margin-bottom: 1.8rem; line-height: 1.5;
}
.btn-login {
  width: 100%; padding: 0.9rem;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white; border: none; border-radius: var(--radius-md);
  font-size: 1rem; font-weight: 700;
  cursor: pointer; transition: all var(--transition);
  box-shadow: 0 4px 14px rgba(27,110,59,0.4);
  margin-top: 0.5rem;
}
.btn-login:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(27,110,59,0.5);
}
.login-footer {
  text-align: center; margin-top: 1.5rem;
  font-size: 0.8rem; color: var(--text-light);
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
}
.login-footer img { width: 30px; height: 30px; opacity: 0.7; }

/* ─── Input with icon ────────────────────────────────────── */
.input-wrap { position: relative; }
.input-wrap .input-icon {
  position: absolute; left: 0.9rem; top: 50%; transform: translateY(-50%);
  color: var(--text-light); pointer-events: none;
  display: flex; align-items: center;
}
.input-wrap .form-control { padding-left: 2.5rem; }
.input-wrap .input-eye {
  position: absolute; right: 0.9rem; top: 50%; transform: translateY(-50%);
  cursor: pointer; color: var(--text-light);
  display: flex; align-items: center;
  transition: color var(--transition);
}
.input-wrap .input-eye:hover { color: var(--primary); }

/* ─── Ranking Page ───────────────────────────────────────── */
.ranking-podium {
  display: flex; align-items: flex-end; justify-content: center;
  gap: 1rem; margin: 1.5rem 0;
}
.podium-item {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.5rem;
}
.podium-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 800;
  border: 3px solid white;
  box-shadow: var(--shadow-md);
}
.podium-avatar.gold   { background: linear-gradient(135deg, #f6d365, #fda085); color: #7c4a00; }
.podium-avatar.silver { background: linear-gradient(135deg, #d7d2cc, #304352); color: #fff; }
.podium-avatar.bronze { background: linear-gradient(135deg, #c97b2a, #e8956b); color: #fff; }
.podium-block {
  width: 90px; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end; padding: 0.7rem;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  color: white; font-weight: 700;
}
.podium-block.gold   { height: 110px; background: linear-gradient(180deg, #f6d365, #e8a100); }
.podium-block.silver { height: 80px;  background: linear-gradient(180deg, #c8ccd0, #8a95a0); }
.podium-block.bronze { height: 60px;  background: linear-gradient(180deg, #d4935a, #a0632c); }
.podium-name { font-size: 0.72rem; text-align: center; opacity: 0.9; line-height: 1.2; }
.podium-score { font-size: 1rem; font-weight: 800; }

.ranking-list { display: flex; flex-direction: column; gap: 0.6rem; }
.ranking-item {
  display: flex; align-items: center; gap: 1rem;
  background: white; border-radius: var(--radius-md);
  padding: 0.9rem 1.2rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: transform var(--transition), box-shadow var(--transition);
}
.ranking-item:hover { transform: translateX(4px); box-shadow: var(--shadow-md); }
.ranking-num {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.88rem; flex-shrink: 0;
  background: var(--bg-alt); color: var(--text-mid);
}
.ranking-num.top { background: linear-gradient(135deg, var(--primary), var(--accent)); color: white; }
.ranking-room { flex: 1; }
.ranking-room-name { font-weight: 600; font-size: 0.92rem; }
.ranking-room-meta { font-size: 0.78rem; color: var(--text-light); }
.ranking-score {
  font-size: 1.1rem; font-weight: 800; color: var(--primary);
}
.ranking-bar-wrap { width: 100px; }
.ranking-bar {
  height: 6px; background: var(--bg-alt); border-radius: 99px; overflow: hidden;
}
.ranking-bar-fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), var(--accent-light));
  transition: width 0.8s cubic-bezier(0.4,0,0.2,1);
}

/* ─── Upload Form ────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 2rem; text-align: center;
  cursor: pointer; transition: all var(--transition);
  background: var(--bg-alt);
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--primary);
  background: rgba(27,110,59,0.05);
}
.upload-zone .upload-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.upload-zone .upload-text { font-size: 0.88rem; color: var(--text-mid); }
.upload-zone .upload-hint { font-size: 0.78rem; color: var(--text-light); margin-top: 0.2rem; }
.upload-zone.has-file { border-color: var(--accent); background: rgba(39,174,96,0.06); }
.file-preview {
  display: flex; align-items: center; gap: 0.6rem;
  background: white; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.6rem 0.9rem;
  font-size: 0.85rem; margin-top: 0.5rem;
}
.file-preview .file-icon { font-size: 1.2rem; }
.file-preview .file-name { flex: 1; color: var(--text-dark); font-weight: 500; truncate: true; }
.file-preview .remove-file { color: #dc2626; cursor: pointer; font-size: 1rem; }

/* ─── Chat ───────────────────────────────────────────────── */
.chat-layout {
  display: flex; height: calc(100vh - 120px);
  border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow-md); border: 1px solid var(--border);
  background: white;
}
.chat-sidebar {
  width: 260px; border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  background: var(--bg-alt);
  flex-shrink: 0;
}
.chat-sidebar-header {
  padding: 1rem; font-weight: 700; font-size: 0.95rem;
  border-bottom: 1px solid var(--border);
  background: white;
}
.chat-sidebar-list { flex: 1; overflow-y: auto; }
.chat-user-item {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.8rem 1rem; cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.chat-user-item:hover { background: rgba(27,110,59,0.05); }
.chat-user-item.active { background: rgba(27,110,59,0.1); }
.chat-user-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 0.9rem; flex-shrink: 0;
}
.chat-user-info { flex: 1; min-width: 0; }
.chat-user-name { font-weight: 600; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-user-last { font-size: 0.75rem; color: var(--text-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-unread {
  background: #ef4444; color: white;
  border-radius: 99px; font-size: 0.7rem;
  padding: 0.1rem 0.45rem; font-weight: 700; flex-shrink: 0;
}

.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-main-header {
  padding: 0.9rem 1.2rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 0.8rem;
  background: white; font-weight: 600;
}
.chat-messages {
  flex: 1; overflow-y: auto; padding: 1rem;
  display: flex; flex-direction: column; gap: 0.7rem;
  background: var(--bg-alt);
}
.chat-msg {
  display: flex; gap: 0.6rem; max-width: 75%;
}
.chat-msg.mine { flex-direction: row-reverse; margin-left: auto; }
.chat-msg-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; flex-shrink: 0;
  color: white;
}
.chat-msg-avatar.admin { background: linear-gradient(135deg, var(--primary), var(--accent)); }
.chat-msg-avatar.guru  { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.chat-bubble {
  background: white;
  border-radius: 16px 16px 16px 4px;
  padding: 0.6rem 0.9rem;
  box-shadow: var(--shadow-sm);
  font-size: 0.88rem; max-width: 100%;
  border: 1px solid var(--border);
}
.chat-msg.mine .chat-bubble {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white; border-color: transparent;
  border-radius: 16px 16px 4px 16px;
}
.chat-msg-time {
  font-size: 0.7rem; color: var(--text-light);
  margin-top: 0.2rem; text-align: right;
}
.chat-msg.mine .chat-msg-time { text-align: left; }
.chat-input-wrap {
  padding: 0.8rem 1rem;
  border-top: 1px solid var(--border);
  display: flex; gap: 0.7rem;
  background: white;
}
.chat-input {
  flex: 1; padding: 0.65rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md); font-size: 0.9rem;
  outline: none; transition: border-color var(--transition);
}
.chat-input:focus { border-color: var(--primary); }

/* ─── Animations ─────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in-up { animation: fadeInUp 0.35s ease forwards; }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  
  
}

/* ─── Loading Spinner ────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Empty State ────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 3rem 1rem;
  color: var(--text-light);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state-title { font-size: 1rem; font-weight: 600; color: var(--text-mid); }
.empty-state-text  { font-size: 0.85rem; margin-top: 0.3rem; }

/* ─── Broadcast Banner ───────────────────────────────────── */
.broadcast-banner {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white; border-radius: var(--radius-md);
  padding: 0.9rem 1.2rem;
  display: flex; align-items: center; gap: 0.7rem;
  font-size: 0.88rem; font-weight: 500;
  margin-bottom: 1rem;
  animation: fadeInUp 0.3s ease;
}
.typing-indicator { padding: 0.5rem 1.5rem; display: flex; align-items: center; }
.typing-indicator span { display: inline-block; width: 6px; height: 6px; background-color: var(--text-light); border-radius: 50%; margin-right: 4px; animation: typing 1.4s infinite both; }
.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }
.status-dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid white; position: absolute; bottom: -2px; right: -2px; }
.status-dot.online { background-color: #2ecc71; }
.status-dot.offline { background-color: #bdc3c7; }
.chat-user-avatar { position: relative; }
.custom-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s ease-out;
}
.custom-modal {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  overflow: hidden;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.custom-modal-header {
  padding: 1.25rem 1.5rem;
  font-weight: 700;
  font-size: 1.125rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-dark);
}
.custom-modal-body {
  padding: 1.5rem;
  color: var(--text);
  line-height: 1.5;
}
.custom-modal-footer {
  padding: 1rem 1.5rem;
  background: var(--bg);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  border-top: 1px solid var(--border);
}
.chat-bubble.image-bubble {
  padding: 0.25rem;
  background: white;
  border: 1px solid var(--border);
}
.chat-msg.mine .chat-bubble.image-bubble {
  background: var(--primary);
  border-color: var(--primary);
}
/* Chat Advanced Interactions */
.chat-msg { position: relative; overflow: visible; touch-action: pan-y; transition: transform 0.2s cubic-bezier(0.1, 0.7, 0.1, 1); }
.chat-msg:hover .msg-menu-btn { opacity: 1; visibility: visible; }
.msg-menu-btn {
  position: absolute; top: 0; right: 0; width: 24px; height: 24px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.8) 50%, white);
  color: var(--text); border-radius: 0 8px 0 8px;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; transition: 0.2s; cursor: pointer; z-index: 2;
}
.chat-msg.mine .msg-menu-btn { background: linear-gradient(90deg, transparent, rgba(var(--primary-rgb),0.8) 50%, var(--primary)); color: white; }
.msg-menu {
  position: absolute; top: 24px; left: calc(100% - 24px); background: white;
  border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.15);
  z-index: 100; min-width: 150px; display: none; flex-direction: column; overflow: hidden;
}
.chat-msg.mine .msg-menu {
  left: auto; right: 0;
}
.msg-menu.active { display: flex; animation: fadeIn 0.15s ease-out; }
.msg-menu-item {
  padding: 0.75rem 1rem; display: flex; align-items: center; gap: 0.75rem;
  font-size: 0.85rem; color: var(--text-dark); cursor: pointer;
}
.msg-menu-item:hover { background: var(--bg); }
.msg-menu-item.danger { color: #e74c3c; }

/* Reply Preview (Input Area) */
.reply-preview-container {
  display: none; background: var(--bg); border-left: 4px solid var(--primary);
  padding: 0.5rem 1rem; position: relative; border-radius: 8px 8px 0 0;
  margin: 0 1rem; margin-top: -1rem; margin-bottom: 0.5rem;
}
.reply-preview-container.active { display: block; animation: slideUp 0.2s ease-out; }
.reply-preview-header { font-weight: 600; font-size: 0.8rem; color: var(--primary); margin-bottom: 0.25rem; display: flex; justify-content: space-between; }
.reply-preview-text { font-size: 0.85rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-preview-close { cursor: pointer; color: var(--text-light); }

/* Replied Message Inside Bubble */
.replied-msg-box {
  background: rgba(0,0,0,0.05); border-left: 3px solid var(--primary);
  padding: 0.25rem 0.5rem; border-radius: 4px; margin-bottom: 0.5rem;
  font-size: 0.8rem; cursor: pointer; opacity: 0.9;
}
.chat-msg.mine .replied-msg-box { background: rgba(255,255,255,0.2); border-left-color: white; color: white; }
.replied-msg-sender { font-weight: 600; margin-bottom: 0.1rem; }
.replied-msg-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Mobile Context Menu Bottom Sheet */
.mobile-context-menu {
  position: fixed; bottom: 0; left: 0; right: 0; background: white;
  border-radius: 20px 20px 0 0; padding: 1rem 0; box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  z-index: 10001; transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.mobile-context-menu.active { transform: translateY(0); }
.mobile-context-menu .msg-menu-item { padding: 1rem 1.5rem; font-size: 1rem; }

/* Deleted message styling */
.msg-deleted { color: var(--text-light); font-style: italic; display: flex; align-items: center; gap: 0.5rem; }
.chat-msg.mine .msg-deleted { color: rgba(255,255,255,0.8); }

/* Edited badge */
.msg-edited-badge { font-size: 0.65rem; color: var(--text-light); margin-left: 0.5rem; font-style: italic; }
.chat-msg.mine .msg-edited-badge { color: rgba(255,255,255,0.7); }

/* Pinned badge */
.msg-pinned-badge {
  position: absolute; top: -10px; right: -5px; width: 20px; height: 20px;
  background: #f1c40f; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: white; font-size: 10px; border: 2px solid white; z-index: 3;
}

.chat-msg:has(.attendance-widget) {
  order: 9999;
}

.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  right: 1rem;
  height: 65px;
  background-color: var(--primary);
  border-radius: 32px;
  z-index: 9999;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  padding: 0;
  align-items: center;
  justify-content: flex-start;
    gap: 0.5rem;
  overflow-x: auto;
}

.mobile-bottom-nav::-webkit-scrollbar {
  display: none;
}

.mobile-nav-item {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1rem;
  border-radius: 24px;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  flex-shrink: 0;
}

.mobile-nav-item svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
}



.mobile-nav-item.active {
  background-color: white;
  color: var(--primary);
}



@media (max-width: 768px) {
  .mobile-bottom-nav {
    display: flex;
  }
  .app-layout {
    padding-bottom: 90px; /* Space for the bottom nav */
  }
  .sidebar {
    display: none; /* fully hide sidebar on mobile to prevent swipe issues */
  }
}
@media (max-width: 768px) {
  .chat-input-area {
    bottom: 85px !important; /* sit above bottom nav */
    border-radius: 12px;
    margin: 0 0.5rem;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
  }
}
@media (max-width: 768px) {
  .card-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.8rem;
  }
  .card-header .flex {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 5px;
  }
  .card-header .flex::-webkit-scrollbar {
    display: none;
  }
  .card-title {
    white-space: nowrap;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  table th, table td {
    white-space: nowrap;
  }
}






.mobile-bottom-nav::after {
  content: '';
  flex: 0 0 1rem; /* Spacer to prevent rightmost item from touching the edge */
}
.mobile-bottom-nav::before {
  content: '';
  flex: 0 0 1rem; /* Spacer for the left edge */
}

.mobile-nav-item .nav-text {
  font-size: 0.85rem;
  font-weight: 600;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  white-space: nowrap;
  margin-left: 0;
}
.mobile-nav-item.active .nav-text {
  max-width: 100px;
  opacity: 1;
  margin-left: 8px;
}

/* WhatsApp Mobile Style Chat */
@media (max-width: 768px) {
  .chat-layout {
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    height: calc(100vh - 200px); /* Adjust based on mobile screen */
  }
  .chat-sidebar {
    display: flex !important;
    width: 100%;
    height: 100%;
    border-right: none;
    transition: transform 0.3s ease;
    flex-shrink: 0;
  }
  .chat-main {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    background: var(--bg);
    z-index: 10;
  }
  .chat-layout.chat-active .chat-sidebar {
    transform: translateX(-100%);
  }
  .chat-layout.chat-active .chat-main {
    transform: translateX(0);
  }
  .mobile-chat-back {
    display: flex !important;
    align-items: center;
    justify-content: center;
    margin-right: 0.5rem;
    cursor: pointer;
  }
}
.mobile-chat-back {
  display: none;
}
