/* ═══════════════════════════════════════════════════════
   Akademik Hujjatlar Tizimi — v2 UI
   Sidebar + Dashboard layout (matches uploaded design)
   ═══════════════════════════════════════════════════════ */

:root {
  --primary: #1e3a8a;
  --primary-dark: #172554;
  --primary-light: #dbeafe;
  --primary-50: #eff6ff;
  --primary-hover: #1e40af;
  --accent-red: #dc2626;
  --accent-orange: #ea580c;
  --accent-teal: #0d9488;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --success: #0d9488;
  --success-light: #ccfbf1;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --orange: #ea580c;
  --purple: #a855f7;
  --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.04);
  --shadow: 0 1px 3px 0 rgba(0,0,0,0.06), 0 1px 2px 0 rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.06), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.03);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --transition: all 0.15s ease;
  --sidebar-w: 260px;
  --header-h: 64px;
}

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

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, "Helvetica Neue", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; font-size: inherit; background: none; border: none; cursor: pointer; }
img { display: block; max-width: 100%; }

/* ═══ Login page ═══ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  padding: 20px;
}

.login-container {
  display: flex;
  width: 100%;
  max-width: 900px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  min-height: 520px;
}

.login-left {
  flex: 1;
  padding: 50px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-left img {
  width: 200px !important;
  height: auto !important;
  max-width: 200px;
  object-fit: contain;
  margin-bottom: 24px;
}

.login-right {
  flex: 1;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.login-logo {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  border-radius: 14px;
  margin-bottom: 16px;
  font-size: 28px;
  box-shadow: 0 4px 12px rgba(37,99,235,0.25);
}

.login-title { font-size: 22px; font-weight: 600; margin-bottom: 6px; }
.login-subtitle { color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }

.login-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}
.login-options label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--text-muted);
}

.login-footer {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.login-illustration { max-width: 300px; width: 100%; height: auto; }

.password-wrap { position: relative; }
.password-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
  padding: 4px;
}

/* ═══ Forms ═══ */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 13px; font-weight: 500; color: var(--text); }

.form-input, .form-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  transition: var(--transition);
}
.form-input::placeholder { color: var(--text-light); }
.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

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

/* ═══ Buttons ═══ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: #f1f5f9; text-decoration: none; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: #f8fafc; }

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

.btn-icon {
  width: 32px; height: 32px;
  padding: 0;
  border-color: var(--border);
  background: transparent;
  color: var(--text-muted);
}
.btn-icon:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-lg { padding: 11px 18px; font-size: 15px; }
.btn-block { width: 100%; }

/* ═══ App layout ═══ */
.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 90;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  min-height: 80px;
}

.sidebar-brand .logo-img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar-brand .brand-info {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}
.sidebar-brand .brand-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-brand .brand-sub {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-date {
  padding: 8px 18px 10px;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-category {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 12px 12px 6px;
  margin-top: 4px;
}
.sidebar-category:first-child { margin-top: 0; }

.sidebar-nav .nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  position: relative;
  border-left: 3px solid transparent;
  padding-left: 10px;
}

.sidebar-nav .nav-item:hover {
  background: var(--primary-50);
  color: var(--primary);
  text-decoration: none;
}

.sidebar-nav .nav-item.active {
  background: var(--primary-50);
  color: var(--primary);
  border-left-color: var(--accent-red);
  font-weight: 600;
}

.sidebar-nav .nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg);
}
.sidebar-user-card .user-avatar {
  width: 36px;
  height: 36px;
  font-size: 14px;
  background: var(--primary);
  color: #fff;
}
.sidebar-user-card .user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.sidebar-user-card .user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-card .user-role-tag {
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-block;
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  width: fit-content;
}
.sidebar-user-card .user-role-tag.role-specialist { background: var(--success); }
.sidebar-user-card .user-role-tag.role-viewer { background: var(--accent-orange); }
.sidebar-user-card .user-role-tag.role-leadership { background: #be185d; }
.sidebar-user-card .user-role-tag.role-branch-admin { background: #7c3aed; }

.sidebar-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  width: 100%;
  font-family: inherit;
}
.sidebar-logout:hover { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }

/* Main content */
.main-wrap {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Topbar */
.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 80;
}

.topbar-search { flex: 1; max-width: 520px; position: relative; }
.topbar-search input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  font-size: 14px;
  transition: var(--transition);
}
.topbar-search input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
}
.topbar-search::before {
  content: "🔍";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  opacity: 0.5;
}

.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.topbar-bell {
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
}
.topbar-bell:hover { background: var(--bg); }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 6px 6px;
  border-radius: 999px;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid var(--border);
}
.topbar-user:hover { background: var(--bg); }

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

.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-meta .name { font-size: 13px; font-weight: 500; color: var(--text); }
.user-meta .role { font-size: 11px; color: var(--text-muted); }

/* Content */
.content { flex: 1; padding: 28px; }

.page-header { margin-bottom: 20px; }
.page-title { font-size: 22px; font-weight: 600; color: var(--text); }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.page-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
}

/* ═══ Stat cards ═══ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.stat-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--primary);
}
.stat-card.border-navy::before { background: var(--primary); }
.stat-card.border-orange::before { background: var(--accent-orange); }
.stat-card.border-teal::before { background: var(--accent-teal); }
.stat-card.border-red::before { background: var(--accent-red); }

.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card .stat-info { display: flex; flex-direction: column; gap: 4px; }
.stat-card .stat-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1.1; margin-top: 2px; }
.stat-card .stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ═══ Card container ═══ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-head .dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.dot-orange { background: var(--orange); }
.dot-blue { background: var(--primary); }

.card-body { padding: 0; }

.card-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.card-footer a { font-size: 13px; color: var(--primary); font-weight: 500; }

.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

/* ═══ Bar chart rows ═══ */
.bar-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 36px;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
}
.bar-row:last-child { border-bottom: none; }
.bar-row .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.bar-track {
  height: 8px;
  background: var(--primary-light);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.bar-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  border-radius: 999px;
  transition: width 0.4s ease;
}
.bar-fill.orange { background: var(--orange); }
.bar-fill.blue { background: var(--primary); }

.bar-count { text-align: right; font-weight: 600; color: var(--text); }

/* ═══ Tables ═══ */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  background: var(--surface);
}
.table th, .table td {
  padding: 11px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}
.table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border);
}
.table tbody tr:hover { background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: none; }

.para-badge {
  display: inline-flex;
  width: 28px; height: 28px;
  align-items: center; justify-content: center;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 50%;
  font-weight: 600;
  font-size: 12px;
}

.teacher-absent { color: #d97706; font-weight: 500; }
.teacher-substitute { color: var(--success); font-weight: 500; }

/* ═══ Folder grid cards ═══ */
.folder-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.folder-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}
.folder-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.folder-card.current {
  border-color: var(--primary);
  background: linear-gradient(135deg, var(--primary-50), var(--surface));
}

.folder-card .folder-icon {
  font-size: 36px;
  margin-bottom: 12px;
  display: inline-flex;
  color: var(--primary);
}

.folder-card .folder-name {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
  color: var(--text);
}

.folder-card .folder-meta { font-size: 13px; color: var(--text-muted); }

.current-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--primary);
  color: #fff;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
}

/* ═══ Breadcrumbs ═══ */
.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.breadcrumbs a {
  color: var(--primary);
  padding: 4px 8px;
  border-radius: 4px;
  transition: var(--transition);
}
.breadcrumbs a:hover { background: var(--primary-light); text-decoration: none; }
.breadcrumbs .separator { color: var(--text-light); }
.breadcrumbs .current { color: var(--text); font-weight: 500; padding: 4px 8px; }

/* ═══ File list ═══ */
.file-list { display: flex; flex-direction: column; }

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.1s ease;
}
.file-item:last-child { border-bottom: none; }
.file-item:hover { background: #f8fafc; }

.file-icon {
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.file-icon.folder { color: #eab308; }
.file-icon.pdf { color: #dc2626; }
.file-icon.doc { color: #2563eb; }
.file-icon.xls { color: #16a34a; }
.file-icon.ppt { color: #ea580c; }
.file-icon.img { color: #8b5cf6; }
.file-icon.file { color: var(--text-muted); }

.file-info { flex: 1; min-width: 0; }
.file-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-name:hover { color: var(--primary); }
.file-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
  margin-top: 2px;
}
.file-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* ═══ Toolbar ═══ */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar .spacer { flex: 1; }

/* ═══ Pill tabs ═══ */
.pill-tabs {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  gap: 2px;
  margin-bottom: 20px;
}
.pill-tabs button {
  flex: 1;
  padding: 10px 16px;
  border-radius: 7px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 14px;
  transition: var(--transition);
}
.pill-tabs button:hover { background: var(--bg); color: var(--text); }
.pill-tabs button.active { background: var(--primary); color: #fff; }

/* ═══ Filter bar ═══ */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.filter-bar label {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.filter-bar input, .filter-bar select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--surface);
}

/* ═══ Role badges ═══ */
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.role-admin { background: #fef3c7; color: #92400e; }
.role-specialist { background: var(--success-light); color: #166534; }
.role-viewer { background: #e0e7ff; color: #3730a3; }
.role-leadership { background: #fce7f3; color: #9f1239; }
.role-branch_admin { background: #ede9fe; color: #5b21b6; }

/* ═══ Modals ═══ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 10000;  /* v3.26.0: above Messenger (9001) and FAB (9000) */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.2s ease;
}
.modal.modal-lg { max-width: 720px; }
.modal.modal-xl { max-width: 1100px; height: 90vh; display: flex; flex-direction: column; }

/* v3.44.16: Library form modal — wider than 'lg' but not full-height like 'xl'.
   Perfect for forms with 12-20 fields in a 2-column grid. */
.modal.modal-form {
  max-width: 920px;
  border: 1px solid #cbd5e1;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 600; }

.modal-close {
  font-size: 22px;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 4px;
  transition: var(--transition);
  line-height: 1;
}
.modal-close:hover { background: var(--border); color: var(--text); }

.modal-body { padding: 20px; }
.modal.modal-xl .modal-body { flex: 1; padding: 0; overflow-y: auto; min-height: 0; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: #fafbfc;
}

/* ═══ Toast ═══ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  min-width: 260px;
  max-width: 400px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--primary);
  font-size: 14px;
  animation: slideInRight 0.2s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

/* ═══ Alerts ═══ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.alert-danger { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: var(--success-light); color: #166534; border: 1px solid #bbf7d0; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: var(--primary-light); color: #1e40af; border: 1px solid #bfdbfe; }

/* ═══ Spinner ═══ */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin: 40px auto;
}
.spinner-sm {
  width: 14px; height: 14px;
  border-width: 2px;
  margin: 0;
  display: inline-block;
  vertical-align: middle;
}

/* ═══ Empty state ═══ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; opacity: 0.6; }
.empty-state .title { font-size: 16px; font-weight: 500; color: var(--text); margin-bottom: 4px; }

/* ═══ Pagination ═══ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-muted);
}
.pagination-controls { display: flex; gap: 4px; }
.pagination button {
  min-width: 28px; height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  padding: 0 8px;
}
.pagination button:hover { background: var(--bg); color: var(--text); }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ═══ Misc ═══ */
.hidden { display: none !important; }
.preview-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: #f8fafc;
}

/* ═══ Animations ═══ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══ Responsive ═══ */
@media (max-width: 1400px) {
  .stats-row { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1100px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .folder-grid { grid-template-columns: repeat(3, 1fr); }
  .two-cols { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .content { padding: 16px; }
  .folder-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-row { grid-template-columns: 1fr; }
  .topbar-search { display: none; }
  .user-meta { display: none; }
  .login-container { flex-direction: column; }
  .login-right { display: none; }
}

/* ═══ Toggle Switch ═══ */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
  flex-shrink: 0;
}

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

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #cbd5e1;
  transition: 0.25s;
  border-radius: 26px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.25s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

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

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

/* ═══════════════════════════════════════════════════
   AI ASSISTANT (chat in bottom-right corner)
   ═══════════════════════════════════════════════════ */

.ai-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: white;
  border: none;
  font-size: 28px;
  cursor: grab;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
  z-index: 9000;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  touch-action: none;
}
.ai-fab.dragging {
  cursor: grabbing;
  transition: none;
  box-shadow: 0 16px 40px rgba(99, 102, 241, 0.6);
}

/* v3.25.0: Messenger FAB — placed BEFORE the AI fab (to its left when AI is visible) */
.msg-fab {
  position: fixed;
  bottom: 24px;
  right: 24px; /* default: same as AI; shifted via .has-ai-fab */
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2481cc 0%, #1e6fad 100%);
  color: white;
  border: none;
  font-size: 28px;
  cursor: grab;
  box-shadow: 0 8px 24px rgba(36, 129, 204, 0.4);
  z-index: 9000;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  touch-action: none;
}
.msg-fab.dragging {
  cursor: grabbing;
  transition: none;
  box-shadow: 0 16px 40px rgba(36, 129, 204, 0.6);
}
.msg-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 32px rgba(36, 129, 204, 0.55);
}
.msg-fab.hidden { display: none; }

/* When BOTH FABs are visible — only auto-shift if user hasn't manually positioned */
body.has-ai-fab .msg-fab:not(.user-positioned) { right: 100px; }

/* v3.35.0: AI mode buttons (Tezkor / LLM) */
.ai-mode-btn {
  padding: 4px 10px;
  border: 1px solid #cbd5e1;
  background: white;
  border-radius: 14px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  transition: all 0.15s;
}
.ai-mode-btn:hover { background: #f1f5f9; border-color: #94a3b8; }
.ai-mode-btn.active {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  border-color: transparent;
}

.msg-fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: white;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border: 2px solid white;
}
.msg-fab-badge.hidden { display: none; }

/* Messenger Modal/Window */
/* v3.36.0: Messenger Telegram-style theme variables (overridable per user theme) */
.msg-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 720px;
  max-width: calc(100vw - 48px);
  height: 600px;
  max-height: calc(100vh - 140px);
  background: var(--msg-bg, #ffffff);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  z-index: 9001;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 420px;
  min-height: 400px;
  --msg-primary: #2481cc;
  --msg-primary-dark: #1e6fad;
  --msg-bg: #ffffff;
  --msg-sidebar-bg: #f4f4f5;
  --msg-hover-bg: #ebebeb;
  --msg-active-bg: #2481cc;
  --msg-active-text: #ffffff;
  --msg-text: #1f2937;
  --msg-text-muted: #6b7280;
  --msg-border: #e5e7eb;
  --msg-bubble-mine: #effdde;
  --msg-bubble-other: #ffffff;
  --msg-chat-bg: #e7ebf0;
}

/* Theme: Telegram Blue (default) */
.msg-window.theme-tg-blue {
  --msg-primary: #2481cc;
  --msg-primary-dark: #1e6fad;
  --msg-active-bg: #2481cc;
  --msg-bubble-mine: #effdde;
  --msg-chat-bg: #e7ebf0;
}
/* Theme: Telegram Dark */
.msg-window.theme-tg-dark {
  --msg-primary: #5288c1;
  --msg-primary-dark: #3e6a9c;
  --msg-bg: #17212b;
  --msg-sidebar-bg: #17212b;
  --msg-hover-bg: #2b5278;
  --msg-active-bg: #2b5278;
  --msg-active-text: #ffffff;
  --msg-text: #ffffff;
  --msg-text-muted: #708499;
  --msg-border: #0f1620;
  --msg-bubble-mine: #2b5278;
  --msg-bubble-other: #182533;
  --msg-chat-bg: #0e1621;
}
/* Theme: Forest Green */
.msg-window.theme-forest {
  --msg-primary: #10b981;
  --msg-primary-dark: #047857;
  --msg-active-bg: #10b981;
  --msg-bubble-mine: #d1fae5;
  --msg-chat-bg: #ecfdf5;
}
/* Theme: Royal Purple */
.msg-window.theme-purple {
  --msg-primary: #8b5cf6;
  --msg-primary-dark: #6d28d9;
  --msg-active-bg: #8b5cf6;
  --msg-bubble-mine: #ede9fe;
  --msg-chat-bg: #f5f3ff;
}
/* Theme: Sunset Orange */
.msg-window.theme-sunset {
  --msg-primary: #f97316;
  --msg-primary-dark: #c2410c;
  --msg-active-bg: #f97316;
  --msg-bubble-mine: #ffedd5;
  --msg-chat-bg: #fff7ed;
}
/* Theme: Rose Pink */
.msg-window.theme-rose {
  --msg-primary: #f43f5e;
  --msg-primary-dark: #be123c;
  --msg-active-bg: #f43f5e;
  --msg-bubble-mine: #ffe4e6;
  --msg-chat-bg: #fff1f2;
}
.msg-window.hidden { display: none; }

/* v3.26.0: Resize handles */
.msg-resize-handle {
  position: absolute;
  background: transparent;
  z-index: 10;
}
.msg-resize-n { top: 0; left: 0; right: 0; height: 6px; cursor: ns-resize; }
.msg-resize-w { top: 0; left: 0; bottom: 0; width: 6px; cursor: ew-resize; }
.msg-resize-nw { top: 0; left: 0; width: 14px; height: 14px; cursor: nw-resize; z-index: 11; }
.msg-resize-ne { top: 0; right: 0; width: 14px; height: 14px; cursor: ne-resize; z-index: 11; }
.msg-resize-sw { bottom: 0; left: 0; width: 14px; height: 14px; cursor: sw-resize; z-index: 11; }
.msg-resize-nw::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 10px; height: 10px;
  border-top: 2px solid #94a3b8; border-left: 2px solid #94a3b8;
}
.msg-resize-ne::after {
  content: ''; position: absolute; top: 2px; right: 2px;
  width: 10px; height: 10px;
  border-top: 2px solid #94a3b8; border-right: 2px solid #94a3b8;
}
.msg-resize-sw::after {
  content: ''; position: absolute; bottom: 2px; left: 2px;
  width: 10px; height: 10px;
  border-bottom: 2px solid #94a3b8; border-left: 2px solid #94a3b8;
}

/* File/image/video previews in messages */
.msg-attachment {
  margin-top: 4px;
  max-width: 100%;
}
.msg-attachment-image {
  max-width: 300px;
  max-height: 300px;
  border-radius: 8px;
  cursor: pointer;
  display: block;
  background: #f1f5f9;
}
.msg-attachment-video {
  max-width: 320px;
  max-height: 320px;
  border-radius: 8px;
  background: #000;
}
.msg-attachment-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.15);
  border-radius: 8px;
  cursor: pointer;
  max-width: 320px;
  text-decoration: none;
  color: inherit;
}
.msg-message.other .msg-attachment-file {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
}
.msg-attachment-file:hover { opacity: 0.85; }
.msg-attachment-file-icon {
  font-size: 28px;
  flex-shrink: 0;
}
.msg-attachment-file-info { flex: 1; min-width: 0; }
.msg-attachment-file-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-attachment-file-size { font-size: 11px; opacity: 0.7; }

/* Attach button + preview area in input */
.msg-attach-btn {
  background: #e2e8f0;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.msg-attach-btn:hover { background: #cbd5e1; }

.msg-attach-menu {
  position: absolute;
  bottom: 50px;
  left: 12px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 200px;
  z-index: 20;
}
.msg-attach-menu button {
  background: transparent;
  border: none;
  text-align: left;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.msg-attach-menu button:hover { background: #f1f5f9; }

.msg-pending-attachment {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

/* Image lightbox */
.msg-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 11000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.msg-lightbox img { max-width: 90vw; max-height: 90vh; box-shadow: 0 0 60px rgba(255,255,255,0.1); }
.msg-lightbox.hidden { display: none; }

/* ═══════════════════════════════════════════════════
   v3.27.0: Telegram-like features
   ═══════════════════════════════════════════════════ */

/* User select item highlight */
.msg-user-item:hover, .msg-add-item:hover { background: #f1f5f9; }
.msg-user-item.selected, .msg-add-item.selected { background: #e0f2fe !important; }

/* Action menu (context menu on ⋯) */
.msg-action-menu {
  position: fixed;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  padding: 6px;
  min-width: 220px;
  z-index: 10500;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.msg-action-menu button {
  background: transparent;
  border: none;
  text-align: left;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-radius: 6px;
  color: #1e293b;
  white-space: nowrap;
}
.msg-action-menu button:hover { background: #f1f5f9; }
.msg-action-menu .msg-action-danger { color: #dc2626; }
.msg-action-menu .msg-action-danger:hover { background: #fee2e2; }

/* Message menu trigger (⋯) */
.msg-message-menu-trigger {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,0.1);
  border: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  color: inherit;
  opacity: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}
.msg-message:hover .msg-message-menu-trigger { opacity: 1; }
.msg-message-menu-trigger:hover { background: rgba(0,0,0,0.2); }

/* Reactions */
.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.msg-reaction {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.3);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  cursor: pointer;
  color: inherit;
}
.msg-message.other .msg-reaction {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
}
.msg-reaction.mine {
  background: #0ea5e9 !important;
  border-color: #0284c7 !important;
  color: white !important;
}
.msg-reaction:hover { transform: scale(1.05); }

/* Pin indicator */
.msg-pin-indicator { color: #f59e0b; font-size: 12px; }

/* Check (read receipt) */
.msg-check { color: rgba(255,255,255,0.7); font-weight: bold; }
.msg-message.other .msg-check { color: #94a3b8; }

/* Highlight (scroll-to) */
.msg-highlight {
  animation: msgHighlight 1.5s ease;
}
@keyframes msgHighlight {
  0% { background: #fef3c7; }
  50% { background: #fef3c7; }
  100% { background: transparent; }
}

/* Search hits */
.msg-message.msg-search-hit {
  outline: 2px solid #f59e0b;
  outline-offset: 2px;
}

/* Emoji picker */
.msg-emoji-picker {
  position: fixed;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  padding: 12px;
  z-index: 10600;
  width: 320px;
}
.msg-emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  max-height: 240px;
  overflow-y: auto;
}
.msg-emoji-btn {
  background: transparent;
  border: none;
  font-size: 20px;
  padding: 6px;
  cursor: pointer;
  border-radius: 6px;
  width: 100%;
}
.msg-emoji-btn:hover { background: #f1f5f9; transform: scale(1.2); }

/* Reaction quick-pick (smaller) */
.msg-emoji-picker.msg-emoji-reactions {
  width: auto;
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  max-width: 320px;
}
.msg-emoji-picker.msg-emoji-reactions .msg-emoji-btn {
  width: 36px;
  height: 36px;
  font-size: 22px;
}

/* Typing indicator in chat header */
.msg-typing-text {
  font-style: italic;
  color: #0ea5e9;
  font-size: 11px;
}
.msg-typing-dots::after {
  content: '...';
  animation: typingDots 1.2s infinite;
}
@keyframes typingDots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

/* Online indicator */
.msg-online-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  margin-right: 4px;
}
.msg-offline-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #cbd5e1;
  margin-right: 4px;
}

/* Pinned messages bar */
.msg-pinned-bar {
  background: #fef3c7;
  border-left: 4px solid #f59e0b;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.msg-pinned-bar:hover { background: #fde68a; }

/* Search bar */
.msg-search-bar {
  padding: 8px 12px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  gap: 6px;
}
.msg-search-bar input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
}
.msg-header {
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--msg-primary, #2481cc) 0%, var(--msg-primary-dark, #1e6fad) 100%);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.msg-header h3 { margin: 0; font-size: 16px; font-weight: 600; }
.msg-header-actions { display: flex; gap: 8px; }
.msg-header-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
}
.msg-header-btn:hover { background: rgba(255,255,255,0.3); }
.msg-header-btn:active { transform: scale(0.95); }
.msg-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
  background: var(--msg-bg);
}
.msg-sidebar {
  width: 260px;
  border-right: 1px solid var(--msg-border, #e2e8f0);
  display: flex;
  flex-direction: column;
  background: var(--msg-sidebar-bg, #f4f4f5);
  flex-shrink: 0;
  color: var(--msg-text);
}
.msg-sidebar-search {
  padding: 10px;
  border-bottom: 1px solid var(--msg-border, #e2e8f0);
  display: flex;
  gap: 6px;
}
.msg-sidebar-search input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
}
.msg-sidebar-search button {
  padding: 6px 10px;
  background: #0ea5e9;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.msg-chat-list {
  flex: 1;
  overflow-y: auto;
}
.msg-chat-item {
  padding: 10px 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
}
.msg-chat-item:hover { background: #e0f2fe; }
.msg-chat-item.active { background: #bae6fd; }
.msg-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  flex-shrink: 0;
}
.msg-chat-avatar.group { background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%); }
.msg-chat-info { flex: 1; min-width: 0; }
.msg-chat-name {
  font-weight: 600;
  font-size: 13px;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-chat-preview {
  font-size: 11px;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-chat-unread {
  background: #0ea5e9;
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}
.msg-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.msg-main-header {
  padding: 10px 14px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: white;
  flex-shrink: 0;
}
.msg-main-header-title { font-weight: 600; font-size: 14px; color: #1e293b; }
.msg-main-header-sub { font-size: 11px; color: #64748b; }
.msg-main-actions { display: flex; gap: 6px; }
.msg-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.msg-message {
  max-width: 75%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
  position: relative;
  word-wrap: break-word;
}
.msg-message.own {
  background: #0ea5e9;
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.msg-message.other {
  background: white;
  color: #1e293b;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  border: 1px solid #e2e8f0;
}
.msg-message.system {
  background: transparent;
  color: #64748b;
  align-self: center;
  font-size: 11px;
  font-style: italic;
}
.msg-message-sender {
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 2px;
  color: #6366f1;
}
.msg-message.own .msg-message-sender { color: #e0f2fe; }
.msg-message-reply {
  border-left: 3px solid rgba(255,255,255,0.5);
  padding-left: 6px;
  font-size: 11px;
  opacity: 0.85;
  margin-bottom: 4px;
}
.msg-message.other .msg-message-reply { border-left-color: #6366f1; }
.msg-message-meta {
  font-size: 10px;
  opacity: 0.7;
  margin-top: 4px;
  display: flex;
  gap: 6px;
}
.msg-message-actions {
  position: absolute;
  top: 2px;
  right: 4px;
  display: none;
  gap: 4px;
}
.msg-message:hover .msg-message-actions { display: flex; }
.msg-message-action-btn {
  background: rgba(0,0,0,0.1);
  border: none;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 10px;
  color: inherit;
}
.msg-input-area {
  padding: 10px 12px;
  border-top: 1px solid #e2e8f0;
  background: white;
  flex-shrink: 0;
}
.msg-reply-preview {
  background: #e0f2fe;
  border-left: 3px solid #0ea5e9;
  padding: 6px 10px;
  font-size: 11px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.msg-input-row { display: flex; gap: 8px; }
.msg-input-row textarea {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  resize: none;
  font-family: inherit;
  font-size: 13px;
  min-height: 38px;
  max-height: 120px;
}
.msg-input-row button {
  padding: 8px 16px;
  background: #0ea5e9;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}
.msg-input-row button:hover { background: #0284c7; }
.msg-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  text-align: center;
  padding: 40px 20px;
}
.msg-empty .icon { font-size: 64px; margin-bottom: 12px; opacity: 0.4; }
.msg-empty .title { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.msg-empty .hint { font-size: 12px; }

/* Mobile fullscreen */
@media (max-width: 768px) {
  .msg-window {
    width: 100vw;
    height: 100vh;
    bottom: 0;
    right: 0;
    border-radius: 0;
    max-width: none;
    max-height: none;
  }
  .msg-sidebar { width: 100%; }
  .msg-main { display: none; }
  .msg-window.mobile-chat-active .msg-sidebar { display: none; }
  .msg-window.mobile-chat-active .msg-main { display: flex; }
}

.ai-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 32px rgba(99, 102, 241, 0.55);
}

.ai-fab.hidden {
  display: none;
}

.ai-chat-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 400px;
  height: 600px;
  max-height: calc(100vh - 140px);
  background: white;
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25);
  z-index: 9001;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
}

.ai-chat-window.hidden {
  display: none;
}

.ai-chat-header {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: white;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-chat-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-chat-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-chat-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.ai-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f9fafb;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-message {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
}

.ai-message.user {
  align-self: flex-end;
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.ai-message.bot {
  align-self: flex-start;
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.ai-message.bot.loading {
  font-style: italic;
  color: var(--text-light);
}

.ai-result-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 8px;
  font-size: 13px;
}

.ai-result-card .file-name {
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.ai-result-card .file-path {
  font-size: 11px;
  color: var(--text-light);
  margin-bottom: 6px;
  word-break: break-all;
}

.ai-result-card .file-snippet {
  font-size: 12px;
  color: #4b5563;
  background: #f9fafb;
  padding: 4px 6px;
  border-radius: 4px;
  margin-bottom: 6px;
  font-style: italic;
}

.ai-result-card .file-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.ai-result-card .file-actions a {
  font-size: 12px;
  padding: 4px 8px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 4px;
  text-decoration: none;
  font-weight: 500;
}

.ai-result-card .file-actions a:hover {
  background: var(--primary);
  color: white;
}

.ai-suggestion-card {
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 6px;
  font-size: 13px;
}

.ai-suggestion-card .sugg-name {
  font-weight: 600;
  color: #92400e;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-suggestion-card .sugg-phone {
  font-size: 12px;
  color: #78350f;
  margin-top: 4px;
}

.ai-suggestion-card .sugg-phone a {
  color: #1e40af;
  text-decoration: none;
}

.ai-chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
  background: white;
}

.ai-chat-input-row input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.ai-chat-input-row input:focus {
  border-color: var(--primary);
}

.ai-chat-input-row button {
  padding: 10px 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.ai-chat-input-row button:hover {
  background: var(--primary-dark);
}

.ai-chat-input-row button:disabled {
  background: var(--text-light);
  cursor: not-allowed;
}

.ai-empty-state {
  text-align: center;
  color: var(--text-light);
  font-size: 13px;
  padding: 40px 20px;
}

.ai-empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

@media (max-width: 480px) {
  .ai-chat-window {
    width: calc(100vw - 32px);
    right: 16px;
    bottom: 90px;
    height: 70vh;
  }
  .ai-fab {
    right: 16px;
    bottom: 16px;
  }
}

/* AI v3.0.0 — additions for streaming + sources */
.ai-cursor {
  display: inline-block;
  animation: blink 1s steps(2, start) infinite;
  color: var(--primary);
  font-weight: bold;
}
@keyframes blink {
  to { visibility: hidden; }
}

.ai-message.bot p {
  margin: 0 0 8px 0;
  line-height: 1.5;
}
.ai-message.bot p:last-child {
  margin-bottom: 0;
}
.ai-message.bot strong {
  color: var(--text);
  font-weight: 600;
}
.ai-message.bot em {
  font-style: italic;
}

.ai-answer-text {
  font-size: 14px;
  line-height: 1.5;
}

.ai-sources-host:empty {
  display: none;
}

#aiReindexBtn {
  background: rgba(255, 255, 255, 0.15);
  font-size: 14px;
}
#aiReindexBtn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ═══════════════════════════════════════════════════
   v3.5.0: Data tables — clean, bordered, professional
   ═══════════════════════════════════════════════════ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: white;
}
.data-table thead th {
  background: #f9fafb;
  color: #374151;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 2px solid #e5e7eb;
}
.data-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}
.data-table tbody tr:hover {
  background: #f9fafb;
}
.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* Bordered variant — every cell has visible borders */
.data-table-bordered {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
}
.data-table-bordered thead th,
.data-table-bordered tbody td {
  border-right: 1px solid #f3f4f6;
}
.data-table-bordered thead th:last-child,
.data-table-bordered tbody td:last-child {
  border-right: none;
}
.data-table-bordered thead th {
  border-bottom: 2px solid #d1d5db;
}
.data-table-bordered tbody td {
  border-bottom: 1px solid #f3f4f6;
}
.data-table-bordered tbody tr:last-child td {
  border-bottom: none;
}

/* ═══════════════════════════════════════════════════
   v3.28.0: Settings, PIN, Dialogs, Preview, Sidebar
   ═══════════════════════════════════════════════════ */

/* Sidebar collapse */
.msg-window.msg-sidebar-collapsed .msg-sidebar {
  display: none;
}

/* PIN Lock screen */
.msg-pin-lock {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 30px;
  text-align: center;
  background: #f8fafc;
}
.msg-pin-lock-icon {
  font-size: 64px;
  margin-bottom: 16px;
}
.msg-pin-lock-title {
  font-size: 18px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 8px;
}
.msg-pin-lock-hint {
  font-size: 13px;
  color: #64748b;
  margin-bottom: 24px;
}
.msg-pin-input {
  width: 240px;
  padding: 14px 18px;
  font-size: 24px;
  text-align: center;
  letter-spacing: 8px;
  border: 2px solid #cbd5e1;
  border-radius: 12px;
  outline: none;
  font-family: monospace;
}
.msg-pin-input:focus { border-color: #0ea5e9; }
.msg-pin-error { margin-top: 10px; font-size: 13px; color: #dc2626; min-height: 18px; }

/* In-window dialogs (overlay inside messenger) */
.msg-dialog-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}
.msg-dialog {
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  max-width: 450px;
  width: 100%;
  max-height: 90%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.2s ease;
}
.msg-dialog-header {
  padding: 14px 18px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
}
.msg-dialog-title { font-size: 15px; font-weight: 600; color: #1e293b; }
.msg-dialog-close {
  background: transparent;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #64748b;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}
.msg-dialog-close:hover { background: #e2e8f0; color: #1e293b; }
.msg-dialog-body { padding: 18px; overflow-y: auto; flex: 1; }
.msg-dialog-footer {
  padding: 12px 18px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: #f8fafc;
}

/* Settings rows */
.msg-setting-row {
  padding: 14px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid #f1f5f9;
}
.msg-setting-row:last-child { border-bottom: none; }
.msg-setting-info { flex: 1; min-width: 0; }
.msg-setting-title {
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 4px;
}
.msg-setting-hint {
  font-size: 11px;
  color: #64748b;
  line-height: 1.4;
}

/* iOS-style switch */
.msg-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.msg-switch.disabled { opacity: 0.4; cursor: not-allowed; }
.msg-switch input { opacity: 0; width: 0; height: 0; }
.msg-switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #cbd5e1;
  transition: 0.2s;
  border-radius: 24px;
}
.msg-switch-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.2s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.msg-switch input:checked + .msg-switch-slider { background-color: #0ea5e9; }
.msg-switch input:checked + .msg-switch-slider:before { transform: translateX(20px); }
.msg-switch.disabled .msg-switch-slider { cursor: not-allowed; }
.msg-switch.disabled .msg-switch-slider,
.msg-switch.disabled input { pointer-events: none; }

/* Read receipt double-check */
.msg-check-read {
  cursor: pointer;
  color: #67e8f9 !important;
  font-weight: bold;
}
.msg-message.other .msg-check-read { color: #0ea5e9 !important; }
.msg-check-read:hover { text-decoration: underline; }

/* Attachment action buttons */
.msg-attachment-image-wrap, .msg-attachment-video-wrap {
  position: relative;
  display: inline-block;
  max-width: 100%;
}
.msg-attachment-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}
.msg-attachment-image-wrap:hover .msg-attachment-actions,
.msg-attachment-video-wrap:hover .msg-attachment-actions {
  opacity: 1;
}
.msg-attach-action-btn {
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}
.msg-attach-action-btn:hover { background: rgba(0,0,0,0.85); }
.msg-attachment-file .msg-attach-action-btn {
  background: #0ea5e9;
  flex-shrink: 0;
}
.msg-attachment-file .msg-attach-action-btn:hover { background: #0284c7; }

/* Preview overlay (Telegram-style fullscreen) */
.msg-preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(6px);
  z-index: 11500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
.msg-preview-container {
  background: white;
  border-radius: 12px;
  max-width: 1100px;
  width: 100%;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 80px rgba(0,0,0,0.5);
}
.msg-preview-header {
  padding: 12px 18px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
  flex-shrink: 0;
}
.msg-preview-title { flex: 1; min-width: 0; }
.msg-preview-actions { display: flex; gap: 8px; align-items: center; }
.msg-preview-body {
  padding: 20px;
  overflow: auto;
  flex: 1;
  background: #1e293b;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

/* ═══════════════════════════════════════════════════
   v3.39.0: TIU Dashboard — Statistical Panel
   ═══════════════════════════════════════════════════ */
.tiu-dash { padding: 4px; }

.tiu-dash-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

/* Stat cards grid */
.tiu-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.tiu-card {
  background: #fff;
  border-radius: 14px;
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
  transition: all 0.25s ease;
  opacity: 0;
  animation: tiuCardIn 0.5s ease forwards;
}

.tiu-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
}

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

.tiu-card-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
}

.tiu-card-body { flex: 1; min-width: 0; }

.tiu-card-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 2px;
  font-feature-settings: "tnum";
}

.tiu-card-label {
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Skeleton */
.tiu-card-skel {
  background: #fff;
  border-radius: 14px;
  padding: 18px;
  height: 88px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.skel-bar {
  height: 14px;
  background: linear-gradient(90deg, #f1f5f9, #e2e8f0, #f1f5f9);
  background-size: 200% 100%;
  border-radius: 4px;
  margin-bottom: 10px;
  animation: skelShine 1.5s infinite;
}
.skel-bar.short { width: 60%; }

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

/* Charts grid */
.tiu-charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 14px;
}

.tiu-chart-box {
  background: #fff;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
  transition: box-shadow 0.2s ease;
}

.tiu-chart-box:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.07);
}

.tiu-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #f1f5f9;
}

.tiu-chart-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
}

.tiu-chip {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  color: #1e40af;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.tiu-chart-wrap {
  position: relative;
  height: 280px;
  width: 100%;
}

/* Responsive */
@media (max-width: 768px) {
  .tiu-cards { grid-template-columns: repeat(2, 1fr); }
  .tiu-card-value { font-size: 22px; }
  .tiu-card-icon { width: 44px; height: 44px; font-size: 22px; }
  .tiu-chart-wrap { height: 240px; }
  .tiu-charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .tiu-cards { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════
   v3.44.16: Library form modal — sections, spacing, contrast
   ═══════════════════════════════════════════════════════════ */

/* Make modal overlay slightly darker so the form stands out on light backgrounds */
.modal-overlay {
  background: rgba(15, 23, 42, 0.6);
}

/* Library form sections */
.lib-form-section {
  margin-bottom: 22px;
  padding: 18px 20px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}
.lib-form-section:last-of-type { margin-bottom: 0; }

.lib-form-section-title {
  font-size: 14px;
  font-weight: 700;
  color: #1e40af;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid #e0e7ff;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 2-column grid for form fields */
.lib-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.lib-form-field {
  display: flex;
  flex-direction: column;
}

/* Full-width field spans both columns */
.lib-form-field-wide {
  grid-column: 1 / -1;
}

/* Required marker */
.lib-req {
  color: #ef4444;
  font-weight: 700;
  margin-left: 2px;
}

/* Currently attached file label */
.lib-file-current {
  font-size: 12.5px;
  color: #0f766e;
  margin-top: 6px;
  padding: 4px 10px;
  background: #ccfbf1;
  border-radius: 6px;
  display: inline-block;
  font-weight: 500;
}

/* Upload button */
.lib-upload-btn {
  margin-top: 8px;
  align-self: flex-start;
}

/* Info banner (when book not saved yet) */
.lib-form-info {
  padding: 14px 16px;
  background: #eff6ff;
  border-left: 4px solid #3b82f6;
  border-radius: 8px;
  font-size: 13.5px;
  color: #1e40af;
  font-weight: 500;
  margin-bottom: 4px;
}

/* Stronger label color inside form sections */
.lib-form-field .form-label {
  color: #334155;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
}

/* Slightly stronger input borders for visibility on white modal */
.lib-form-field .form-input {
  border: 1.5px solid #cbd5e1;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.lib-form-field .form-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
  outline: none;
}

/* Responsive: collapse to single column on narrow screens */
@media (max-width: 720px) {
  .lib-form-grid { grid-template-columns: 1fr; }
  .lib-form-section { padding: 14px 16px; }
}
