/* ============================================
   PREMIUM FEATURES CSS — Workflow, Templates, Analytics
   ============================================ */

/* --- Content Workflow Builder --- */
.workflow-templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.workflow-template-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  cursor: pointer;
  transition: all var(--transition-normal);
  border-top: 3px solid var(--wf-color);
  position: relative;
  overflow: hidden;
}
.workflow-template-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, color-mix(in srgb, var(--wf-color) 6%, transparent), transparent);
  opacity: 0;
  transition: opacity var(--transition-normal);
}
.workflow-template-card:hover {
  border-color: var(--wf-color);
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.workflow-template-card:hover::after { opacity: 1; }

.wf-card-icon { font-size: 2rem; margin-bottom: 12px; position: relative; z-index: 1; }
.wf-card-name { font-family: var(--font-display); font-size: 1.05rem; font-weight: 700; margin-bottom: 6px; position: relative; z-index: 1; }
.wf-card-desc { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 14px; line-height: 1.5; position: relative; z-index: 1; }

.wf-card-steps {
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px;
  position: relative; z-index: 1;
}
.wf-step-chip {
  font-size: 0.68rem; font-weight: 500; padding: 3px 8px;
  border-radius: var(--radius-pill); background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-color); color: var(--text-muted);
}

.wf-generate-btn {
  width: 100%; padding: 10px; border-radius: var(--radius-md);
  background: rgba(255,255,255,0.04); border: 1px solid var(--border-color);
  color: var(--text-secondary); font-size: 0.82rem; font-weight: 600;
  font-family: var(--font-primary); cursor: pointer;
  transition: all var(--transition-normal);
  position: relative; z-index: 1;
}
.wf-generate-btn:hover {
  background: rgba(168,85,247,0.1); border-color: var(--accent-1); color: var(--accent-1);
}

/* Workflow Output */
.workflow-output {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); padding: 28px; margin-top: 24px;
}

.wf-output-header { margin-bottom: 24px; }
.wf-output-title { font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; }
.wf-output-meta { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 12px; }

.wf-copy-all-btn {
  padding: 8px 18px; border-radius: var(--radius-pill);
  background: rgba(168,85,247,0.1); border: 1px solid rgba(168,85,247,0.3);
  color: var(--accent-1); font-size: 0.78rem; font-weight: 600;
  font-family: var(--font-primary); cursor: pointer;
  transition: all var(--transition-fast);
}
.wf-copy-all-btn:hover { background: rgba(168,85,247,0.2); }

.wf-output-pieces { display: flex; flex-direction: column; gap: 16px; }

.wf-piece {
  background: rgba(255,255,255,0.02); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 18px;
  transition: border-color var(--transition-fast);
}
.wf-piece:hover { border-color: var(--border-hover); }

.wf-piece-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.wf-piece-icon { font-size: 1.1rem; }
.wf-piece-label { font-family: var(--font-display); font-size: 0.88rem; font-weight: 700; }
.wf-piece-desc { font-size: 0.72rem; color: var(--text-muted); margin-left: auto; }
.wf-piece-copy {
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; border: 1px solid var(--border-color); background: transparent;
  color: var(--text-muted); cursor: pointer; transition: all var(--transition-fast); flex-shrink: 0;
}
.wf-piece-copy:hover { border-color: var(--accent-3); color: var(--accent-3); }

.wf-piece-text {
  font-size: 0.84rem; line-height: 1.65; color: var(--text-secondary);
  white-space: pre-wrap;
}

/* --- Templates Gallery --- */
.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.template-pack-card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); padding: 24px;
  cursor: pointer; transition: all var(--transition-normal);
  position: relative; overflow: hidden;
}
.template-pack-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--tp-color);
}
.template-pack-card:hover {
  border-color: var(--tp-color); transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.tp-tag {
  display: inline-block; font-size: 0.6rem; font-weight: 700;
  letter-spacing: 1.5px; padding: 3px 8px; border-radius: var(--radius-pill);
  margin-bottom: 12px; text-transform: uppercase;
}
.tp-icon { font-size: 2.2rem; margin-bottom: 10px; }
.tp-name { font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; }
.tp-desc { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 12px; line-height: 1.5; }
.tp-count { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 14px; font-weight: 600; }

.tp-expand-btn {
  width: 100%; padding: 10px; border-radius: var(--radius-md);
  background: rgba(255,255,255,0.04); border: 1px solid var(--border-color);
  color: var(--text-secondary); font-size: 0.82rem; font-weight: 600;
  font-family: var(--font-primary); cursor: pointer;
  transition: all var(--transition-normal);
}
.tp-expand-btn:hover { background: rgba(168,85,247,0.1); border-color: var(--accent-1); color: var(--accent-1); }

/* Template Pack Detail */
.template-pack-detail {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); overflow: hidden; margin-top: 24px;
}

.tpd-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap; gap: 12px;
}
.tpd-info { display: flex; align-items: center; gap: 10px; }
.tpd-icon { font-size: 1.5rem; }
.tpd-name { font-family: var(--font-display); font-size: 1rem; font-weight: 700; }
.tpd-count { font-size: 0.72rem; color: var(--text-muted); }
.tpd-actions { display: flex; gap: 8px; }

.tpd-copy-all {
  padding: 7px 14px; border-radius: var(--radius-pill);
  background: rgba(168,85,247,0.1); border: 1px solid rgba(168,85,247,0.3);
  color: var(--accent-1); font-size: 0.75rem; font-weight: 600;
  font-family: var(--font-primary); cursor: pointer; transition: all var(--transition-fast);
}
.tpd-copy-all:hover { background: rgba(168,85,247,0.2); }

.tpd-close {
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md); border: 1px solid var(--border-color);
  background: transparent; color: var(--text-muted); cursor: pointer;
  font-size: 0.9rem; transition: all var(--transition-fast);
}
.tpd-close:hover { border-color: var(--text-muted); color: var(--text-primary); }

.tpd-prompts { padding: 16px 24px; display: flex; flex-direction: column; gap: 10px; }

.tpd-prompt-card {
  display: flex; align-items: flex-start; gap: 12px;
  background: rgba(255,255,255,0.02); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 14px; cursor: pointer;
  transition: all var(--transition-fast);
}
.tpd-prompt-card:hover { border-color: var(--accent-1); background: rgba(168,85,247,0.03); }
.tpd-prompt-card.copied { border-color: var(--accent-3); box-shadow: 0 0 20px rgba(6,214,160,0.15); }

.tpd-prompt-num {
  font-family: var(--font-display); font-size: 0.68rem; font-weight: 700;
  color: var(--accent-1); opacity: 0.7; flex-shrink: 0; padding-top: 2px;
}
.tpd-prompt-text { font-size: 0.82rem; line-height: 1.55; color: var(--text-secondary); flex: 1; }
.tpd-prompt-copy {
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; border: 1px solid var(--border-color); background: transparent;
  color: var(--text-muted); cursor: pointer; transition: all var(--transition-fast); flex-shrink: 0;
}
.tpd-prompt-copy:hover { border-color: var(--accent-3); color: var(--accent-3); }

/* --- Analytics Dashboard --- */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px; margin-bottom: 20px;
}

.analytics-card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); padding: 24px;
  transition: border-color var(--transition-fast);
}
.analytics-card:hover { border-color: var(--border-hover); }

.stat-card { text-align: center; }
.astat-icon { font-size: 1.8rem; margin-bottom: 8px; }
.astat-value {
  font-family: var(--font-display); font-size: 2rem; font-weight: 800;
  background: var(--gradient-main); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent; background-clip: text;
}
.astat-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; font-weight: 500; }

.analytics-details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.chart-card { padding: 24px; }
.achart-title {
  font-family: var(--font-display); font-size: 0.95rem; font-weight: 700;
  margin-bottom: 18px;
}
.achart-bars { display: flex; flex-direction: column; gap: 10px; }

.abar-row { display: flex; align-items: center; gap: 10px; }
.abar-label { font-size: 0.75rem; color: var(--text-muted); width: 100px; text-transform: capitalize; flex-shrink: 0; }
.abar-track {
  flex: 1; height: 8px; background: rgba(255,255,255,0.04);
  border-radius: 4px; overflow: hidden;
}
.abar-fill {
  height: 100%; background: var(--gradient-main); border-radius: 4px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}
.abar-value { font-size: 0.72rem; font-weight: 700; color: var(--text-secondary); width: 30px; text-align: right; }

.analytics-empty { font-size: 0.82rem; color: var(--text-muted); text-align: center; padding: 20px; }

/* Heatmap */
.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px; margin-bottom: 10px;
}
.heatmap-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  background: rgba(168, 85, 247, calc(var(--heat) * 0.8 + 0.02));
  border: 1px solid rgba(168, 85, 247, calc(var(--heat) * 0.3 + 0.05));
  transition: all var(--transition-fast);
}
.heatmap-cell:hover { transform: scale(1.3); }

.heatmap-legend {
  display: flex; align-items: center; gap: 4px; justify-content: flex-end;
  font-size: 0.65rem; color: var(--text-muted);
}
.heatmap-cell-legend {
  width: 14px; height: 14px; border-radius: 3px;
  background: rgba(168, 85, 247, calc(var(--heat) * 0.8 + 0.02));
  border: 1px solid rgba(168, 85, 247, calc(var(--heat) * 0.3 + 0.05));
}

/* --- Scroll to Top Button --- */
.scroll-top-btn {
  position: fixed; bottom: 24px; right: 24px;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; z-index: 900;
  background: var(--bg-card); border: 1px solid var(--border-color);
  color: var(--text-muted); cursor: pointer;
  transition: all var(--transition-normal);
  opacity: 0; pointer-events: none;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.scroll-top-btn.visible { opacity: 1; pointer-events: all; }
.scroll-top-btn:hover {
  border-color: var(--accent-1); color: var(--accent-1);
  transform: translateY(-2px); box-shadow: var(--shadow-glow);
}

/* --- Responsive for new features --- */
@media (max-width: 768px) {
  .workflow-templates-grid { grid-template-columns: 1fr; }
  .templates-grid { grid-template-columns: 1fr; }
  .analytics-details-grid { grid-template-columns: 1fr; }
  .analytics-grid { grid-template-columns: repeat(2, 1fr); }
  .heatmap-grid { grid-template-columns: repeat(6, 1fr); }
}

/* ============================================
   AUTHENTICATION UI
   ============================================ */

/* Auth Button in Header */
.auth-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: var(--radius-pill);
  background: linear-gradient(135deg, #7c3aed 0%, #2563eb 100%);
  border: none; color: #fff; font-size: 0.78rem; font-weight: 700;
  font-family: var(--font-primary); cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 12px rgba(124,58,237,0.3);
  white-space: nowrap;
}
.auth-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(124,58,237,0.45);
}

/* Signed-in User Chip */
.auth-user-info {
  display: none; align-items: center; gap: 8px;
  padding: 4px 12px 4px 4px; border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.05); border: 1px solid var(--border-color);
  cursor: pointer; transition: all var(--transition-fast); position: relative;
}
.auth-user-info:hover { border-color: var(--border-hover); background: rgba(255,255,255,0.08); }

.auth-user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  object-fit: cover; border: 2px solid var(--accent-1);
}
.auth-user-name {
  font-size: 0.78rem; font-weight: 600; color: var(--text-primary);
  max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* User Dropdown Menu */
.auth-user-menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 6px 0; min-width: 180px;
  box-shadow: var(--shadow-lg); z-index: 1010;
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: all var(--transition-fast);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.auth-user-menu.visible { opacity: 1; visibility: visible; transform: translateY(0); }

.auth-user-menu-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; font-size: 0.82rem; color: var(--text-secondary);
  background: none; border: none; width: 100%; text-align: left;
  font-family: var(--font-primary); cursor: pointer; transition: all var(--transition-fast);
}
.auth-user-menu-item:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
.auth-user-menu-item.danger { color: #f87171; }
.auth-user-menu-item.danger:hover { background: rgba(248,113,113,0.08); }
.auth-user-menu-divider { height: 1px; background: var(--border-color); margin: 4px 0; }

/* Auth Modal Overlay */
.auth-modal-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: all 0.3s ease;
}
.auth-modal-overlay.active { opacity: 1; visibility: visible; pointer-events: all; }

/* Auth Modal */
.auth-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl, 20px);
  width: 100%; max-width: 420px;
  box-shadow: 0 25px 80px rgba(0,0,0,0.6);
  transform: scale(0.95) translateY(10px);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}
.auth-modal-overlay.active .auth-modal { transform: scale(1) translateY(0); }

.auth-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 24px 28px 0; margin-bottom: 4px;
}
.auth-modal-title {
  font-family: var(--font-display); font-size: 1.3rem; font-weight: 800;
  color: var(--text-primary);
}
.auth-modal-close {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: 8px; border: 1px solid var(--border-color); background: transparent;
  color: var(--text-muted); cursor: pointer; font-size: 1rem;
  transition: all var(--transition-fast);
}
.auth-modal-close:hover { border-color: var(--text-muted); color: var(--text-primary); }

.auth-modal-body { padding: 20px 28px 28px; }

.auth-modal-subtitle {
  font-size: 0.84rem; color: var(--text-muted); margin-bottom: 22px; line-height: 1.5;
}

/* Google Sign In Button */
.auth-google-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 12px; border-radius: var(--radius-md);
  background: #fff; border: 1px solid rgba(255,255,255,0.2);
  color: #333; font-size: 0.88rem; font-weight: 600;
  font-family: var(--font-primary); cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
.auth-google-btn:hover { background: #f8f8f8; box-shadow: 0 2px 8px rgba(0,0,0,0.15); }

.auth-google-icon {
  width: 18px; height: 18px;
}

.auth-divider {
  display: flex; align-items: center; gap: 14px;
  margin: 20px 0; font-size: 0.75rem; color: var(--text-muted);
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border-color);
}

/* Form Fields */
.auth-field {
  margin-bottom: 14px;
}
.auth-field-label {
  display: block; font-size: 0.78rem; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 6px;
}
.auth-field-input {
  width: 100%; padding: 11px 14px; border-radius: var(--radius-md);
  border: 1px solid var(--border-color); background: rgba(255,255,255,0.04);
  color: var(--text-primary); font-size: 0.88rem;
  font-family: var(--font-primary); outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  box-sizing: border-box;
}
.auth-field-input::placeholder { color: rgba(255,255,255,0.25); }
.auth-field-input:focus {
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px rgba(168,85,247,0.15);
}

/* Submit Button */
.auth-submit-btn {
  width: 100%; padding: 12px; border-radius: var(--radius-md);
  background: linear-gradient(135deg, #7c3aed 0%, #2563eb 100%);
  border: none; color: #fff; font-size: 0.9rem; font-weight: 700;
  font-family: var(--font-primary); cursor: pointer;
  transition: all var(--transition-fast); margin-top: 6px;
  box-shadow: 0 4px 16px rgba(124,58,237,0.3);
}
.auth-submit-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(124,58,237,0.45);
}
.auth-submit-btn:disabled { opacity: 0.65; cursor: not-allowed; transform: none; }

/* Error Message */
.auth-error {
  display: none; font-size: 0.78rem; color: #f87171;
  background: rgba(248,113,113,0.08); border: 1px solid rgba(248,113,113,0.2);
  border-radius: var(--radius-md); padding: 10px 12px; margin-bottom: 12px;
  line-height: 1.4;
}

/* Loading Spinner */
.auth-spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff;
  border-radius: 50%; animation: authSpin 0.6s linear infinite;
  vertical-align: middle;
}
@keyframes authSpin { to { transform: rotate(360deg); } }

/* Auth Links */
.auth-links {
  margin-top: 18px; text-align: center; font-size: 0.8rem; color: var(--text-muted);
}
.auth-link {
  color: var(--accent-1); cursor: pointer; font-weight: 600;
  text-decoration: none; transition: color var(--transition-fast);
  background: none; border: none; font-family: var(--font-primary); font-size: 0.8rem;
}
.auth-link:hover { color: var(--accent-2); }

/* Responsive */
@media (max-width: 480px) {
  .auth-modal { max-width: 100%; border-radius: 16px; }
  .auth-modal-body { padding: 16px 20px 24px; }
  .auth-modal-header { padding: 20px 20px 0; }
  .auth-user-name { display: none; }
}

