/* ================================================================
   GEMMA.CSS — Design System Interno · Blue Arroyo srl
   Il sistema operativo di Blue Arroyo
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;1,300;1,400&family=Inter:wght@300;400;500;600;700&display=swap');

/* ── DESIGN TOKENS ───────────────────────────────────────────── */
:root {
  /* Palette */
  --g-bg:            #09090d;
  --g-surface:       #111118;
  --g-surface-2:     #18181f;
  --g-surface-3:     #1e1e28;
  --g-border:        rgba(255,255,255,0.07);
  --g-border-mid:    rgba(255,255,255,0.12);

  /* Brand */
  --g-brass:         #B8924A;
  --g-brass-light:   #d4ac6a;
  --g-brass-dim:     rgba(184,146,74,0.12);
  --g-brass-border:  rgba(184,146,74,0.25);
  --g-cream:         #F5F1E8;
  --g-charcoal:      #1A1A1A;

  /* Text */
  --g-text:          #eaeaea;
  --g-text-mid:      rgba(234,234,234,0.6);
  --g-text-low:      rgba(234,234,234,0.35);

  /* Status */
  --g-success:       #34a853;
  --g-success-bg:    rgba(52,168,83,0.12);
  --g-warning:       #fbbc05;
  --g-warning-bg:    rgba(251,188,5,0.12);
  --g-danger:        #ea4335;
  --g-danger-bg:     rgba(234,67,53,0.12);
  --g-info:          #4285f4;
  --g-info-bg:       rgba(66,133,244,0.12);

  /* Typography */
  --g-font-heading:  'Cormorant Garamond', Georgia, serif;
  --g-font-body:     'Inter', system-ui, -apple-system, sans-serif;

  /* Layout */
  --g-sidebar-w:     256px;
  --g-header-h:      56px;
  --g-radius:        8px;
  --g-radius-lg:     14px;

  /* Shadows */
  --g-shadow-sm:     0 2px 8px rgba(0,0,0,0.3);
  --g-shadow:        0 4px 20px rgba(0,0,0,0.4);
  --g-shadow-lg:     0 12px 40px rgba(0,0,0,0.5);

  /* Transitions */
  --g-ease:          cubic-bezier(0.4, 0, 0.2, 1);
  --g-dur:           180ms;
}

/* ── RESET ───────────────────────────────────────────────────── */
.gemma-scope *, .gemma-scope *::before, .gemma-scope *::after {
  box-sizing: border-box;
}

/* ── GEMMA TOPBAR ─────────────────────────────────────────────
   Barra superiore presente in ogni tool interno Gemma.
   Uso: <header class="g-topbar"> ... </header>
   ─────────────────────────────────────────────────────────── */
.g-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--g-header-h);
  background: var(--g-surface);
  border-bottom: 1px solid var(--g-border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 200;
  gap: 16px;
}

.g-topbar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.g-topbar__drop {
  width: 28px;
  height: 28px;
  object-fit: contain;
  mix-blend-mode: normal;
  filter: brightness(1.1);
}

.g-topbar__wordmark {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.g-topbar__name {
  font-family: var(--g-font-heading);
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--g-text);
  letter-spacing: 0.04em;
}

.g-topbar__sub {
  font-size: 0.57rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--g-brass);
  margin-top: 2px;
}

.g-topbar__divider {
  width: 1px;
  height: 20px;
  background: var(--g-border-mid);
  flex-shrink: 0;
}

.g-topbar__title {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--g-text-mid);
  letter-spacing: 0.02em;
}

.g-topbar__spacer { flex: 1; }

.g-topbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── SIDEBAR ──────────────────────────────────────────────────
   Layout a sidebar (con topbar Gemma sopra).
   Uso: <aside class="g-sidebar"> ... </aside>
   ─────────────────────────────────────────────────────────── */
.g-sidebar {
  position: fixed;
  top: var(--g-header-h);
  left: 0;
  bottom: 0;
  width: var(--g-sidebar-w);
  background: var(--g-surface);
  border-right: 1px solid var(--g-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 100;
}

.g-sidebar__section {
  padding: 6px 10px;
  border-bottom: 1px solid var(--g-border);
}

.g-sidebar__label {
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--g-text-low);
  padding: 14px 10px 6px;
  display: block;
}

.g-sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  font-size: 0.825rem;
  font-weight: 400;
  color: var(--g-text-mid);
  text-decoration: none;
  transition: background var(--g-dur) var(--g-ease), color var(--g-dur) var(--g-ease);
  cursor: pointer;
}

.g-sidebar__link:hover {
  background: var(--g-surface-3);
  color: var(--g-text);
}

.g-sidebar__link.active {
  background: var(--g-brass-dim);
  color: var(--g-brass-light);
  font-weight: 500;
}

.g-sidebar__link svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.g-sidebar__badge {
  margin-left: auto;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 100px;
  background: var(--g-brass-dim);
  color: var(--g-brass);
  letter-spacing: 0.06em;
}

/* ── MAIN CONTENT ─────────────────────────────────────────────
   Area principale con topbar e sidebar.
   ─────────────────────────────────────────────────────────── */
.g-main {
  margin-top: var(--g-header-h);
  margin-left: var(--g-sidebar-w);
  min-height: calc(100vh - var(--g-header-h));
  background: var(--g-bg);
  padding: 28px 28px 60px;
}

.g-main--no-sidebar {
  margin-left: 0;
}

/* ── PAGE HEADER ──────────────────────────────────────────────*/
.g-page-header {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--g-border);
}

.g-page-eyebrow {
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--g-brass);
  font-weight: 600;
  margin-bottom: 6px;
}

.g-page-title {
  font-family: var(--g-font-heading);
  font-size: 1.8rem;
  font-weight: 400;
  color: var(--g-text);
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.g-page-subtitle {
  font-size: 0.825rem;
  color: var(--g-text-mid);
  margin-top: 6px;
  line-height: 1.5;
}

/* ── CARDS ────────────────────────────────────────────────────*/
.g-card {
  background: var(--g-surface);
  border: 1px solid var(--g-border);
  border-radius: var(--g-radius-lg);
  padding: 24px;
}

.g-card + .g-card { margin-top: 16px; }

.g-card__title {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--g-brass);
  margin-bottom: 18px;
}

.g-card__body {
  font-size: 0.875rem;
  color: var(--g-text-mid);
  line-height: 1.6;
}

/* Grid helpers */
.g-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.g-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.g-grid-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 16px; }

/* ── STAT CARD ────────────────────────────────────────────────*/
.g-stat {
  background: var(--g-surface);
  border: 1px solid var(--g-border);
  border-radius: var(--g-radius-lg);
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
}

.g-stat::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--g-brass), transparent);
  opacity: 0.4;
}

.g-stat__label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--g-text-low);
  margin-bottom: 8px;
}

.g-stat__value {
  font-family: var(--g-font-heading);
  font-size: 2rem;
  font-weight: 400;
  color: var(--g-text);
  line-height: 1;
}

.g-stat__sub {
  font-size: 0.72rem;
  color: var(--g-text-low);
  margin-top: 4px;
}

/* ── BUTTONS ──────────────────────────────────────────────────*/
.g-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--g-radius);
  font-family: var(--g-font-body);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--g-dur) var(--g-ease);
  border: none;
  text-decoration: none;
  white-space: nowrap;
}

.g-btn--primary {
  background: linear-gradient(135deg, var(--g-brass), var(--g-brass-light));
  color: #000;
  box-shadow: 0 4px 16px rgba(184,146,74,0.25);
}
.g-btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(184,146,74,0.35);
}

.g-btn--ghost {
  background: transparent;
  color: var(--g-text-mid);
  border: 1px solid var(--g-border-mid);
}
.g-btn--ghost:hover {
  background: var(--g-surface-2);
  color: var(--g-text);
  border-color: var(--g-border-mid);
}

.g-btn--danger {
  background: var(--g-danger-bg);
  color: var(--g-danger);
  border: 1px solid rgba(234,67,53,0.2);
}
.g-btn--danger:hover {
  background: rgba(234,67,53,0.2);
}

.g-btn--sm { padding: 6px 12px; font-size: 0.72rem; }
.g-btn--lg { padding: 12px 24px; font-size: 0.9rem; }
.g-btn--full { width: 100%; justify-content: center; }

.g-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── BADGES ───────────────────────────────────────────────────*/
.g-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.g-badge--success { background: var(--g-success-bg); color: var(--g-success); }
.g-badge--warning { background: var(--g-warning-bg); color: var(--g-warning); }
.g-badge--danger  { background: var(--g-danger-bg);  color: var(--g-danger);  }
.g-badge--info    { background: var(--g-info-bg);    color: var(--g-info);    }
.g-badge--brass   { background: var(--g-brass-dim);  color: var(--g-brass);   }
.g-badge--neutral { background: rgba(255,255,255,0.07); color: var(--g-text-mid); }

/* ── FORMS ────────────────────────────────────────────────────*/
.g-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.g-field + .g-field { margin-top: 14px; }

.g-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--g-text-mid);
  letter-spacing: 0.04em;
}

.g-input,
.g-select,
.g-textarea {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--g-border-mid);
  border-radius: var(--g-radius);
  padding: 10px 14px;
  color: var(--g-text);
  font-family: var(--g-font-body);
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--g-dur) var(--g-ease), background var(--g-dur) var(--g-ease);
  width: 100%;
}

.g-input:focus,
.g-select:focus,
.g-textarea:focus {
  border-color: var(--g-brass-border);
  background: var(--g-brass-dim);
}

.g-input::placeholder { color: var(--g-text-low); }
.g-textarea { resize: vertical; min-height: 80px; }
.g-select option { background: var(--g-surface-2); }

.g-hint {
  font-size: 0.68rem;
  color: var(--g-text-low);
  line-height: 1.5;
}

/* ── TABLE ────────────────────────────────────────────────────*/
.g-table-wrap {
  overflow-x: auto;
  border-radius: var(--g-radius-lg);
  border: 1px solid var(--g-border);
}

.g-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.825rem;
}

.g-table th {
  background: var(--g-surface-2);
  padding: 11px 16px;
  text-align: left;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--g-text-low);
  border-bottom: 1px solid var(--g-border);
  white-space: nowrap;
}

.g-table td {
  padding: 12px 16px;
  color: var(--g-text-mid);
  border-bottom: 1px solid var(--g-border);
}

.g-table tr:last-child td { border-bottom: none; }

.g-table tr:hover td {
  background: var(--g-surface-2);
  color: var(--g-text);
}

/* ── MODAL ────────────────────────────────────────────────────*/
.g-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.g-modal {
  background: var(--g-surface);
  border: 1px solid var(--g-border-mid);
  border-radius: var(--g-radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--g-shadow-lg);
  position: relative;
}

.g-modal__header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--g-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.g-modal__title {
  font-family: var(--g-font-heading);
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--g-text);
}

.g-modal__close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: none;
  border: 1px solid var(--g-border);
  color: var(--g-text-mid);
  cursor: pointer;
  transition: all var(--g-dur) var(--g-ease);
  font-size: 1rem;
}
.g-modal__close:hover { background: var(--g-surface-3); color: var(--g-text); }

.g-modal__body { padding: 20px 24px; }
.g-modal__footer {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--g-border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── STATUS DOTS ──────────────────────────────────────────────*/
.g-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.g-dot--success { background: var(--g-success); box-shadow: 0 0 6px var(--g-success); }
.g-dot--warning { background: var(--g-warning); box-shadow: 0 0 6px var(--g-warning); animation: g-pulse 2s ease infinite; }
.g-dot--danger  { background: var(--g-danger);  box-shadow: 0 0 6px var(--g-danger);  }
.g-dot--neutral { background: var(--g-text-low); }

@keyframes g-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ── DIVIDER ──────────────────────────────────────────────────*/
.g-divider {
  height: 1px;
  background: var(--g-border);
  margin: 20px 0;
}

/* ── ALERT BANNER ─────────────────────────────────────────────*/
.g-alert {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--g-radius);
  font-size: 0.8rem;
  line-height: 1.5;
  margin-bottom: 16px;
}
.g-alert--danger  { background: var(--g-danger-bg);  border-left: 3px solid var(--g-danger);  color: #ff8a7a; }
.g-alert--warning { background: var(--g-warning-bg); border-left: 3px solid var(--g-warning); color: #fcd45f; }
.g-alert--success { background: var(--g-success-bg); border-left: 3px solid var(--g-success); color: #6fcf87; }
.g-alert--info    { background: var(--g-info-bg);    border-left: 3px solid var(--g-info);    color: #82b0f7; }

/* ── UTILITY ──────────────────────────────────────────────────*/
.g-flex         { display: flex; align-items: center; }
.g-flex-between { display: flex; align-items: center; justify-content: space-between; }
.g-gap-sm       { gap: 8px; }
.g-gap          { gap: 12px; }
.g-gap-lg       { gap: 20px; }
.g-mt-sm        { margin-top: 8px; }
.g-mt           { margin-top: 16px; }
.g-mt-lg        { margin-top: 28px; }
.g-mb-sm        { margin-bottom: 8px; }
.g-mb           { margin-bottom: 16px; }
.g-text-sm      { font-size: 0.78rem; }
.g-text-muted   { color: var(--g-text-mid); }
.g-text-brass   { color: var(--g-brass); }
.g-monospace    { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 0.8rem; }

/* ── LOGIN CARD (per tool interni protetti) ───────────────────*/
.g-login-backdrop {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, var(--g-surface) 0%, var(--g-bg) 100%);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  transition: opacity 400ms var(--g-ease), visibility 400ms;
}

.g-login-backdrop.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.g-login-card {
  background: var(--g-surface);
  border: 1px solid var(--g-brass-border);
  border-radius: var(--g-radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--g-shadow-lg);
  position: relative;
}

.g-login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 10%; right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--g-brass), transparent);
}

.g-login-brand {
  text-align: center;
  margin-bottom: 32px;
}

.g-login-logo {
  font-family: var(--g-font-heading);
  font-size: 2rem;
  font-weight: 400;
  color: var(--g-text);
  letter-spacing: 0.04em;
}

.g-login-sub {
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--g-brass);
  margin-top: 4px;
}

.g-login-drop {
  width: 40px;
  height: 40px;
  object-fit: contain;
  display: block;
  margin: 0 auto 12px;
  filter: brightness(1.05);
  mix-blend-mode: normal;
}

/* ── SCROLLBAR ────────────────────────────────────────────────*/
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 100px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
