/* ============================================
   GRAPH Suite — Reusable Components
   ACG Suite — Design System Centralizzato
   ============================================ */

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-primary,
.btn--primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}
.btn-primary:hover,
.btn--primary:hover:not(:disabled) { opacity: 0.9; }

.btn-secondary,
.btn--secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}
.btn-secondary:hover,
.btn--secondary:hover:not(:disabled) { background: hsl(var(--muted)); }

.btn-destructive {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}

.btn-outline,
.btn--outline {
  background: transparent;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
}
.btn-outline:hover,
.btn--outline:hover:not(:disabled) { background: hsl(var(--muted)); }

.btn-ghost {
  background: transparent;
  color: hsl(var(--foreground));
}
.btn-ghost:hover { background: hsl(var(--muted)); }

.btn--accent {
  background: hsl(25 95% 53%);
  color: white;
}
.btn--accent:hover:not(:disabled) { opacity: 0.9; }

.btn--success {
  background: hsl(var(--success));
  color: white;
}

.btn-sm,
.btn--sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn--block { width: 100%; justify-content: center; }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn:active:not(:disabled) { transform: scale(0.97); }

.btn--icon {
  padding: 6px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
  min-width: 32px;
  min-height: 32px;
  justify-content: center;
}
.btn--icon:hover:not(:disabled) { background: hsl(var(--muted)); color: hsl(var(--foreground)); }

.btn-group {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

/* ---- Cards ---- */
.card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
}
.card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Compat */
.card--clickable { cursor: pointer; }
.card--clickable:hover { box-shadow: var(--shadow-card-hover); border-color: hsl(var(--primary)); }
.card--selected { border: 2px solid hsl(var(--primary)); background: hsl(var(--info-light)); }

.card-header,
.card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}
.card__header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title,
.card__title {
  font-size: 14px;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
}
.card-title-large {
  font-size: 16px;
  font-weight: 600;
  color: hsl(var(--foreground));
}
.card__subtitle,
.card-description {
  font-size: 14px;
  color: hsl(var(--muted-foreground));
  margin-top: 4px;
}
.card__badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.card-icon {
  color: hsl(var(--muted-foreground));
}
.card-value {
  font-size: 28px;
  font-weight: 700;
  color: hsl(var(--foreground));
  line-height: 1.2;
}
.card-trend {
  font-size: 12px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.card-trend.positive { color: hsl(var(--success)); }
.card-trend.negative { color: hsl(var(--error)); }

/* ---- Stats Grid ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
}
.stat-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.stat-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}
.stat-label,
.stat-card__label {
  font-size: 13px;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
}
.stat-icon { color: hsl(var(--muted-foreground)); }
.stat-value,
.stat-card__value {
  font-size: 28px;
  font-weight: 700;
  color: hsl(var(--foreground));
  line-height: 1.2;
}
.stat-value.success { color: hsl(var(--success)); }
.stat-value.warning { color: hsl(var(--warning)); }
.stat-value.error { color: hsl(var(--error)); }
.stat-description {
  font-size: 12px;
  color: hsl(var(--muted-foreground));
  margin-top: 4px;
}
.stat-trend {
  font-size: 12px;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.stat-trend.positive { color: hsl(var(--success)); }
.stat-trend.negative { color: hsl(var(--error)); }

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
}
.badge-default,
.badge--default { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.badge-primary,
.badge--default { background: hsl(var(--primary) / 0.1); color: hsl(var(--primary)); }
.badge-success,
.badge--success { background: hsl(var(--success) / 0.1); color: hsl(var(--success)); }
.badge-warning,
.badge--warning { background: hsl(var(--warning) / 0.1); color: hsl(var(--warning)); }
.badge-error,
.badge--error { background: hsl(var(--error) / 0.1); color: hsl(var(--error)); }
.badge-info { background: hsl(var(--info) / 0.1); color: hsl(var(--info)); }
.badge--accent { background: hsl(25 95% 53% / 0.1); color: hsl(25 95% 53%); }
.badge--muted { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }
.badge-purple { background: hsl(270 70% 50% / 0.1); color: hsl(270 70% 50%); }
.badge-orange { background: hsl(25 95% 53% / 0.1); color: hsl(25 95% 53%); }

/* ---- Tab Bar ---- */
.tab-bar {
  display: flex;
  gap: 2px;
  background: hsl(var(--muted));
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 16px;
}
.tab-bar__item {
  flex: 1;
  padding: 8px 12px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s;
  background: transparent;
  color: hsl(var(--muted-foreground));
  font-family: inherit;
  text-align: center;
}
.tab-bar__item:hover { color: hsl(var(--foreground)); }
.tab-bar__item--active {
  background: hsl(var(--card));
  color: hsl(var(--primary));
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ---- Forms ---- */
.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  box-sizing: border-box;
  transition: all 0.2s;
}
.input:focus {
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 3px hsl(var(--primary) / 0.1);
}
.input--sm { padding: 6px 8px; font-size: 12px; border-radius: 6px; }
.input--with-icon { padding-left: 36px; }

.input-group { margin-bottom: 12px; }
.input-group__label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  margin-bottom: 4px;
}

select.input { appearance: auto; cursor: pointer; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group label {
  font-size: 14px;
  font-weight: 500;
  color: hsl(var(--foreground));
}
.form-group select,
.form-group input,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  transition: all 0.2s;
}
.form-group select:focus,
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 3px hsl(var(--primary) / 0.1);
}

.checkbox-group {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}
.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}
.checkbox-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: hsl(var(--primary));
}

/* ---- Table ---- */
.table-container { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid hsl(var(--primary));
  color: hsl(var(--primary));
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.table td {
  padding: 10px 12px;
  font-weight: 500;
  border-bottom: 1px solid hsl(var(--border));
}
.table tbody tr:hover { background: hsl(var(--muted) / 0.5); }
.table th.text-center,
.table td.text-center { text-align: center; }
.table th.text-right,
.table td.text-right { text-align: right; }

/* ---- Modal / Dialog ---- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 40px 0;
}
.modal-overlay.active,
.modal-overlay--active {
  display: flex;
}
.modal {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  padding: 24px;
  max-width: 560px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}
.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid hsl(var(--border));
}
.modal__title {
  font-size: 18px;
  font-weight: 600;
  color: hsl(var(--foreground));
  display: flex;
  align-items: center;
  gap: 10px;
}
.modal__body { padding: 0; }
.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 0 0;
  margin-top: 20px;
  border-top: 1px solid hsl(var(--border));
}

/* Detail grid (inside modals) */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.detail-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
}
.detail-value {
  font-size: 14px;
  color: hsl(var(--foreground));
}

/* ---- Toast / Notifications ---- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideIn 0.3s ease;
  font-size: 14px;
  color: hsl(var(--foreground));
}
.toast.success,
.toast--success { border-left: 4px solid hsl(var(--success)); }
.toast.error,
.toast--error { border-left: 4px solid hsl(var(--error)); }
.toast.info,
.toast--info { border-left: 4px solid hsl(var(--primary)); }
.toast.warning,
.toast--warning { border-left: 4px solid hsl(var(--warning)); }
.toast--exiting { animation: slideOut 0.3s ease forwards; }
@keyframes slideOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(40px); } }

/* ---- Alert (inline) ---- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  border-left: 3px solid;
  font-size: 13px;
  line-height: 1.5;
}
.alert--info,
.alert.info { background: hsl(var(--info-light)); border-left-color: hsl(var(--info)); color: hsl(var(--muted-foreground)); }
.alert--success,
.alert.success { background: hsl(var(--success-light)); border-left-color: hsl(var(--success)); color: hsl(var(--muted-foreground)); }
.alert--warning,
.alert.warning { background: hsl(var(--warning-light)); border-left-color: hsl(var(--warning)); color: hsl(var(--muted-foreground)); }
.alert--error,
.alert.error { background: hsl(var(--error-light)); border-left-color: hsl(var(--error)); color: hsl(var(--muted-foreground)); }
.alert__title { font-weight: 700; margin-bottom: 4px; font-size: 13px; }

/* ---- Section Title ---- */
.section-title {
  font-size: 16px;
  font-weight: 600;
  color: hsl(var(--foreground));
  margin-bottom: 12px;
}
.section-title--sm { font-size: 13px; }

/* ---- Group Label ---- */
.group-label {
  font-size: 11px;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ---- Grid Layouts ---- */
.grid { display: grid; gap: 12px; }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }
.grid--auto-fill { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* ---- Quick Actions ---- */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.action-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 16px 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}
.action-card:hover {
  background: hsl(var(--accent));
  border-color: hsl(var(--border));
}
.action-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: hsl(var(--primary) / 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: hsl(var(--primary));
}
.action-content { flex: 1; min-width: 0; }
.action-title { font-weight: 500; font-size: 14px; margin-bottom: 2px; }
.action-desc { font-size: 13px; color: hsl(var(--muted-foreground)); }

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: hsl(var(--muted-foreground));
}
.empty-state__icon { margin-bottom: 8px; }
.empty-state__text { font-size: 13px; }

/* ---- Search input with icon ---- */
.search-wrapper {
  position: relative;
  flex: 1 1 240px;
}
.search-wrapper__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: hsl(var(--muted-foreground));
  pointer-events: none;
}

/* ---- Filter Pills ---- */
.filter-pills {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.filter-pill {
  padding: 6px 14px;
  border-radius: 9999px;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  transition: all 0.2s;
  font-family: inherit;
}
.filter-pill:hover { color: hsl(var(--foreground)); }
.filter-pill--active {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

/* ---- Loading Spinner ---- */
.spinner,
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid hsl(var(--muted));
  border-top-color: hsl(var(--primary));
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner { width: 64px; height: 64px; border-width: 3px; margin: 0 auto; }
.loading-spinner.lg { width: 32px; height: 32px; border-width: 3px; }
.loading-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

/* ---- Code Block ---- */
.code-block,
.log-console {
  background: hsl(222.2 84% 4.9%);
  color: #E8E8E8;
  padding: 16px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.6;
  overflow: auto;
  max-height: 400px;
  font-family: var(--font-mono);
  white-space: pre-wrap;
  word-break: break-word;
}
.log-console { height: 350px; max-height: none; }
.log-line { padding: 2px 0; }
.log-time { color: hsl(215 20.2% 45%); }
.log-info { color: hsl(199 89% 48%); }
.log-success { color: hsl(142 71% 45%); }
.log-error { color: hsl(0 84% 60%); }
.log-warning { color: hsl(45 93% 47%); }

/* ---- Drop Zone ---- */
.drop-zone {
  border: 2px dashed hsl(var(--border));
  border-radius: var(--radius);
  padding: 50px 40px;
  text-align: center;
  cursor: pointer;
  background: hsl(var(--muted) / 0.3);
  transition: all 0.3s;
}
.drop-zone--active,
.drop-zone.active {
  border-color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.1);
}

/* ---- Context Menu ---- */
.context-menu {
  position: fixed;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  z-index: 10000;
  min-width: 180px;
  padding: 6px 0;
  display: none;
}
.context-menu.visible { display: block; }
.context-menu-item {
  padding: 10px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: hsl(var(--foreground));
  transition: background 0.15s;
}
.context-menu-item:hover { background: hsl(var(--muted) / 0.5); }
.context-menu-separator {
  height: 1px;
  background: hsl(var(--border));
  margin: 6px 0;
}
.context-menu-header {
  padding: 8px 16px 4px;
  font-size: 11px;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ---- Company color dot (compat) ---- */
.company-dot {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 7px;
  font-weight: 800;
  flex-shrink: 0;
}

/* ---- Logo placeholder (compat) ---- */
.logo-box {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  color: #fff;
  font-weight: 800;
  flex-shrink: 0;
}
.logo-box--sm { width: 36px; height: 36px; font-size: 13px; }
.logo-box--md { width: 42px; height: 42px; font-size: 14px; }
.logo-box--lg { width: 48px; height: 48px; font-size: 16px; }

/* ---- A4 Preview Container (compat) ---- */
.a4-container {
  background: hsl(var(--muted));
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  justify-content: center;
  overflow: auto;
}
.a4-page {
  width: 470px;
  min-height: 660px;
  background: #fff;
  box-shadow: var(--shadow-lg);
  font-family: var(--font-primary);
  font-size: 11px;
  position: relative;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; }
  .modal { width: 95%; max-width: none; }
  .detail-grid { grid-template-columns: 1fr; }
}
