/* CourseOS · Genie
   Floating assistant character with summary,
   Text Me / Email / Snooze actions. */

/* Floating trigger button — anchored to app container, not viewport */
.genie-fab {
  position: fixed;
  bottom: 88px;
  /* Center within the max-width app container */
  right: calc(50% - var(--max-width) / 2 + 16px);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--color-red);
  color: #fff;
  border: none;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(218,0,0,0.35);
  cursor: pointer;
  z-index: 200;
  animation: genie-bounce 2s ease-in-out infinite;
  transition: var(--transition-fast);
}

/* On narrow screens (smaller than max-width), just use right: 16px */
@media (max-width: 430px) {
  .genie-fab {
    right: 16px;
  }
}

.genie-fab:active {
  transform: scale(0.92);
}

@keyframes genie-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

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

/* Overlay backdrop */
.genie-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 300;
  display: none;
  animation: genie-fade-in 0.2s ease;
}

.genie-overlay.open {
  display: block;
}

@keyframes genie-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Genie card */
.genie-card {
  position: fixed;
  bottom: var(--nav-height);
  left: 0;
  right: 0;
  max-width: var(--max-width);
  margin: 0 auto;
  background: var(--bg-primary);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  z-index: 301;
  display: none;
  animation: genie-slide-up 0.3s ease;
  max-height: 70vh;
  overflow-y: auto;
  padding-bottom: var(--space-sm);
}

.genie-card.open {
  display: block;
}

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

/* Genie header */
.genie-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  border-bottom: var(--border-width) solid var(--gray-100);
}

.genie-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-red);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.genie-greeting {
  flex: 1;
}

.genie-greeting-title {
  font-size: var(--font-base);
  font-weight: 700;
  color: var(--text-primary);
}

.genie-greeting-sub {
  font-size: var(--font-xs);
  color: var(--text-secondary);
  margin-top: 1px;
}

.genie-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gray-100);
  border: none;
  font-size: 16px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Summary section */
.genie-summary {
  padding: var(--space-md);
}

.genie-summary-text {
  font-size: var(--font-sm);
  color: var(--text-primary);
  line-height: 1.6;
  white-space: pre-line;
}

/* Action buttons */
.genie-actions {
  display: flex;
  gap: var(--space-sm);
  padding: 0 var(--space-md) var(--space-md);
}

.genie-action-btn {
  flex: 1;
  padding: 12px 8px;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-sm);
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: var(--transition-fast);
}

.genie-action-btn:active {
  transform: scale(0.96);
}

.genie-action-icon {
  font-size: 20px;
}

.genie-btn-text {
  background: #E8F8F5;
  color: #1A8A6A;
}

.genie-btn-email {
  background: #DBEAFE;
  color: #2563EB;
}

.genie-btn-snooze {
  background: #FFF0D4;
  color: #7A4800;
}

/* Snooze options */
.genie-snooze-options {
  display: none;
  padding: 0 var(--space-md) var(--space-md);
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.genie-snooze-options.open {
  display: flex;
}

.genie-snooze-btn {
  padding: 6px 12px;
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--radius-full);
  background: var(--bg-primary);
  font-size: var(--font-xs);
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.genie-snooze-btn:active {
  background: var(--gray-100);
}

/* Loading state */
.genie-loading {
  padding: var(--space-lg);
  text-align: center;
  font-size: var(--font-sm);
  color: var(--text-muted);
  font-style: italic;
}

/* Sent confirmation */
.genie-sent {
  padding: var(--space-md);
  text-align: center;
}

.genie-sent-icon {
  font-size: 32px;
  margin-bottom: var(--space-xs);
}

.genie-sent-text {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.genie-sent-detail {
  font-size: var(--font-xs);
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── Genie notification bubble ── */
.genie-notification {
  position: fixed;
  bottom: 148px;
  right: calc(50% - var(--max-width) / 2 + 8px);
  width: 280px;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  border: var(--border-width) solid var(--border-color);
  box-shadow: var(--shadow-lg);
  z-index: 250;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.95);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.genie-notification.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* On narrow screens, match genie-fab position */
@media (max-width: 430px) {
  .genie-notification {
    right: 8px;
  }
}

/* Speech bubble tail pointing down toward Genie FAB */
.genie-notification::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 20px;
  width: 16px;
  height: 16px;
  background: var(--bg-primary);
  border-right: var(--border-width) solid var(--border-color);
  border-bottom: var(--border-width) solid var(--border-color);
  transform: rotate(45deg);
  box-shadow: 2px 2px 4px rgba(0,0,0,0.04);
}

.genie-notif-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: var(--border-width) solid var(--gray-100);
}

.genie-notif-avatar {
  font-size: 16px;
}

.genie-notif-label {
  font-size: var(--font-xs);
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}

.genie-notif-close {
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.genie-notif-body {
  padding: 10px 12px;
  font-size: var(--font-sm);
  color: var(--text-primary);
  line-height: 1.5;
}

.genie-notif-body strong {
  font-weight: 700;
}

.genie-notif-actions {
  display: flex;
  gap: 6px;
  padding: 0 12px 10px;
}

.genie-notif-btn {
  flex: 1;
  padding: 8px 6px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}

.genie-notif-read {
  background: var(--color-teal);
  color: #fff;
}

.genie-notif-library {
  background: var(--gray-100);
  color: var(--text-primary);
}

.genie-notif-btn:active {
  transform: scale(0.96);
}
