/**
 * Agent Diagram - Modern Styles (Modernizzazione Feb 2026)
 * Basato su Platform UI Standards v2.6
 * Segue pattern di Agent_Presentation
 * 
 * ⚠️ IMPORTANTE: Questo file NON deve sovrascrivere componenti standard.
 * Usa solo stili agent-specific. Componenti standard (page-header, buttons, etc.)
 * sono gestiti da Foundation e Components CSS.
 * 
 * Last Update: 2026-01-18 - Rimossi stili deprecati, allineato a Platform-UI-Standards v2.6
 */

:root {
  --code-editor-bg: #1e1e1e;
  --code-editor-text: #d4d4d4;
}

html[data-theme='light'] {
  --code-editor-bg: #f5f5f5;
  --code-editor-text: #333;
}

/* ========================================
   BODY & OVERALL LAYOUT
   ======================================== */
/* Body è gestito da theme-system.css (Foundation) */
/* NON sovrascrivere qui */

/* Hidden utility class */
.hidden {
  display: none !important;
}

/* ========================================
   LOADER OVERLAY (DIAGRAM GENERATION)
   ======================================== */

.diagram-generation-loader {
  display: none;
}

.diagram-generation-loader.active {
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 9999;
  justify-content: center;
  align-items: center;
}

.diagram-generation-loader .loader-overlay {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-xl);
  text-align: center;
  min-width: 300px;
  animation: slideUp 0.3s ease-out;
}

.diagram-generation-loader .loader-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  align-items: center;
}

.diagram-generation-loader .loader-content .spinner {
  font-size: 3rem;
  color: var(--primary);
  animation: spin 1s linear infinite;
}

.diagram-generation-loader .loader-content h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.diagram-generation-loader .loader-content p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin: 0;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

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

/* Dark Theme Support */
html[data-theme='dark'] .diagram-generation-loader .loader-overlay {
  background: var(--bg-surface);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

/* ========================================
   DIAGRAM SHELL
   ======================================== */

.diagram-shell {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  margin-top: var(--space-4);
}

/* ========================================
   PAGE HEADER OVERRIDE (Forza stile standard)
   ======================================== */
/* Forza l'uso dello stile standard da theme-system.css */
/* Sovrascrive eventuali stili deprecati da style-agents.css o altri */

.page-header {
  background: var(--bg-card) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-md) !important;
  padding: var(--space-4) var(--space-6) !important;
  margin-top: var(--space-4) !important;
  margin-bottom: var(--space-6) !important;
  text-align: left !important;
  box-shadow: var(--box-shadow) !important;
  color: var(--text-primary) !important;
}

.page-header::before {
  content: '' !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  height: 3px !important;
  background: var(--gradient-primary) !important;
  border-radius: var(--radius-md) var(--radius-md) 0 0 !important;
}

.page-title {
  font-size: 1.75rem !important;
  font-weight: 700 !important;
  color: var(--primary) !important;
  margin: 0 0 var(--space-1) 0 !important;
  display: flex !important;
  align-items: center !important;
  gap: var(--space-2) !important;
}

.page-title i {
  color: var(--primary) !important;
  font-size: 1.5rem !important;
  text-shadow: none !important;
}

.page-subtitle {
  font-size: var(--font-size-base) !important;
  color: var(--text-secondary) !important;
  margin: 0 !important;
  font-weight: 400 !important;
  line-height: 1.5 !important;
}

/* ========================================
   HERO INPUT SECTION
   ======================================== */

.hero-input-section {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-4);
}

.input-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.input-wrapper {
  position: relative;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 2px solid var(--border-color);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.attach-status {
  min-height: 20px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding-left: 4px;
}

.attach-status.is-active {
  color: var(--success, #22c55e);
}

.input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--bg-primary-subtle);
}

.main-input {
  width: 100%;
  min-height: 100px;
  padding: var(--space-4);
  padding-right: 100px;
  border: none;
  outline: none;
  background: transparent;
  font-size: var(--font-size-lg);
  color: var(--text-primary);
  resize: vertical;
  font-family: inherit;
  line-height: 1.6;
}

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

.input-actions {
  position: absolute;
  right: var(--space-3);
  top: var(--space-3);
  display: flex;
  gap: var(--space-2);
}

/* Microfono in registrazione (Speech Recognition) */
#diagram-mic-btn.recording {
  color: var(--danger, #dc3545) !important;
  animation: pulse-recording 1.5s ease-in-out infinite;
}
@keyframes pulse-recording {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* btn-icon è gestito da buttons.css (Components) */
/* NON sovrascrivere qui - usa solo la classe standard */

.input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.prompt-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  flex: 1;
}

.suggestion-chip {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-4);
  background: var(--bg-card);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.suggestion-chip:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--bg-primary-subtle);
  transform: translateY(-1px);
}

/* ========================================
   STEP CARD SYSTEM
   ======================================== */
/* Step cards sono gestite da workflow.css (Components) */
/* Manteniamo solo animazioni specifiche se necessario */

.config-card.step-card {
  animation: fadeInUp 0.6s ease-out;
}

.config-card.step-card:nth-child(2) { animation-delay: 0.1s; }
.config-card.step-card:nth-child(3) { animation-delay: 0.2s; }
.config-card.step-card:nth-child(4) { animation-delay: 0.3s; }

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

/* ========================================
   OPTIONS GRID (Configuration)
   ======================================== */

.options-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.option-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.option-group label {
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
}

/* Select è gestito da forms.css (Components) */
/* NON sovrascrivere qui */

/* ========================================
   CODE EDITOR
   ======================================== */

.code-editor-container {
  background: var(--code-editor-bg);
  color: var(--code-editor-text);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  font-family: 'Courier New', monospace;
  font-size: 0.875rem;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ========================================
   ADVANCED OPTIONS (Collapsible)
   ======================================== */
/* options-toggle e options-content sono gestiti da forms.css (Components) */
/* NON sovrascrivere qui */

/* ========================================
   PREVIEW CONTAINER
   ======================================== */

.preview-container {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  min-height: 300px;
  max-height: 600px;
  padding: var(--space-5);
  background: var(--bg-surface);
  overflow: auto;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-container.has-content {
  border-color: var(--success);
  background: var(--bg-card);
  border-style: solid;
}

.preview-container img,
.preview-container svg {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius-md);
}

/* ========================================
   DOWNLOAD ACTIONS
   ======================================== */

.download-actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* ========================================
   TEMPLATES / EXAMPLES SECTION
   ======================================== */

.templates-section {
  margin-top: var(--space-8);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 2px solid var(--border-color);
}

.section-title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  margin: 0;
}

.section-title i {
  color: var(--primary);
}

.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
}

.template-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.template-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
}

.template-card-icon {
  font-size: 2rem;
}

.template-card h5 {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin: 0;
}

.template-card p {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin: 0;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* Tablet (≤768px) */
@media (max-width: 768px) {
  .input-footer {
    flex-direction: column;
    width: 100%;
  }

  .prompt-suggestions {
    width: 100%;
  }

  .options-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* step-header e step-content sono gestiti da workflow.css */

  .templates-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}

/* Mobile (≤480px) */
@media (max-width: 480px) {
  .hero-input-section {
    padding: var(--space-4);
  }

  .input-wrapper {
    flex-direction: column;
  }

  .main-input {
    padding-right: var(--space-4);
  }

  .input-actions {
    position: static;
    justify-content: flex-start;
    margin-top: var(--space-2);
  }

  /* btn-icon è gestito da buttons.css */

  .options-grid {
    grid-template-columns: 1fr;
  }

  /* step-card e step-badge sono gestiti da workflow.css */

  .preview-container {
    min-height: 200px;
    max-height: 400px;
  }

  .templates-grid {
    grid-template-columns: 1fr;
  }

  .input-footer {
    gap: var(--space-2);
  }
}

/* ========================================
   DARK THEME ADJUSTMENTS
   ======================================== */

html[data-theme='dark'] .preview-container img,
html[data-theme='dark'] .preview-container svg {
  background: white;
  padding: var(--space-2);
  border-radius: var(--radius-md);
}

html[data-theme='dark'] .code-editor-container {
  background: #252526;
  color: #d4d4d4;
}
