/* ==================== GLOBAL MODAL FORM INPUTS & BUTTONS ==================== */

.form-input {
  background: rgba(15, 23, 42, 0.75) !important;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12)) !important;
  color: var(--text-main, #f8fafc) !important;
  border-radius: var(--radius-sm, 8px) !important;
  padding: 8px 12px !important;
  font-size: 13px !important;
  font-family: inherit !important;
  outline: none !important;
  box-sizing: border-box !important;
  transition: all 0.2s ease !important;
}

.form-input.has-icon-left {
  padding-left: 36px !important;
}

.form-input:focus {
  border-color: var(--primary, #6366f1) !important;
  background: rgba(15, 23, 42, 0.95) !important;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.35) !important;
}

.form-input::placeholder {
  color: var(--text-dim, #64748b) !important;
}

.icon-btn.btn-close-modal,
.btn-close-modal:not(.btn-secondary):not(.btn-cancel):not(button:has(span)) {
  width: 30px !important;
  height: 30px !important;
  border-radius: 8px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  color: var(--text-dim, #94a3b8) !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  flex-shrink: 0 !important;
}

.icon-btn.btn-close-modal:hover,
.btn-close-modal:not(.btn-secondary):not(.btn-cancel):not(button:has(span)):hover {
  background: rgba(239, 68, 68, 0.18) !important;
  border-color: rgba(239, 68, 68, 0.45) !important;
  color: #f87171 !important;
  transform: scale(1.05) !important;
}

/* ==================== UNIFIED MODAL FOOTER BUTTONS DESIGN SYSTEM ==================== */
.modal-footer {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 10px !important;
}

.modal-footer button,
.modal-footer .btn-secondary,
.modal-footer .btn-primary,
.modal-footer .btn-cancel,
.modal-footer .btn-danger,
.gdrive-footer-buttons button,
.gdrive-footer-buttons .btn-secondary,
.gdrive-footer-buttons .btn-primary,
.btn-secondary.btn-close-modal,
.btn-cancel.btn-close-modal {
  width: auto !important;
  min-width: 80px !important;
  height: 38px !important;
  min-height: 38px !important;
  padding: 0 18px !important;
  border-radius: 8px !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  gap: 8px !important;
  box-sizing: border-box !important;
  line-height: 1 !important;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.modal-footer .btn-secondary,
.modal-footer .btn-cancel,
.gdrive-footer-buttons .btn-secondary,
.btn-secondary.btn-close-modal,
.btn-cancel.btn-close-modal {
  color: var(--text-main, #f8fafc) !important;
  background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
}

.modal-footer .btn-secondary:hover,
.modal-footer .btn-cancel:hover,
.gdrive-footer-buttons .btn-secondary:hover,
.btn-secondary.btn-close-modal:hover,
.btn-cancel.btn-close-modal:hover {
  background: rgba(255, 255, 255, 0.12) !important;
  border-color: rgba(255, 255, 255, 0.25) !important;
  color: #fff !important;
  transform: translateY(-0.5px) !important;
}

.modal-footer .btn-primary,
.gdrive-footer-buttons .btn-primary {
  background: var(--gradient-primary, linear-gradient(135deg, #6366F1, #4F46E5)) !important;
  color: #fff !important;
  border: 1px solid rgba(255, 255, 255, 0.22) !important;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3) !important;
}

.modal-footer .btn-primary:hover,
.gdrive-footer-buttons .btn-primary:hover {
  background: linear-gradient(135deg, #4F46E5, #4338CA) !important;
  border-color: rgba(255, 255, 255, 0.35) !important;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.45) !important;
  transform: translateY(-0.5px) !important;
}

.modal-palette {
  max-width: 540px;
  background-color: var(--bg-modal);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-top: 1px solid var(--border-glass-specular);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 24px rgba(99, 102, 241, 0.18);
}

.palette-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.search-palette-icon {
  color: var(--text-muted);
  font-size: 14px;
}

.palette-header input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 13.5px;
  color: var(--text-main);
  font-family: var(--font-sans);
}

.palette-body {
  padding: 12px 16px;
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.palette-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.palette-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.palette-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

.session-items-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.session-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.session-list-item:hover {
  background: rgba(139, 92, 246, 0.1);
  border-color: rgba(139, 92, 246, 0.25);
}

.session-list-item.active {
  background: rgba(139, 92, 246, 0.15);
  border-color: var(--primary);
}

.session-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.session-item-title {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-item-meta {
  font-size: 10.5px;
  color: var(--text-dim);
  display: flex;
  gap: 8px;
}

.session-item-actions {
  display: flex;
  align-items: center;
  gap: 3px;
}

.btn-session-action {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 11px;
  opacity: 0.6;
}

.btn-session-action:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  opacity: 1;
}



/* ==================== MODAL STYLING ==================== */

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(4, 6, 12, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.15s ease-out;
}

.modal-overlay.hidden { display: none; }

.modal-card {
  background-color: var(--bg-modal);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-top: 1px solid var(--border-glass-specular);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 540px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.75), 0 0 24px rgba(99, 102, 241, 0.12);
}

.modal-card.modal-lg { max-width: 760px; }

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-bright);
}

.modal-body {
  padding: 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.form-control {
  background-color: var(--bg-input);
  border: 1px solid var(--border-input);
  border-top: 1px solid var(--border-glass-specular);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 7px 10px;
  font-size: 12.5px;
  outline: none;
  width: 100%;
  transition: all 0.2s ease;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
}

.inline-input { display: flex; gap: 6px; }

.doc-reader-body {
  font-size: 14px;
  line-height: 1.75;
  white-space: normal;
  background: var(--bg-surface, #1e1e1e);
  color: var(--text-main, #d4d4d4);
  padding: 24px 28px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  max-height: 68vh;
  overflow-y: auto;
}

.doc-reader-body h1, .doc-reader-body h2, .doc-reader-body h3, .doc-reader-body h4 {
  color: var(--text-bright, #ffffff);
  margin-top: 20px;
  margin-bottom: 10px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.doc-reader-body h1 {
  font-size: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

.doc-reader-body h2 {
  font-size: 17px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 6px;
}

.doc-reader-body h3 { font-size: 15px; }

.doc-reader-body p {
  margin: 0 0 14px 0;
}

.doc-reader-body blockquote {
  margin: 14px 0;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-left: 3px solid var(--primary, #0078D4);
  border-radius: 0 4px 4px 0;
  color: var(--text-secondary, #cccccc);
}

.doc-reader-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}

.doc-reader-body th, .doc-reader-body td {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  font-size: 13px;
}

.doc-reader-body th {
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
}

.doc-reader-body pre {
  background: #181818;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 14px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.doc-reader-body code:not(pre code) {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.citation-meta {
  font-size: 11.5px;
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  margin-bottom: 8px;
}

.citation-snippet {
  background: var(--bg-input);
  padding: 14px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  max-height: 380px;
  overflow-y: auto;
}

/* UTILITY */
.hidden { display: none !important; }
.mobile-only { display: none; }

@media (max-width: 768px) {
  .sidebar { position: fixed; left: -320px; transition: left 0.3s ease; }
  .sidebar.open { left: 0; }
  .mobile-only { display: flex; }
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.22); }

/* ATTACHMENT PREVIEW STRIP */
.attach-preview-strip {
  display: flex;
  gap: 8px;
  padding: 8px 0;
  overflow-x: auto;
  flex-wrap: wrap;
}

.attach-preview-item {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 10px 6px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
  max-width: 220px;
  transition: border-color 0.15s ease;
}

.attach-preview-item:hover {
  border-color: var(--primary);
}

.attach-preview-item .attach-thumb {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.attach-preview-item .attach-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--primary-rgb), 0.12);
  border-radius: 4px;
  color: var(--primary);
  font-size: 16px;
  flex-shrink: 0;
}

.attach-preview-item .attach-info {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.attach-preview-item .attach-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
  font-weight: 500;
  color: var(--text-main);
  font-size: 11px;
}

.attach-preview-item .attach-meta-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.attach-preview-item .attach-size {
  font-size: 10px;
  color: var(--text-dim);
}

.attach-preview-item .attach-tokens-badge {
  font-size: 9.5px;
  font-family: var(--font-mono, monospace);
  color: var(--accent-cyan, #38bdf8);
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 0px 4px;
  border-radius: 4px;
  white-space: nowrap;
}

.attach-preview-item .btn-remove-attach {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--accent-red, #ef4444);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.attach-preview-item:hover .btn-remove-attach {
  opacity: 1;
}

#btnAttachFile:hover {
  color: var(--primary);
}

/* Attachment images in chat messages */
.msg-attachment-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.msg-attachment-strip img {
  max-width: 260px;
  max-height: 180px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: all 0.2s ease;
  background: #181818;
  display: block;
}

.msg-attachment-strip img:hover {
  transform: scale(1.02);
  border-color: var(--accent-blue, #0078d4);
  box-shadow: 0 4px 14px rgba(0, 120, 212, 0.25);
}

.msg-attach-file {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: rgba(var(--primary-rgb), 0.08);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-dim);
}

/* ==================== IMAGE LIGHTBOX MODAL ==================== */
.modal-lightbox-card {
  max-width: 90vw;
  max-height: 90vh;
  width: auto;
  background: rgba(18, 18, 18, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

.lightbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: rgba(30, 30, 30, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  gap: 12px;
}

.lightbox-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.lightbox-icon {
  color: var(--accent-cyan, #38bdf8);
  font-size: 15px;
}

.lightbox-img-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}

.lightbox-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-lightbox-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-lightbox-action:hover {
  background: var(--accent-blue, #0078d4);
  border-color: var(--accent-blue, #0078d4);
  color: #ffffff;
}

.btn-lightbox-close {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-lightbox-close:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.4);
}

.lightbox-body {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d0d0d;
  overflow: auto;
  max-height: calc(90vh - 65px);
}

.lightbox-img {
  max-width: 100%;
  max-height: calc(85vh - 75px);
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}



/* ==================== AUTH & ACCESS KEY LOCK SCREEN ==================== */

.modal-auth-card {
  max-width: 440px;
  width: 92%;
  padding: 32px 28px;
  background: #141724;
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85), 0 0 35px rgba(139, 92, 246, 0.18);
  text-align: center;
  animation: authFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes authFadeIn {
  from { opacity: 0; transform: scale(0.94) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.auth-header {
  margin-bottom: 24px;
}

.auth-icon-circle {
  width: 58px;
  height: 58px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(6, 182, 212, 0.2));
  border: 1px solid rgba(139, 92, 246, 0.45);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--primary);
  box-shadow: 0 0 25px rgba(139, 92, 246, 0.25);
}

.auth-header h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
  letter-spacing: -0.3px;
}

.auth-header p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* GOOGLE GIS AUTH BUTTON WRAPPER */
.google-auth-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 12px 0 16px;
  width: 100%;
}

.google-signin-btn-box {
  min-height: 44px;
  display: flex;
  justify-content: center;
  width: 100%;
}

.btn-google-custom {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 12px 18px;
  background: #ffffff;
  color: #1f1f1f;
  font-weight: 600;
  font-size: 14px;
  font-family: var(--font-sans);
  border: 1px solid #dadce0;
  border-radius: 24px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
}

.btn-google-custom:hover {
  background: #f8f9fa;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  transform: translateY(-1px);
}

.google-icon-svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* AUTH DIVIDER */
.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 18px 0;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.auth-divider span {
  padding: 0 12px;
}

/* DEV MOCK FAST LOGIN BOX */
.dev-auth-box {
  background: rgba(15, 17, 26, 0.7);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 16px;
  text-align: left;
}

.dev-auth-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.dev-auth-input-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.select-dev-email {
  flex: 1;
  background: #0b0d14;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 12.5px;
  font-family: var(--font-sans);
  padding: 9px 10px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s ease;
  min-width: 0;
}

.select-dev-email:focus {
  border-color: var(--primary);
}

.btn-dev-fast-login {
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.btn-dev-fast-login:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

.auth-error-msg {
  font-size: 12.5px;
  color: #f87171;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  text-align: left;
  line-height: 1.4;
  margin-top: 10px;
}

.auth-footer-note {
  margin-top: 18px;
  font-size: 11.5px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* ==================== SIDEBAR USER PROFILE WIDGET ==================== */
.sidebar-user-section {
  padding: 10px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(12, 14, 22, 0.4);
}

.sidebar-user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: all 0.2s ease;
}

.sidebar-user-profile:hover {
  background: rgba(139, 92, 246, 0.08);
  border-color: rgba(139, 92, 246, 0.25);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--primary);
  flex-shrink: 0;
  background: #141724;
}

.user-info-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  text-align: left;
}

.user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-logout {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.btn-logout:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
}




/* ==================== DOCUMENT PREVIEW READER ==================== */

.doc-reader-body {
  padding: 20px 24px;
  max-height: 75vh;
  overflow-y: auto;
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.8;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-word;
  background: rgba(11, 13, 20, 0.95);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin: 16px 20px 20px;
}

/* CITATION FOCUS HIGHLIGHT IN FULL DOC (ANTIGRAVITY BLUE GLOW) */
.citation-in-doc-highlight {
  background: rgba(0, 120, 212, 0.22) !important;
  color: #FFFFFF !important;
  border: 1px solid rgba(0, 120, 212, 0.6) !important;
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  display: inline;
  box-shadow: 0 0 10px rgba(0, 120, 212, 0.25);
  animation: citationTargetPulse 2.5s infinite ease-in-out;
}

/* PREVIEW FIND IN-DOC MATCHES (ANTIGRAVITY FIND MATCH) */
.preview-find-match {
  background: rgba(187, 128, 9, 0.35) !important;
  color: #CCCCCC !important;
  padding: 1px 4px;
  border-radius: 2px;
  transition: all 0.15s ease;
}

.preview-find-match.active-match {
  background: #9E6A03 !important;
  color: #FFFFFF !important;
  font-weight: 600;
  outline: 1px solid #BB8009;
  border-radius: 2px;
}

@keyframes citationTargetPulse {
  0%, 100% {
    box-shadow: 0 0 6px rgba(0, 120, 212, 0.2);
    border-color: rgba(0, 120, 212, 0.4);
  }
  50% {
    box-shadow: 0 0 14px rgba(0, 120, 212, 0.45);
    border-color: #0078D4;
  }
}



/* ==================== DOCUMENT STUDIO EDITOR & AI REWRITER ==================== */

.modal-doc-editor {
  width: 840px;
  max-width: 96vw;
  height: 90vh;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  background: var(--bg-modal);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.doc-editor-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.doc-editor-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 14px 18px;
  min-height: 0;
  gap: 10px;
}

.editor-ai-toolbar {
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-toolbar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-copilot-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
}

.ai-preset-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

.ai-preset-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.ai-preset-chip:hover {
  background: rgba(139, 92, 246, 0.2);
  color: #fff;
  border-color: var(--primary);
}

/* IN-EDITOR FIND BAR */
.editor-find-bar {
  background: rgba(18, 20, 32, 0.95);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slashFadeIn 0.2s ease;
}

.editor-find-bar .find-icon {
  font-size: 12px;
  color: var(--text-dim);
}

.editor-find-bar input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 12.5px;
  font-family: var(--font-main);
  outline: none;
}

.find-counter-badge {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.btn-find-nav {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: 4px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-find-nav:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.ai-instruction-input-row {
  display: flex;
  gap: 8px;
}

.ai-instruction-input-row input {
  flex: 1;
  background: rgba(11, 13, 20, 0.85);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-main);
  font-size: 13px;
  outline: none;
}

.ai-instruction-input-row input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
}

.btn-run-rewrite {
  padding: 0 16px;
  white-space: nowrap;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* EDITOR TEXTAREA & SYNCHRONIZED BACKDROP */
.editor-textarea-wrapper {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 260px;
  display: flex;
  background: rgba(11, 13, 20, 0.95);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.editor-textarea-wrapper:focus-within {
  border-color: rgba(139, 92, 246, 0.5);
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.15);
}

.editor-highlight-backdrop {
  position: absolute;
  inset: 0;
  padding: 16px 18px;
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
  color: transparent;
  background: transparent;
  overflow-y: auto;
  pointer-events: none;
  user-select: none;
  border: 1px solid transparent;
  z-index: 1;
}

.doc-editor-textarea {
  position: relative;
  flex: 1;
  width: 100%;
  background: transparent !important;
  border: none;
  padding: 16px 18px;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.75;
  resize: none;
  outline: none;
  min-height: 260px;
  z-index: 2;
  caret-color: #fde68a;
}

/* IN-EDITOR FIND MATCHES (ANTIGRAVITY THEME) */
.editor-find-match {
  background: rgba(187, 128, 9, 0.35) !important;
  color: transparent !important;
  border-radius: 2px;
}

.editor-find-match.active-match {
  background: #9E6A03 !important;
  outline: 1px solid #BB8009;
  border-radius: 2px;
}

.doc-editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 4px;
}

.doc-editor-footer-left, .doc-editor-footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-gdrive-sync {
  background: rgba(66, 133, 244, 0.15);
  border: 1px solid rgba(66, 133, 244, 0.4);
  color: #93c5fd;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-gdrive-sync:hover {
  background: #2563eb;
  color: #fff;
  box-shadow: 0 0 14px rgba(37, 99, 235, 0.4);
}

.btn-gdrive-sync.synced {
  background: rgba(34, 197, 94, 0.2) !important;
  border-color: #22c55e !important;
  color: #86efac !important;
}

/* TUNING MODAL CONTAINER */


/* ==================== GLOBAL APP DIALOG MODAL (CONFIRM & PROMPT) ==================== */
.modal-dialog-card {
  max-width: 440px;
  background: rgba(20, 23, 34, 0.95);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8), 0 0 32px rgba(139, 92, 246, 0.12);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: modalPopIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPopIn {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.dialog-icon-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  background: rgba(139, 92, 246, 0.15);
  color: var(--primary);
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.dialog-icon-circle.danger {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.35);
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.2);
}

.dialog-icon-circle.warning {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.35);
}

.dialog-icon-circle.success {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.35);
}

.dialog-header-texts {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.dialog-header-texts h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
  margin: 0;
  line-height: 1.3;
}

.dialog-header-texts p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
  word-break: break-word;
}

.dialog-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dialog-input {
  background: rgba(15, 17, 26, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 10px 14px;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.dialog-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
}

.dialog-input-error {
  font-size: 11.5px;
  color: #ef4444;
}

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.dialog-actions button {
  min-width: 90px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.dialog-actions .btn-danger-confirm {
  background: #dc2626 !important;
  border-color: #ef4444 !important;
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.35);
}

.dialog-actions .btn-danger-confirm:hover {
  background: #b91c1c !important;
  border-color: #f87171 !important;
}

/* ==================== TOAST NOTIFICATIONS ==================== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 380px;
}

.toast-item {
  pointer-events: auto;
  background: rgba(22, 24, 34, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  font-size: 13px;
  color: var(--text-main);
  animation: toastSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: all 0.25s ease;
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

.toast-item.toast-hiding {
  opacity: 0;
  transform: translateX(40px) scale(0.9);
}

.toast-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.toast-item.toast-success {
  border-left: 3px solid #10b981;
}
.toast-item.toast-success .toast-icon { color: #10b981; }

.toast-item.toast-error {
  border-left: 3px solid #ef4444;
}
.toast-item.toast-error .toast-icon { color: #ef4444; }

.toast-item.toast-warning {
  border-left: 3px solid #f59e0b;
}
.toast-item.toast-warning .toast-icon { color: #f59e0b; }

.toast-item.toast-info {
  border-left: 3px solid var(--primary);
}
.toast-item.toast-info .toast-icon { color: var(--primary); }

.toast-message {
  flex: 1;
  line-height: 1.4;
  word-break: break-word;
}

.toast-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}

.toast-close:hover {
  color: var(--text-main);
}

/* ==================== ALL WORKSPACES MODAL STYLING ==================== */
.all-workspaces-scroll-list {
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ws-modal-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm, 8px);
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  box-sizing: border-box;
}

.ws-modal-item:hover {
  background: rgba(30, 41, 59, 0.85);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.ws-modal-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.ws-modal-item-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14.5px;
  flex-shrink: 0;
}

.ws-modal-item-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.ws-modal-item-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ws-modal-item-meta {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.ws-modal-item-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ws-modal-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 10px;
  flex-shrink: 0;
}

.ws-modal-action-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ws-modal-action-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-main);
}

.ws-modal-action-btn.btn-delete-ws:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

@media (max-width: 640px) {
  .modal-workspaces-manager {
    width: 94vw !important;
    max-width: 94vw !important;
    margin: 0 auto !important;
  }
  .ws-modal-item {
    padding: 8px 10px !important;
    gap: 8px !important;
    border-radius: 8px !important;
  }
  .ws-modal-item-left {
    gap: 9px !important;
  }
  .ws-modal-item-icon {
    width: 28px !important;
    height: 28px !important;
    font-size: 12px !important;
    border-radius: 6px !important;
  }
  .ws-modal-item-name {
    font-size: 12.5px !important;
    max-width: 140px !important;
  }
  .ws-modal-item-meta {
    font-size: 10px !important;
    gap: 4px !important;
  }
  .ws-modal-item-actions {
    gap: 4px !important;
    margin-left: 4px !important;
  }
  .ws-modal-action-btn {
    width: 26px !important;
    height: 26px !important;
    font-size: 10.5px !important;
    border-radius: 5px !important;
  }
  .ws-modal-action-btn.btn-open-ws {
    display: none !important; /* redundant on mobile since whole card opens workspace */
  }
}

/* ==================== DISKUSI 06: SYSTEM DIALOG Z-INDEX & MODAL POLISH ==================== */

/* Top-level Alert & Confirm Dialogs: Always on top of all modals */
#modalAppDialog {
  z-index: 100000 !important;
}

/* Create / Edit Project Modal: Obsidian Pro proportions */
#modalProjectEditor .modal-card,
.modal-project-editor {
  width: 450px !important;
  max-width: calc(100vw - 28px) !important;
  border-radius: 14px !important;
  border: 1px solid rgba(99, 102, 241, 0.3) !important;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.7), 0 0 24px rgba(99, 102, 241, 0.18) !important;
}

#modalProjectEditor .modal-header {
  padding: 16px 20px 14px !important;
}

#modalProjectEditor .modal-body {
  padding: 16px 20px 18px !important;
  gap: 16px !important;
}

#modalProjectEditor textarea#inputProjectDesc {
  min-height: 68px !important;
  resize: vertical !important;
}

#modalProjectEditor .modal-footer {
  padding: 14px 20px !important;
}

/* GDrive Picker Footer Button Vertical Centering & Mobile Actions */
.gdrive-modal-footer {
  padding: 12px 20px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  background: var(--bg-card) !important;
  box-sizing: border-box !important;
}

.gdrive-footer-buttons {
  display: inline-flex !important;
  align-items: center !important;
  gap: 10px !important;
}

.gdrive-footer-buttons button,
.gdrive-footer-buttons .btn-secondary,
.gdrive-footer-buttons #btnSubmitGDrivePicker,
#btnSubmitGDrivePicker {
  height: 38px !important;
  min-height: 38px !important;
  padding: 0 16px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 1 !important;
  font-size: 12.5px !important;
  font-weight: 600 !important;
  border-radius: var(--radius-sm, 6px) !important;
  cursor: pointer !important;
  box-sizing: border-box !important;
  gap: 6px !important;
  margin: 0 !important;
}

#btnSubmitGDrivePicker i {
  font-size: 13px !important;
  display: inline-block !important;
  line-height: 1 !important;
}

#btnSubmitGDrivePicker span {
  display: inline-block !important;
  line-height: 1 !important;
}

/* Mobile Modal Footer: Hide Cancel to prevent accidental taps, Full-Width Action Buttons */
@media (max-width: 768px) {
  .modal-footer {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
  }
  .modal-footer-actions {
    width: 100% !important;
    display: flex !important;
  }
  .modal-footer .btn-secondary,
  .modal-footer .btn-cancel {
    display: none !important;
  }
  .modal-footer .btn-primary,
  .modal-footer-actions .btn-primary {
    width: 100% !important;
    justify-content: center !important;
    height: 40px !important;
  }
  .gdrive-modal-footer {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    padding: 12px 16px max(12px, env(safe-area-inset-bottom)) !important;
  }
  .gdrive-selection-info {
    text-align: center !important;
  }
  .gdrive-footer-buttons {
    width: 100% !important;
  }
  .gdrive-footer-buttons .btn-secondary,
  .gdrive-footer-buttons .btn-cancel {
    display: none !important;
  }
  .gdrive-footer-buttons #btnSubmitGDrivePicker,
  .gdrive-footer-buttons .btn-primary {
    width: 100% !important;
    height: 40px !important;
    justify-content: center !important;
  }
}


