/* ==========================================================================
   Gemo AI Assistant for Infinity Sheets - Google Gemini in Sheets Style
   ========================================================================== */

/* Main Side Panel (Image 1 - Google Gemini in Sheets) */
.sheets-gemo-sidebar {
  width: 380px;
  min-width: 380px;
  max-width: 440px;
  background: #ffffff;
  border-left: 1px solid #e0e2e6;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  height: 100vh;
  z-index: 99999;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.08);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #1f1f1f;
  box-sizing: border-box;
}

.sheets-gemo-sidebar.collapsed {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}

/* Sidebar Header */
.sheets-gemo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 12px 16px;
  border-bottom: 1px solid #f1f3f4;
  height: 52px;
  box-sizing: border-box;
}

.sheets-gemo-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sheets-gemo-header-menu-btn {
  background: none;
  border: none;
  color: #444746;
  font-size: 1.05rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s;
}

.sheets-gemo-header-menu-btn:hover {
  background-color: #f1f3f4;
}

.sheets-gemo-header-title {
  font-size: 1.08rem;
  font-weight: 500;
  color: #1f1f1f;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  letter-spacing: -0.2px;
}

.sheets-gemo-header-credits {
  font-size: 0.74rem;
  font-weight: 600;
  color: #0070ba;
  background: rgba(0, 112, 186, 0.08);
  border: 1px solid rgba(0, 112, 186, 0.18);
  border-radius: 12px;
  padding: 2px 8px;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.sheets-gemo-header-credits:hover {
  background: rgba(0, 112, 186, 0.16);
}

.sheets-gemo-header-right {
  display: flex;
  align-items: center;
  gap: 2px;
}

.sheets-gemo-icon-btn {
  background: none;
  border: none;
  color: #444746;
  font-size: 0.95rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s;
}

.sheets-gemo-icon-btn:hover {
  background-color: #f1f3f4;
  color: #1f1f1f;
}

/* Sidebar Body */
.sheets-gemo-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px 16px 20px;
  display: flex;
  flex-direction: column;
}

/* Hero Title with Gradient Text ("Type + to reference sources") */
.sheets-gemo-hero-container {
  margin-top: auto;
  margin-bottom: 24px;
}

.sheets-gemo-hero-title {
  font-size: 1.48rem;
  font-weight: 600;
  line-height: 1.35;
  color: #1a73e8;
  margin: 0 0 20px 0;
  letter-spacing: -0.3px;
  background: linear-gradient(135deg, #1a73e8 0%, #7c3aed 70%, #9333ea 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Prompt Suggestion Items (Image 1) */
.sheets-gemo-suggestions-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.sheets-gemo-suggestion-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: none;
  border: none;
  padding: 6px 4px;
  font-size: 0.88rem;
  font-weight: 500;
  color: #1f1f1f;
  cursor: pointer;
  text-align: left;
  border-radius: 8px;
  transition: background-color 0.15s ease, color 0.15s ease;
  width: 100%;
}

.sheets-gemo-suggestion-item:hover {
  background-color: #f8fafd;
  color: #1a73e8;
}

.sheets-gemo-suggestion-item .suggestion-icon {
  color: #747775;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.sheets-gemo-suggestion-item:hover .suggestion-icon {
  color: #1a73e8;
}

.sheets-gemo-view-all-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  padding: 6px 4px;
  font-size: 0.84rem;
  font-weight: 600;
  color: #444746;
  cursor: pointer;
  text-align: left;
  margin-top: 4px;
  border-radius: 6px;
  transition: color 0.15s;
}

.sheets-gemo-view-all-btn:hover {
  color: #1a73e8;
}

/* Chat Stream */
.sheets-gemo-chat-stream {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sheets-gemo-msg {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
  line-height: 1.5;
  animation: gemoFadeIn 0.2s ease-out;
}

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

.sheets-gemo-msg.user {
  align-self: flex-end;
  background: #f0f4f9;
  color: #1f1f1f;
  padding: 10px 14px;
  border-radius: 18px 18px 4px 18px;
  max-width: 86%;
  font-weight: 500;
  word-break: break-word;
}

.sheets-gemo-msg.ai {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px 16px;
  width: 100%;
  box-sizing: border-box;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.sheets-gemo-msg.ai .gemo-msg-content {
  color: #1f1f1f;
  overflow-x: auto;
  line-height: 1.5;
  word-break: break-word;
}

/* Polished Table Appearance inside Gemo Sidebar */
.sheets-gemo-rendered-table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 10px 0 6px 0;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.sheets-gemo-rendered-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  text-align: left;
}

.sheets-gemo-rendered-table th {
  background: #f8fafc;
  color: #334155;
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 2px solid #cbd5e1;
  white-space: nowrap;
}

.sheets-gemo-rendered-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
  vertical-align: middle;
}

.sheets-gemo-rendered-table tr:last-child td {
  border-bottom: none;
}

.sheets-gemo-rendered-table tr:hover td {
  background: #f8fafd;
}

.sheets-gemo-rendered-table td.is-formula {
  font-family: monospace;
  color: #0284c7;
  font-weight: 500;
  background: rgba(2, 132, 199, 0.04);
}

.sheets-gemo-rendered-table td.is-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.sheets-gemo-msg.ai pre {
  background: #f8fafc;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  font-family: monospace;
  font-size: 0.82rem;
  overflow-x: auto;
  white-space: pre-wrap;
}

/* History Flyout Drawer / Modal */
.sheets-gemo-history-drawer {
  position: absolute;
  top: 52px;
  left: 0;
  right: 0;
  bottom: 0;
  background: #ffffff;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  animation: gemoHistorySlide 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  pointer-events: auto;
}

@keyframes gemoHistorySlide {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.sheets-gemo-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #f1f3f4;
  background: #f8fafc;
}

.sheets-gemo-history-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sheets-gemo-history-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sheets-gemo-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sheets-gemo-history-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  width: 100%;
  box-sizing: border-box;
}

.sheets-gemo-history-item:hover {
  background: #f0f7ff;
  border-color: #93c5fd;
  transform: translateY(-1px);
}

.sheets-gemo-history-item-icon {
  color: #107c41;
  font-size: 1rem;
  margin-top: 2px;
  flex-shrink: 0;
}

.sheets-gemo-history-item-content {
  flex: 1;
  overflow: hidden;
}

.sheets-gemo-history-item-prompt {
  font-size: 0.86rem;
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.sheets-gemo-history-item-meta {
  font-size: 0.72rem;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sheets-gemo-history-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  color: #64748b;
  gap: 10px;
  font-size: 0.88rem;
}

/* Dark mode overrides for History & Table */
[data-theme="dark"] .sheets-gemo-rendered-table-wrap,
[data-theme="dark"] .sheets-gemo-rendered-table {
  background: #0f172a;
  border-color: #334155;
}

[data-theme="dark"] .sheets-gemo-rendered-table th {
  background: #1e293b;
  color: #f1f5f9;
  border-bottom-color: #475569;
}

[data-theme="dark"] .sheets-gemo-rendered-table td {
  color: #e2e8f0;
  border-bottom-color: #1e293b;
}

[data-theme="dark"] .sheets-gemo-rendered-table tr:hover td {
  background: #1e293b;
}

[data-theme="dark"] .sheets-gemo-rendered-table td.is-formula {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.08);
}

[data-theme="dark"] .sheets-gemo-history-drawer {
  background: #1e293b;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

[data-theme="dark"] .sheets-gemo-history-header {
  background: #0f172a;
  border-bottom-color: #334155;
}

[data-theme="dark"] .sheets-gemo-history-title {
  color: #f8fafc;
}

[data-theme="dark"] .sheets-gemo-history-item {
  background: #0f172a;
  border-color: #334155;
}

[data-theme="dark"] .sheets-gemo-history-item:hover {
  background: #1e293b;
  border-color: #60a5fa;
}

[data-theme="dark"] .sheets-gemo-history-item-prompt {
  color: #f8fafc;
}

[data-theme="dark"] .sheets-gemo-history-item-meta {
  color: #94a3b8;
}

/* Actions inside AI messages */
.sheets-gemo-msg-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #f1f3f4;
  flex-wrap: wrap;
}

.sheets-gemo-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid #dadce0;
  background: #ffffff;
  color: #3c4043;
  transition: all 0.15s ease;
}

.sheets-gemo-action-btn:hover {
  background: #f8fafd;
  border-color: #107c41;
  color: #107c41;
}

.sheets-gemo-action-btn.primary {
  background: #107c41;
  color: #ffffff;
  border-color: #107c41;
}

.sheets-gemo-action-btn.primary:hover {
  background: #0d6334;
}

/* Attachments preview row */
.sheets-gemo-attachments-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.sheets-gemo-attachment-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #e8f0fe;
  color: #1a73e8;
  border: 1px solid #d3e3fd;
  border-radius: 12px;
  padding: 3px 8px;
  font-size: 0.74rem;
  font-weight: 500;
}

.sheets-gemo-attachment-tag .remove-tag-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  color: #747775;
  padding: 0;
  display: flex;
  align-items: center;
}

.sheets-gemo-attachment-tag .remove-tag-btn:hover {
  color: #d93025;
}

/* Sidebar Footer / Ask Gemini Input Card (Image 1) */
.sheets-gemo-footer {
  padding: 12px 16px 16px 16px;
  background: #ffffff;
  border-top: 1px solid #f1f3f4;
}

.sheets-gemo-input-card {
  border: 1px solid #d3e3fd;
  border-radius: 16px;
  padding: 12px 14px 10px 14px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.sheets-gemo-input-card:focus-within {
  border-color: #1a73e8;
  box-shadow: 0 2px 10px rgba(26, 115, 232, 0.16);
}

.sheets-gemo-textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 0.92rem;
  color: #1f1f1f;
  min-height: 44px;
  max-height: 120px;
  line-height: 1.4;
  box-sizing: border-box;
}

.sheets-gemo-textarea::placeholder {
  color: #747775;
}

.sheets-gemo-card-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}

.sheets-gemo-card-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sheets-gemo-tool-btn {
  background: none;
  border: 1px solid #dadce0;
  color: #444746;
  font-size: 0.82rem;
  padding: 4px 8px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background-color 0.15s, border-color 0.15s;
}

.sheets-gemo-tool-btn:hover {
  background: #f1f3f4;
  border-color: #c4c7c5;
}

.sheets-gemo-tool-btn.active {
  background: #e8f0fe;
  color: #1a73e8;
  border-color: #1a73e8;
}

.sheets-gemo-submit-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: #e0e2e6;
  color: #8c9096;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  transition: all 0.2s ease;
  font-size: 0.88rem;
}

.sheets-gemo-submit-btn.ready {
  background: #1a73e8;
  color: #ffffff;
  cursor: pointer;
}

.sheets-gemo-submit-btn.ready:hover {
  background: #1557b0;
}

.sheets-gemo-disclaimer {
  text-align: center;
  font-size: 0.72rem;
  color: #747775;
  margin-top: 10px;
}

.sheets-gemo-disclaimer a {
  color: #747775;
  text-decoration: underline;
}

/* Header Sparkle Launch Button in Sheets App Header */
.inf-btn-gemini-header {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #e8f0fe;
  color: #1a73e8;
  cursor: pointer;
  font-size: 1.05rem;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.inf-btn-gemini-header:hover {
  background: #d3e3fd;
  transform: scale(1.05);
}

.inf-btn-gemini-header.active {
  background: linear-gradient(135deg, #1a73e8, #7c3aed);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(26, 115, 232, 0.35);
}

/* Credits Modal Styles */
.gemo-credits-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000000;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: gemoModalFadeIn 0.2s ease-out;
}

.gemo-credits-modal-overlay.open {
  display: flex;
}

@keyframes gemoModalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.gemo-credits-modal-box {
  background: #ffffff;
  color: #0f172a;
  border-radius: 18px;
  padding: 24px;
  max-width: 440px;
  width: 100%;
  position: relative;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.25);
  box-sizing: border-box;
}

.gemo-credits-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: #64748b;
  cursor: pointer;
}

.gemo-credits-modal-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(26, 115, 232, 0.12);
  color: #1a73e8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  margin-bottom: 12px;
}

.gemo-credits-modal-title {
  margin: 0 0 6px 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.gemo-credits-modal-desc {
  font-size: 0.88rem;
  color: #64748b;
  line-height: 1.45;
  margin: 0 0 16px 0;
}

.gemo-pricing-tiers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.gemo-tier-card {
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
}

.gemo-tier-card:hover {
  border-color: #93c5fd;
  background: rgba(240, 246, 255, 0.5);
}

.gemo-tier-card.selected {
  border-color: #0070ba;
  background: rgba(0, 112, 186, 0.05);
}

.gemo-tier-badge {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  background: #0070ba;
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 8px;
  white-space: nowrap;
}

.gemo-tier-amount {
  font-weight: 700;
  font-size: 0.95rem;
  margin-top: 4px;
}

.gemo-tier-price {
  color: #0070ba;
  font-size: 0.88rem;
  font-weight: 600;
  margin: 4px 0 2px 0;
}

.gemo-tier-sub {
  font-size: 0.7rem;
  color: #64748b;
}

.gemo-credits-modal-balance {
  background: #f8fafc;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.84rem;
  text-align: center;
  margin-bottom: 16px;
}

/* Dark theme styling */
[data-theme="dark"] .sheets-gemo-sidebar,
[data-theme="dark"] .sheets-gemo-footer,
[data-theme="dark"] .sheets-gemo-input-card,
[data-theme="dark"] .gemo-credits-modal-box {
  background: #1e293b;
  border-color: #334155;
  color: #f8fafc;
}

[data-theme="dark"] .sheets-gemo-header {
  border-bottom-color: #334155;
}

[data-theme="dark"] .sheets-gemo-header-title,
[data-theme="dark"] .sheets-gemo-suggestion-item,
[data-theme="dark"] .sheets-gemo-textarea {
  color: #f8fafc;
}

[data-theme="dark"] .sheets-gemo-header-menu-btn,
[data-theme="dark"] .sheets-gemo-icon-btn,
[data-theme="dark"] .sheets-gemo-view-all-btn {
  color: #94a3b8;
}

[data-theme="dark"] .sheets-gemo-header-menu-btn:hover,
[data-theme="dark"] .sheets-gemo-icon-btn:hover {
  background: #334155;
  color: #f8fafc;
}

[data-theme="dark"] .sheets-gemo-msg.user {
  background: #334155;
  color: #f8fafc;
}

[data-theme="dark"] .sheets-gemo-msg.ai {
  background: #0f172a;
  border-color: #334155;
  color: #f1f5f9;
}

[data-theme="dark"] .sheets-gemo-msg.ai .gemo-msg-content {
  color: #f1f5f9;
}

[data-theme="dark"] .sheets-gemo-credits-modal-desc {
  color: #94a3b8;
}

[data-theme="dark"] .gemo-tier-card {
  border-color: #475569;
}
