/* ==========================================================================
   SasoniServices - Professional Multi-Model AI Platform (ChatGPT Style)
   Design System: Layout Centrato, Composer con Model Selector & Allega,
   NanoBanana AI Studio, Auth Modals, Background Generation Indicator
   ========================================================================== */

:root {
  /* Tema Scuro (Default) */
  --bg-app: #212121;
  --bg-sidebar: #171717;
  --bg-surface: #2f2f2f;
  --bg-surface-hover: #383838;
  --bg-input: #2f2f2f;
  --bg-code: #181818;
  
  --border-color: rgba(255, 255, 255, 0.1);
  --border-color-hover: rgba(255, 255, 255, 0.22);
  
  --text-main: #ececec;
  --text-secondary: #b4b4b4;
  --text-muted: #7d7d7d;
  
  --brand-primary: #10a37f;
  --brand-secondary: #00d2ff;
  --brand-gradient: linear-gradient(135deg, #10a37f 0%, #00d2ff 50%, #3a7bd5 100%);
  --brand-glow: rgba(16, 163, 127, 0.25);

  --cialleng-gold: #f59e0b;
  --banana-yellow: #eab308;
  --banana-glow: rgba(234, 179, 8, 0.35);
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.45);
  
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 9999px;
  
  --sidebar-width: 275px;
  --topbar-height: 62px;
  --input-max-width: 820px;
  
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, Monaco, monospace;
}

[data-theme="light"] {
  --bg-app: #ffffff;
  --bg-sidebar: #f8f9fa;
  --bg-surface: #f0f2f5;
  --bg-surface-hover: #e4e7eb;
  --bg-input: #f4f5f7;
  --bg-code: #f6f8fa;
  
  --border-color: rgba(0, 0, 0, 0.09);
  --border-color-hover: rgba(0, 0, 0, 0.18);
  
  --text-main: #111827;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  
  --brand-primary: #0d8c6d;
  --brand-secondary: #0284c7;
  --brand-gradient: linear-gradient(135deg, #0d8c6d 0%, #0284c7 100%);
  --brand-glow: rgba(13, 140, 109, 0.15);
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
}

/* ==========================================================================
   Base & Resets
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

/* Chat page strict lockdown - ONLY when chat page is active */
html.chat-page-html,
html:has(body.chat-page-body),
body.chat-page-body {
  height: 100%;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
}

body.chat-page-body {
  position: fixed;
  inset: 0;
}

.app-layout {
  display: flex;
  height: 100%;
  width: 100%;
  overflow: hidden;
  position: relative;
}

/* ==========================================================================
   Sidebar a Sinistra
   ========================================================================== */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 50;
}

.sidebar-header {
  padding: 16px 18px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  color: #10a37f;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-weight: 700;
  font-size: 0.98rem;
  letter-spacing: -0.3px;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-tag {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  font-weight: 600;
}

.close-sidebar-btn {
  display: none;
}

.sidebar-action {
  padding: 6px 14px;
}

.new-chat-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  background-color: transparent;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.new-chat-btn:hover {
  background-color: var(--bg-surface);
  border-color: var(--border-color-hover);
}

.keyboard-badge {
  margin-left: auto;
  font-size: 0.7rem;
  padding: 2px 6px;
  background-color: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Pulsante Dedicato NanoBanana Studio nella Sidebar */
.sidebar-nanobanana-box {
  padding: 6px 14px 10px;
}

.nanobanana-studio-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.12) 0%, rgba(245, 158, 11, 0.12) 100%);
  border: 1px solid rgba(234, 179, 8, 0.35);
  border-radius: var(--radius-md);
  color: var(--banana-yellow);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: left;
}

.nanobanana-studio-btn:hover {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.22) 0%, rgba(245, 158, 11, 0.22) 100%);
  border-color: rgba(234, 179, 8, 0.6);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(234, 179, 8, 0.2);
}

.banana-icon {
  font-size: 1.3rem;
  animation: slight-tilt 3s ease-in-out infinite;
}

@keyframes slight-tilt {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(10deg); }
}

.nanobanana-btn-text {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.btn-main-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
}

.btn-sub-title {
  font-size: 0.68rem;
  color: var(--banana-yellow);
}

.badge-new {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  background-color: var(--banana-yellow);
  color: #1a1a1a;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
}

.search-box {
  margin: 0 14px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background-color: var(--bg-surface);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  color: var(--text-muted);
}

.search-box:focus-within {
  border-color: var(--border-color-hover);
}

.search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 0.82rem;
  width: 100%;
}

/* Lista Cronologia */
.chat-history-section {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px;
}

.history-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 6px;
}

.history-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.guest-history-badge {
  font-size: 0.66rem;
  color: #f59e0b;
  background-color: rgba(245, 158, 11, 0.15);
  padding: 1px 6px;
  border-radius: 4px;
}

.conversations-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.85rem;
  transition: all 0.15s ease;
  position: relative;
  text-decoration: none;
}

.history-item:hover {
  background-color: var(--bg-surface);
  color: var(--text-main);
}

.history-item.active {
  background-color: var(--bg-surface);
  color: var(--text-main);
  font-weight: 500;
}

.history-item-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  padding-right: 6px;
}

/* Indicatore Animato Generazione in Corso nella Sidebar (Requisito 2 & 21) */
.history-status-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-right: 4px;
}

.pulse-indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--brand-primary);
  box-shadow: 0 0 8px var(--brand-primary);
  animation: pulse-ring 1.4s infinite cubic-bezier(0.45, 0, 0.55, 1);
}

@keyframes pulse-ring {
  0% { transform: scale(0.8); opacity: 0.6; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.8); opacity: 0.6; }
}

.history-actions {
  display: none;
  gap: 4px;
}

.history-item:hover .history-actions,
.history-item.active .history-actions {
  display: flex;
}

.history-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.history-btn:hover {
  color: var(--text-main);
  background-color: rgba(255, 255, 255, 0.1);
}

.history-btn.delete-conv-btn:hover {
  color: #ff5c5c;
  background-color: rgba(255, 92, 92, 0.15);
}

.history-empty {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 16px 8px;
  text-align: center;
}

/* Footer Sidebar (Account & Utility) */
.sidebar-footer {
  border-top: 1px solid var(--border-color);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-status-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background-color: var(--bg-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.user-avatar-mini {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(255, 255, 255, 0.08);
  font-size: 0.85rem;
}

.user-avatar-mini.authenticated-avatar {
  background: var(--brand-gradient);
  color: #fff;
  font-weight: 700;
}

.user-info-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-display-name {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-main);
}

.user-badge-state {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.auth-buttons-group {
  display: flex;
  gap: 8px;
}

.auth-pill-btn {
  flex: 1;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.auth-pill-btn.login-btn {
  background-color: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.auth-pill-btn.login-btn:hover {
  background-color: var(--bg-surface-hover);
}

.auth-pill-btn.register-btn {
  background: var(--brand-gradient);
  color: #fff;
  border: none;
}

.auth-pill-btn.register-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.user-dropdown-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.footer-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.footer-btn:hover {
  background-color: var(--bg-surface);
  color: var(--text-main);
}

.footer-btn.logout-text-btn:hover {
  color: #ff5c5c;
  background-color: rgba(255, 92, 92, 0.12);
}

.utility-footer-btns {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  border-top: 1px solid var(--border-color);
  padding-top: 8px;
}

.icon-utility-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}

.icon-utility-btn:hover {
  color: var(--text-main);
  background-color: var(--bg-surface);
}

[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-dark { display: block; }
[data-theme="light"] .theme-icon-dark { display: none; }
[data-theme="light"] .theme-icon-light { display: block; }

/* ==========================================================================
   Area Principale Chat
   ========================================================================== */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  position: relative;
  background-color: var(--bg-app);
}

/* Topbar */
.chat-topbar {
  flex-shrink: 0;
  height: var(--topbar-height);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-app);
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.current-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.current-chat-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.active-chat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
}

.status-pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--brand-primary);
}

.status-text {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
}

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

.topbar-nanobanana-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.15) 0%, rgba(245, 158, 11, 0.15) 100%);
  border: 1px solid rgba(234, 179, 8, 0.4);
  border-radius: var(--radius-pill);
  color: var(--banana-yellow);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.topbar-nanobanana-btn:hover {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.25) 0%, rgba(245, 158, 11, 0.25) 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--banana-glow);
}

.banana-bounce {
  font-size: 1.1rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:hover {
  background-color: var(--bg-surface);
  color: var(--text-main);
  border-color: var(--border-color-hover);
}

.mobile-menu-btn {
  display: none;
  padding: 8px;
}

/* ==========================================================================
   Contenitore Messaggi & Welcome Screen
   ========================================================================== */
.messages-container {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  padding-bottom: 24px;
}

.welcome-screen {
  max-width: 820px;
  margin: auto;
  padding: 30px 24px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.welcome-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.welcome-icon {
  filter: drop-shadow(0 4px 16px var(--brand-glow));
}

.welcome-company {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.welcome-title {
  font-size: 2.1rem;
  font-weight: 600;
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}

.welcome-subtitle {
  font-size: 0.96rem;
  color: var(--text-secondary);
  line-height: 1.5;
  max-width: 680px;
  margin-bottom: 20px;
}

.guest-welcome-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background-color: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  font-size: 0.85rem;
  color: var(--text-main);
  text-align: left;
  max-width: 720px;
}

.guest-banner-icon {
  font-size: 1.4rem;
}

.inline-auth-btn {
  background: none;
  border: none;
  color: #00d2ff;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  padding: 0 4px;
}

.suggestion-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
}

.suggestion-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 15px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.suggestion-card:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-color-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.suggestion-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.suggestion-icon {
  font-size: 1.15rem;
}

.suggestion-tag {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--brand-primary);
  letter-spacing: 0.4px;
}

.suggestion-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ==========================================================================
   Lista Messaggi
   ========================================================================== */
.chat-messages-list {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.message-row {
  display: flex;
  padding: 22px 20px;
  justify-content: center;
  width: 100%;
  animation: fadeIn 0.25s ease-out;
}

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

.message-row.user {
  background-color: transparent;
}

.message-row.assistant {
  background-color: transparent;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
}

[data-theme="light"] .message-row.assistant {
  border-top: 1px solid rgba(0, 0, 0, 0.03);
}

.message-content-wrapper {
  max-width: var(--input-max-width);
  width: 100%;
  display: flex;
  gap: 18px;
}

/* AVATAR */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.user-avatar {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #fff;
}

.assistant-avatar.avatar-sasonisintelligence {
  background: var(--brand-gradient);
  color: #fff;
}

.assistant-avatar.avatar-qwen {
  background: linear-gradient(135deg, #0284c7 0%, #06b6d4 100%);
  color: #fff;
}

/* AVATAR ESCLUSIVO DI CIALLENGAI */
.assistant-avatar.avatar-ciallengai {
  background: transparent;
  border: 2px solid var(--cialleng-gold);
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

.avatar-ciallengai img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.message-bubble {
  flex: 1;
  min-width: 0;
}

.message-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.author-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

.model-tag-pill {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 4px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}

.streaming-pulse-badge {
  font-size: 0.7rem;
  color: var(--brand-primary);
  font-style: italic;
}

.message-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-left: auto;
}

.message-attached-image {
  margin-bottom: 10px;
}

.chat-thumb-img {
  max-width: 280px;
  max-height: 200px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: transform 0.2s;
}

.chat-thumb-img:hover {
  transform: scale(1.02);
}

/* Accordion Reasoning Docente ITISCAMPIA */
.reasoning-accordion {
  margin: 10px 0 14px;
  background-color: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.reasoning-summary {
  padding: 8px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--cialleng-gold);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  background-color: rgba(245, 158, 11, 0.05);
}

.reasoning-summary:hover {
  background-color: rgba(245, 158, 11, 0.12);
}

.reasoning-body {
  padding: 12px;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-secondary);
  border-top: 1px solid rgba(245, 158, 11, 0.15);
  white-space: pre-wrap;
  font-family: var(--font-mono);
  background-color: rgba(0, 0, 0, 0.2);
}

.markdown-body {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-main);
  word-break: break-word;
}

.markdown-body p { margin-bottom: 12px; }
.markdown-body p:last-child { margin-bottom: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
  margin-top: 20px; margin-bottom: 10px; font-weight: 600;
}
.markdown-body ul, .markdown-body ol { margin-left: 20px; margin-bottom: 12px; }
.markdown-body li { margin-bottom: 4px; }
.markdown-body blockquote {
  border-left: 3px solid var(--brand-primary);
  padding-left: 14px; color: var(--text-secondary); margin: 12px 0; font-style: italic;
}
.markdown-body table { border-collapse: collapse; width: 100%; margin: 16px 0; font-size: 0.88rem; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border-color); padding: 8px 12px; text-align: left; }
.markdown-body th { background-color: var(--bg-surface); font-weight: 600; }
.markdown-body code:not(pre code) {
  font-family: var(--font-mono); font-size: 0.85em; background-color: var(--bg-surface);
  padding: 2px 6px; border-radius: 4px; color: var(--brand-secondary);
}

.code-block-container {
  margin: 14px 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background-color: var(--bg-code);
  border: 1px solid var(--border-color);
}

.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background-color: rgba(255, 255, 255, 0.04);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.copy-code-btn {
  background: transparent; border: none; color: var(--text-secondary); font-size: 0.75rem;
  display: flex; align-items: center; gap: 5px; cursor: pointer; padding: 3px 8px; border-radius: 4px;
}
.copy-code-btn:hover { background-color: var(--bg-surface); color: var(--text-main); }
.code-block-container pre {
  margin: 0; padding: 14px; overflow-x: auto; font-family: var(--font-mono); font-size: 0.88rem; line-height: 1.5;
}

.message-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.action-pill-btn {
  background: transparent; border: none; color: var(--text-muted); font-size: 0.78rem;
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer; padding: 4px 8px;
  border-radius: var(--radius-sm); transition: all 0.15s;
}
.action-pill-btn:hover { background-color: var(--bg-surface); color: var(--text-main); }

/* Typing indicator */
.typing-indicator-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
}

.typing-bubble { display: flex; flex-direction: column; gap: 6px; }
.typing-header { display: flex; align-items: center; gap: 10px; }
.typing-author { font-size: 0.88rem; font-weight: 600; color: var(--text-main); }
.typing-model-tag { font-size: 0.68rem; color: var(--brand-secondary); font-family: var(--font-mono); }
.cancel-stream-btn {
  font-size: 0.7rem; color: #ff5c5c; background: rgba(255, 92, 92, 0.1); border: 1px solid rgba(255, 92, 92, 0.3);
  border-radius: 4px; padding: 2px 8px; cursor: pointer;
}

.typing-dots { display: flex; align-items: center; gap: 5px; padding: 8px 0; }
.typing-dots span {
  width: 7px; height: 7px; background-color: var(--brand-primary); border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}
.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ==========================================================================
   Composer in Basso al Centro (Requisito 4 & 9)
   Disposizione: [ 📎 Allega ] [ Textarea ] [ Modello ▼ ] [ INVIA ]
   ========================================================================== */
.chat-input-area {
  flex-shrink: 0;
  padding: 0 20px 18px;
  display: flex;
  justify-content: center;
  background: linear-gradient(180deg, transparent 0%, var(--bg-app) 20%);
}

.input-box-container {
  max-width: var(--input-max-width);
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.attachment-preview-bar {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  animation: fadeIn 0.2s ease;
}

.attachment-thumb-wrapper {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.attachment-thumb-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.remove-attachment-btn {
  position: absolute;
  top: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border: none;
  font-size: 11px;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.attachment-filename {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.chat-form { width: 100%; }

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 28px;
  padding: 8px 10px 8px 14px;
  box-shadow: var(--shadow-md);
  transition: all 0.2s ease;
  gap: 8px;
}

.input-wrapper:focus-within {
  border-color: var(--border-color-hover);
  box-shadow: 0 0 0 1px var(--border-color-hover), var(--shadow-lg);
}

/* Pulsante Allega File nel Composer */
.composer-attach-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.composer-attach-btn:hover {
  color: var(--text-main);
  background-color: rgba(255, 255, 255, 0.08);
}

.attach-btn-label {
  font-size: 0.75rem;
  font-weight: 500;
}

.input-wrapper textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none;
  max-height: 180px;
  min-height: 24px;
  padding: 2px 4px;
  box-sizing: border-box;
  overflow-y: hidden;
}

.input-wrapper textarea::placeholder { color: var(--text-muted); }

/* Selettore Modello situato nel Composer */
.composer-model-dropdown-wrapper {
  position: relative;
}

.composer-model-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  color: var(--text-main);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.15s;
  white-space: nowrap;
}

.composer-model-trigger:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-color-hover);
}

.model-trigger-icon { font-size: 0.95rem; }
.dropdown-chevron { color: var(--text-muted); transition: transform 0.2s; }
.composer-model-dropdown-wrapper.open .dropdown-chevron { transform: rotate(180deg); }

/* Menu a tendina dei modelli sopra il composer */
.composer-model-menu {
  display: none;
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  width: 310px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  z-index: 100;
  backdrop-filter: blur(10px);
  animation: fadeInUp 0.2s ease-out;
}

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

.composer-model-dropdown-wrapper.open .composer-model-menu { display: block; }

.model-menu-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 4px 8px 6px;
  letter-spacing: 0.5px;
}

.composer-model-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.composer-model-option:hover {
  background-color: var(--bg-surface-hover);
}

.composer-model-option.active {
  background-color: rgba(16, 163, 127, 0.15);
  border: 1px solid rgba(16, 163, 127, 0.3);
}

.composer-model-option.locked {
  opacity: 0.65;
}

.composer-model-option.locked:hover {
  background-color: rgba(245, 158, 11, 0.1);
}

.opt-icon { font-size: 1.2rem; width: 28px; text-align: center; }
.opt-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; border: 1.5px solid var(--cialleng-gold); }
.opt-info { flex: 1; min-width: 0; }
.opt-name { font-size: 0.85rem; font-weight: 600; color: var(--text-main); display: flex; align-items: center; gap: 6px; }
.opt-desc { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }

.badge { font-size: 0.65rem; font-weight: 700; padding: 1px 6px; border-radius: 4px; text-transform: uppercase; }
.badge.flagship { background-color: rgba(16, 163, 127, 0.2); color: #10a37f; }
.badge.free { background-color: rgba(0, 210, 255, 0.2); color: #00d2ff; }
.badge.doc { background-color: rgba(245, 158, 11, 0.25); color: #f59e0b; }

.lock-indicator { font-size: 0.75rem; margin-left: auto; }

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--text-main);
  color: var(--bg-app);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.send-btn:disabled { opacity: 0.25; cursor: not-allowed; background-color: var(--text-muted); }
.send-btn:not(:disabled):hover { transform: scale(1.06); background-color: var(--brand-primary); color: #fff; }

.chat-footer-disclaimer {
  margin-top: 8px; font-size: 0.72rem; color: var(--text-muted); text-align: center;
}

/* ==========================================================================
   MODAL NANOBANANA AI STUDIO
   ========================================================================== */
.studio-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.studio-modal-overlay.open { display: flex; }

.studio-modal-container {
  width: 100%;
  max-width: 920px;
  max-height: 90vh;
  background-color: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: scaleInModal 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleInModal {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.studio-modal-header {
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-sidebar);
}

.studio-title-box { display: flex; align-items: center; gap: 14px; }
.studio-logo-banana { font-size: 2rem; }
.studio-title { font-size: 1.25rem; font-weight: 700; color: var(--text-main); }
.studio-subtitle { font-size: 0.78rem; color: var(--text-muted); }

.studio-close-btn {
  background: transparent; border: none; font-size: 1.8rem; color: var(--text-muted); cursor: pointer;
}
.studio-close-btn:hover { color: var(--text-main); }

.studio-tabs {
  display: flex;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0 16px;
  gap: 8px;
}

.studio-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.studio-tab-btn:hover { color: var(--text-main); }
.studio-tab-btn.active {
  color: var(--banana-yellow);
  border-bottom-color: var(--banana-yellow);
}

.studio-tab-content {
  display: none;
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.studio-tab-content.active { display: block; }

.studio-form-layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
  align-items: start;
}

.studio-input-column { display: flex; flex-direction: column; gap: 12px; }
.studio-field-label { font-size: 0.85rem; font-weight: 600; color: var(--text-main); }

.studio-textarea {
  width: 100%;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  resize: vertical;
}

.studio-textarea:focus { outline: none; border-color: var(--border-color-hover); }

.studio-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.chips-title { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; }

.studio-chip {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}

.studio-chip:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-main);
  border-color: var(--border-color-hover);
}

.studio-primary-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 20px;
  background: linear-gradient(135deg, #eab308 0%, #f59e0b 100%);
  color: #1a1a1a;
  font-weight: 700;
  font-size: 0.92rem;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 8px;
}

.studio-primary-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--banana-glow);
}

.studio-primary-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Anteprima Risultato Studio */
.studio-result-column {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.studio-preview-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  padding: 40px;
}

.preview-empty-state { text-align: center; color: var(--text-muted); }
.empty-icon { font-size: 2.5rem; display: block; margin-bottom: 10px; }

.studio-preview-active { width: 100%; }

.studio-result-image {
  width: 100%;
  max-height: 380px;
  object-fit: contain;
  display: block;
}

.studio-image-meta {
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.3);
  border-top: 1px solid var(--border-color);
}

.image-engine-tag { font-size: 0.75rem; color: var(--banana-yellow); font-weight: 600; }
.image-actions-row { display: flex; gap: 8px; }

.studio-action-link {
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  text-decoration: none;
  cursor: pointer;
}

.studio-action-link:hover { background-color: var(--bg-surface-hover); }

/* Dropzone Upload */
.upload-dropzone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background-color: rgba(255, 255, 255, 0.02);
}

.upload-dropzone:hover {
  border-color: var(--banana-yellow);
  background-color: rgba(234, 179, 8, 0.04);
}

.dropzone-unselected { display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--text-muted); font-size: 0.85rem; }

.dropzone-selected {
  position: relative;
  display: inline-block;
  max-width: 220px;
}

.dropzone-selected img { width: 100%; border-radius: var(--radius-sm); display: block; }
.remove-dropzone-btn {
  position: absolute; top: -8px; right: -8px; background: #ff5c5c; color: #fff; border: none;
  width: 24px; height: 24px; border-radius: 50%; font-size: 14px; cursor: pointer;
}

/* Galleria Grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.gallery-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s;
}

.gallery-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.gallery-card-img { width: 100%; height: 160px; object-fit: cover; cursor: pointer; }
.gallery-card-info { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.gallery-mode-badge { font-size: 0.65rem; color: var(--banana-yellow); font-weight: 700; text-transform: uppercase; }
.gallery-card-prompt { font-size: 0.78rem; color: var(--text-secondary); line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.gallery-download-btn { font-size: 0.75rem; color: #00d2ff; text-decoration: none; font-weight: 600; margin-top: 4px; }

/* ==========================================================================
   MODAL AUTENTICAZIONE & RECUPERO PASSWORD
   ========================================================================== */
.auth-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-modal-overlay.open { display: flex; }

.auth-modal-card {
  width: 100%;
  max-width: 420px;
  background-color: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 30px;
  box-shadow: var(--shadow-lg);
  position: relative;
  animation: scaleInModal 0.25s ease-out;
}

.auth-modal-close {
  position: absolute; top: 16px; right: 18px; background: transparent; border: none;
  font-size: 1.5rem; color: var(--text-muted); cursor: pointer;
}
.auth-modal-close:hover { color: var(--text-main); }

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
}

.auth-tab-btn {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}

.auth-tab-btn.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
}

.auth-form-view { display: none; flex-direction: column; gap: 14px; }
.auth-form-view.active { display: flex; }

.auth-inner-title { font-size: 1.15rem; font-weight: 700; color: var(--text-main); }
.auth-inner-desc { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 6px; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.form-group label { font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); }
.form-group input {
  padding: 10px 14px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

.form-group input:focus { outline: none; border-color: var(--brand-primary); }

.form-sub-links { display: flex; justify-content: flex-end; }
.text-link-btn { background: none; border: none; color: #00d2ff; font-size: 0.78rem; cursor: pointer; text-decoration: underline; }

.primary-auth-btn {
  padding: 11px;
  background: var(--brand-gradient);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
  transition: opacity 0.2s;
}

.primary-auth-btn:hover { opacity: 0.9; }

.auth-alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  margin-bottom: 12px;
}

.auth-alert.error { background-color: rgba(255, 92, 92, 0.15); color: #ff5c5c; border: 1px solid rgba(255, 92, 92, 0.3); }
.auth-alert.success { background-color: rgba(16, 163, 127, 0.15); color: #10a37f; border: 1px solid rgba(16, 163, 127, 0.3); }
.auth-alert.info { background-color: rgba(0, 210, 255, 0.15); color: #00d2ff; border: 1px solid rgba(0, 210, 255, 0.3); }

.reset-link-debug-box {
  padding: 10px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  line-height: 1.4;
  word-break: break-all;
}

/* ==========================================================================
   Pagina Reset Password Standalone
   ========================================================================== */
.auth-page-body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  padding: 20px;
}

.auth-card-standalone {
  width: 100%;
  max-width: 440px;
  background-color: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 34px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.auth-header h2 { font-size: 1.3rem; margin-bottom: 8px; }
.auth-subtitle { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 24px; }
.auth-footer-link { margin-top: 20px; }
.auth-footer-link a { color: #00d2ff; font-size: 0.85rem; text-decoration: underline; }

/* ==========================================================================
   Image Preview Modal
   ========================================================================== */
.image-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
  z-index: 3000;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.image-modal-overlay.open { display: flex; }

.image-modal-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.image-modal-content img {
  max-width: 100%;
  max-height: 75vh;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  border: 1px solid var(--border-color);
}

.image-modal-close {
  position: absolute;
  top: -40px;
  right: 0;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
}

.modal-download-btn {
  background: var(--brand-gradient);
  color: #fff;
  padding: 9px 20px;
  border-radius: var(--radius-pill);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.2s;
}
.modal-download-btn:hover { transform: scale(1.05); }

/* ==========================================================================
   Toast Notifiche
   ========================================================================== */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column;
  gap: 8px; z-index: 4000; pointer-events: none;
}
.toast {
  background-color: var(--bg-surface); color: var(--text-main); border: 1px solid var(--border-color);
  padding: 10px 16px; border-radius: var(--radius-sm); font-size: 0.85rem; box-shadow: var(--shadow-lg);
  animation: slideInToast 0.25s ease forwards; pointer-events: auto;
}
@keyframes slideInToast {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */
@media (max-width: 768px) {
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .close-sidebar-btn { display: flex; }
  .mobile-menu-btn { display: inline-flex; }
  .sidebar-overlay {
    display: none; position: fixed; inset: 0; background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px); z-index: 40;
  }
  .sidebar-overlay.active { display: block; }
  .btn-text-desktop { display: none; }
  .suggestion-grid { grid-template-columns: 1fr; }
  .studio-form-layout { grid-template-columns: 1fr; }
  .welcome-title { font-size: 1.6rem; }
  .current-chat-title { max-width: 140px; }
  .attach-btn-label { display: none; }
}

/* ==========================================================================
   Command Palette Overlay (Ctrl+K)
   ========================================================================== */
.cmd-palette-overlay {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9999 !important;
  background: rgba(3, 4, 8, 0.75) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  display: none !important;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  padding-left: 16px;
  padding-right: 16px;
}

.cmd-palette-overlay.open {
  display: flex !important;
}

.cmd-palette-box {
  width: 100%;
  max-width: 580px;
  background: #0f111a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(0, 210, 255, 0.15);
  overflow: hidden;
  animation: cmdIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.cmd-palette-input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.cmd-palette-input-wrap svg {
  color: #00d2ff;
  flex-shrink: 0;
}

.cmd-palette-input-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
}

.cmd-palette-input-wrap input::placeholder {
  color: #64748b;
}

.cmd-badge {
  font-family: var(--font-mono, monospace);
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.cmd-palette-results {
  max-height: 340px;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cmd-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-radius: 10px;
  text-decoration: none;
  color: #f1f5f9;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.cmd-item:hover,
.cmd-item.active {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.08);
}

.cmd-item.active {
  background: rgba(0, 210, 255, 0.08);
  border-color: rgba(0, 210, 255, 0.2);
}

.cmd-item-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cmd-item-icon.cyan { background: rgba(0, 210, 255, 0.12); color: #00d2ff; }
.cmd-item-icon.blue { background: rgba(56, 189, 248, 0.12); color: #38bdf8; }
.cmd-item-icon.violet { background: rgba(168, 85, 247, 0.12); color: #c084fc; }
.cmd-item-icon.amber { background: rgba(245, 158, 11, 0.12); color: #fbbf24; }

.cmd-item-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cmd-item-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
}

.cmd-item-desc {
  font-size: 0.78rem;
  color: #94a3b8;
}

.cmd-action-tag {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  color: #94a3b8;
}

.cmd-palette-footer {
  padding: 10px 16px;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.75rem;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cmd-palette-footer kbd {
  font-family: var(--font-mono, monospace);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1px 4px;
  border-radius: 3px;
  color: #94a3b8;
}

