/*
 * styles.css — JR Multiservizi component styles
 *
 * Built on top of tokens.css. Faithful to design/poc.html.
 * Organized: reset → layout → sidebar → main → components → login → responsive.
 */

@import url('tokens.css');

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Base ───────────────────────────────────────────────────────────────────── */
html { height: 100%; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: var(--text-base);
  line-height: 1.5;
  min-height: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: var(--font-sans);
  cursor: pointer;
}

/* ── App root ───────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--text);   /* dark nav — matches POC */
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition-mid);
}

.sidebar-logo {
  padding: var(--space-6) var(--space-5) var(--space-5);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.logo-name {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.3px;
  color: #fff;
}

.logo-sub {
  font-size: var(--text-xs);
  color: rgba(255, 255, 255, 0.4);
  margin-top: 2px;
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-3) 0;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.3);
  padding: var(--space-4) var(--space-5) var(--space-1) var(--space-5);
  font-family: var(--font-mono);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px var(--space-5);
  cursor: pointer;
  color: rgba(255, 255, 255, 0.6);
  font-size: 13.5px;
  font-weight: var(--weight-normal);
  border-left: 3px solid transparent;
  transition: all var(--transition-fast);
  user-select: none;
  text-decoration: none;
}

.nav-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.nav-item.active {
  color: #fff;
  border-left-color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
  font-weight: var(--weight-medium);
}

.nav-icon {
  font-size: 15px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: var(--text-sm);
  color: rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.sidebar-user {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.btn-logout {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  padding: 3px var(--space-2);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  font-family: var(--font-sans);
}

.btn-logout:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.5);
}

/* Mobile sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 99;
}

/* ── Main area ──────────────────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px var(--space-7);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: var(--space-3);
}

.topbar-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.2px;
}

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

/* Hamburger (mobile only — hidden on desktop) */
.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  padding: var(--space-1);
  line-height: 1;
  cursor: pointer;
}

.content {
  padding: var(--space-7);
  flex: 1;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  padding: 7px var(--space-4);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-sans);
  font-weight: var(--weight-medium);
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface2);
  color: var(--text);
}

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
}

.btn-danger:hover:not(:disabled) {
  background: var(--red);
  color: #fff;
}

/* ── Stat cards ─────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-7);
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.stat-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: var(--space-2);
}

.stat-value {
  font-size: 28px;
  font-weight: var(--weight-semibold);
  letter-spacing: -1px;
  line-height: 1;
}

.stat-sub {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.stat-accent { color: var(--accent); }
.stat-green  { color: var(--green); }
.stat-orange { color: var(--orange); }
.stat-red    { color: var(--red); }

/* ── Two-column layout ──────────────────────────────────────────────────────── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: var(--space-5);
}

/* ── Card ───────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-title {
  font-size: 13px;
  font-weight: var(--weight-semibold);
}

.card-body {
  padding: 0;
}

/* ── Table ──────────────────────────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  padding: 10px var(--space-5);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-weight: var(--weight-medium);
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition-fast);
}

tbody tr:last-child {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--surface2);
}

tbody td {
  padding: 11px var(--space-5);
  font-size: var(--text-base);
}

.client-name {
  font-weight: var(--weight-medium);
}

.client-meta {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.badge-green  { background: var(--green-light);  color: var(--green); }
.badge-orange { background: var(--orange-light); color: var(--orange); }
.badge-blue   { background: var(--accent-light); color: var(--accent); }
.badge-red    { background: var(--red-light);    color: var(--red); }

/* ── Search bar ─────────────────────────────────────────────────────────────── */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  align-items: center;
}

.search-input {
  flex: 1;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  background: var(--surface);
  outline: none;
  color: var(--text);
  transition: border-color var(--transition-fast);
}

.search-input:focus {
  border-color: var(--accent);
}

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

/* ── Filter pills ───────────────────────────────────────────────────────────── */
.pag-filters {
  display: flex;
  gap: var(--space-2);
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.filter-pill {
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: var(--weight-medium);
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  transition: all var(--transition-fast);
  user-select: none;
}

.filter-pill.active,
.filter-pill:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Activity feed ──────────────────────────────────────────────────────────── */
.activity-item {
  padding: 13px var(--space-5);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

.dot-green  { background: var(--green); }
.dot-orange { background: var(--orange); }
.dot-blue   { background: var(--accent); }

.activity-text {
  font-size: 13px;
  line-height: 1.4;
}

.activity-time {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
  font-family: var(--font-mono);
}

/* ── Payment toggle ─────────────────────────────────────────────────────────── */
.pago-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--surface2);
  border-radius: var(--radius-md);
  padding: 14px var(--space-4);
  margin-bottom: var(--space-4);
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition-fast);
}

.pago-toggle:hover {
  border-color: var(--accent);
}

.pago-toggle.pagato {
  border-color: var(--green);
  background: var(--green-light);
}

.pago-toggle-icon {
  font-size: 22px;
}

.pago-toggle-text {
  flex: 1;
}

.pago-toggle-title {
  font-weight: var(--weight-semibold);
  font-size: var(--text-md);
}

.pago-toggle-sub {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: 1px;
}

/* ── Slide-in modal panel ───────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 200;
  align-items: flex-start;
  justify-content: flex-end;
}

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

.modal-panel {
  background: var(--surface);
  width: 480px;
  max-width: 100vw;
  height: 100vh;
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
  animation: slideInPanel 0.2s ease;
}

@keyframes slideInPanel {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.modal-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.modal-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  padding: var(--space-1);
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  padding: var(--space-6);
}

/* ── Info section (inside modal) ────────────────────────────────────────────── */
.info-section {
  margin-bottom: var(--space-6);
}

.info-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: var(--space-3);
}

.info-row {
  display: flex;
  justify-content: space-between;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-base);
  gap: var(--space-3);
}

.info-row:last-child {
  border-bottom: none;
}

.info-key {
  color: var(--text-muted);
  flex-shrink: 0;
}

.info-val {
  font-weight: var(--weight-medium);
  text-align: right;
}

/* ── Document items (inside modal) ──────────────────────────────────────────── */
.doc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px var(--space-3);
  border: 1px solid var(--border);
  border-radius: 7px;
  margin-bottom: var(--space-2);
  font-size: 13px;
}

.doc-icon { font-size: 18px; }
.doc-name { flex: 1; font-weight: var(--weight-medium); }
.doc-date { font-size: var(--text-xs); color: var(--text-muted); font-family: var(--font-mono); }
.doc-action { color: var(--accent); font-size: var(--text-sm); cursor: pointer; }
.doc-action:hover { text-decoration: underline; }

/* ── Document grid (Documenti page) ─────────────────────────────────────────── */
.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.doc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  cursor: pointer;
  transition: box-shadow var(--transition-fast);
}

.doc-card:hover {
  box-shadow: var(--shadow-card);
}

.doc-card-icon  { font-size: 28px; margin-bottom: 10px; }
.doc-card-name  { font-weight: var(--weight-medium); font-size: 13px; margin-bottom: var(--space-1); }
.doc-card-client { font-size: var(--text-sm); color: var(--text-muted); }
.doc-card-date  { font-size: var(--text-xs); color: var(--text-muted); margin-top: var(--space-2); font-family: var(--font-mono); }

/* ── Campaign card ──────────────────────────────────────────────────────────── */
.campagna-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: 14px;
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
}

.campagna-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-lg);
  background: #25D366;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.campagna-title { font-weight: var(--weight-semibold); font-size: var(--text-md); margin-bottom: var(--space-1); }
.campagna-meta  { font-size: var(--text-sm); color: var(--text-muted); }
.campagna-stats { margin-left: auto; text-align: right; }
.campagna-stat-num   { font-size: 20px; font-weight: var(--weight-semibold); color: var(--accent); }
.campagna-stat-label { font-size: var(--text-xs); color: var(--text-muted); }

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: 5px;
  display: block;
  font-weight: var(--weight-medium);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 9px var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  background: var(--surface);
  outline: none;
  color: var(--text);
  transition: border-color var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

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

.form-input[aria-invalid="true"],
.form-input.error {
  border-color: var(--red);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

/* ── Empty state ────────────────────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 60px var(--space-5);
  color: var(--text-muted);
}

.empty-icon  { font-size: 40px; margin-bottom: var(--space-3); }
.empty-title { font-size: 15px; font-weight: var(--weight-semibold); color: var(--text); margin-bottom: 6px; }
.empty-sub   { font-size: 13px; }

/* ── Toast notification ─────────────────────────────────────────────────────── */
.notification {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  background: var(--text);
  color: #fff;
  padding: var(--space-3) 18px;
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  z-index: 500;
  transform: translateY(80px);
  opacity: 0;
  transition: all var(--transition-mid);
  pointer-events: none;
  max-width: 360px;
}

.notification.show {
  transform: translateY(0);
  opacity: 1;
}

/* ── Loading screen ─────────────────────────────────────────────────────────── */
.loading-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  flex: 1;
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
}

/* ── Login page ─────────────────────────────────────────────────────────────── */
/*
 * The login view replaces the entire #app with this layout.
 * No sidebar — full-page centered card.
 */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  flex: 1;
  padding: var(--space-5);
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-7);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-card);
}

.login-brand {
  text-align: center;
  margin-bottom: var(--space-7);
}

.login-logo-name {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.3px;
  color: var(--text);
}

.login-logo-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.login-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-6);
  letter-spacing: -0.2px;
}

/* Generic error box — used in login form */
.login-error {
  display: none;
  background: #FEF2F2;
  color: var(--red);
  border: 1px solid #FECACA;
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}

.login-error.visible {
  display: block;
}

.login-btn {
  width: 100%;
  padding: 11px;
  justify-content: center;
  font-size: var(--text-md);
  margin-top: var(--space-2);
}

/* ── Clients view ────────────────────────────────────────────────────────────── */

/* Small italic hint beneath the search bar */
.search-hint {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: -10px;        /* visually tuck under the search bar */
  margin-bottom: 18px;
  line-height: 1.4;
}

/* Inline field-level validation error (shown via JS display:block) */
.form-field-error {
  display: none;
  font-size: var(--text-sm);
  color: var(--red);
  margin-top: var(--space-1);
  line-height: 1.4;
}

/* Small muted hint beneath a form input (always visible) */
.form-field-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
  line-height: 1.4;
}

/* "(opzionale)" suffix in form labels */
.form-label-opt {
  font-weight: var(--weight-normal);
  color: var(--text-muted);
}

/* Required-field asterisk */
.form-required {
  color: var(--red);
  margin-left: 2px;
}

/* Textarea height control */
.form-textarea {
  resize: vertical;
  min-height: 72px;
}

/* Table state cells — loading / empty / error */
.table-state-cell {
  text-align: center;
  padding: var(--space-7) var(--space-5);
  color: var(--text-muted);
  font-size: var(--text-sm);
  cursor: default;           /* override the global tbody tr pointer */
}

.table-state-cell:hover {
  background: transparent !important;
}

.table-state-error {
  color: var(--red);
}

.table-loading-text {
  font-family: var(--font-mono);
  letter-spacing: 0.4px;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .two-col {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  /* Sidebar slides off-screen; hamburger button reveals it */
  .sidebar {
    transform: translateX(-100%);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-open .sidebar-overlay {
    display: block;
  }

  .main {
    margin-left: 0;
  }

  .topbar {
    padding: var(--space-3) var(--space-4);
  }

  .content {
    padding: var(--space-4);
  }

  .hamburger {
    display: block;
  }

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

  .modal-panel {
    width: 100vw;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}

/* ── Client detail view (views/clientDetail.js) ──────────────────────────────── */

/* Keyboard focus ring on clickable table rows */
tbody tr[data-id]:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Two-column layout: main data area + narrow actions sidebar */
.cd-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: var(--space-4);
  align-items: flex-start;
}

/* Name + badge row in the card header */
.cd-name-header {
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* Large client name in the detail header */
.cd-client-name {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.3px;
  line-height: 1.2;
  margin: 0;
}

/* Card containing the anagrafica info rows */
.cd-data-card {
  margin-top: var(--space-4);
}

/* Padding inside the info section */
.cd-info-body {
  padding: var(--space-2) var(--space-5) var(--space-3);
}

/* Note row: align items to top since note text can be multi-line */
.cd-note-row {
  align-items: flex-start;
}

/* Note value: wrap long text, right-aligned to match other info-vals */
.cd-note-val {
  max-width: 60%;
  text-align: right;
  word-break: break-word;
  white-space: pre-wrap;
}

/* Loading state centered in the content area */
.cd-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px var(--space-5);
}

/* Actions card body: vertical stack of full-width buttons */
.cd-actions-body {
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.cd-action-btn {
  width: 100%;
  justify-content: center;
  padding: 9px var(--space-4);
}

/* WhatsApp action button — filled green (messaging / positive action). */
.cd-wa-btn {
  background: var(--green);
  color: #fff;
}

.cd-wa-btn:hover:not(:disabled) {
  background: #256B45; /* darker green — no dedicated token */
}

/* Language picker: two equal-width options side by side. */
.cd-wa-actions {
  display: flex;
  gap: var(--space-3);
}

.cd-wa-lang {
  flex: 1;
  justify-content: center;
  padding: 10px var(--space-4);
}

@media (max-width: 380px) {
  /* Stack language options on very narrow screens */
  .cd-wa-actions {
    flex-direction: column;
  }
}

/* ── Edit form ──────────────────────────────────────────────────────────────── */

/* Wrapper centers the edit card horizontally */
.cd-edit-wrap {
  display: flex;
  justify-content: flex-start; /* left-align, not centered — matches page flow */
}

/* The edit form card is constrained in width for readability */
.cd-edit-card {
  width: 100%;
  max-width: 600px;
}

/* Save / Cancel buttons — right-aligned in the form footer */
.cd-edit-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  margin-top: var(--space-2);
}

/* ── Delete confirmation dialog ─────────────────────────────────────────────── */

/* Override modal-overlay's top-right slide-in alignment for a centered dialog */
.cd-confirm-overlay {
  align-items: center !important;
  justify-content: center !important;
}

/* Compact centered dialog (not a full-height side panel) */
.cd-confirm-panel {
  background: var(--surface);
  width: 440px;
  max-width: calc(100vw - var(--space-8));
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  /* No animation — this is a blocking confirm, not a slide-in panel */
}

.cd-confirm-text {
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text);
  margin-bottom: var(--space-4);
}

/* Confirm / Cancel buttons — right-aligned */
.cd-confirm-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
}

/* ── Client detail responsive ────────────────────────────────────────────────── */

@media (max-width: 900px) {
  /* Stack main content above the actions sidebar on tablets */
  .cd-layout {
    grid-template-columns: 1fr;
  }
  /* Actions card goes below the data card; buttons are still full-width */
}

@media (max-width: 600px) {
  .cd-edit-card {
    max-width: 100%;
  }

  .cd-note-val {
    max-width: 55%;
  }

  .cd-confirm-panel {
    width: calc(100vw - var(--space-6));
  }
}

/* ── Payments section (client detail — Bloque 3) ─────────────────────────────── */

/* Payments card sits below the anagrafica card in the main column */
.cd-pay-card {
  margin-top: var(--space-4);
}

/* Row holding the two state-change action buttons */
.cd-pay-actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}

/* Each button grows to fill available space; min-width prevents squishing */
.cd-pay-btn {
  flex: 1;
  min-width: 160px;
  justify-content: center;
  padding: 9px var(--space-4);
}

/* Inline error area below the action buttons (hidden by default via .form-field-error) */
.cd-pay-error {
  padding: 0 var(--space-5) var(--space-3);
  margin-top: var(--space-2);
}

/* Storico sub-section label container */
.cd-storico-header {
  padding: var(--space-4) var(--space-5) var(--space-2);
}

/* "STORICO MOVIMENTI" label — matches info-section-title in the POC */
.cd-storico-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Individual storico row — extends the activity-item visual language */
.cd-storico-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.cd-storico-row:last-child {
  border-bottom: none;
}

/* Content column next to the dot */
.cd-storico-content {
  flex: 1;
  min-width: 0;
}

/* Badge + "da <operator>" inline */
.cd-storico-main {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* Operator name ("da Mario Rossi") */
.cd-storico-by {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* Timestamp line */
.cd-storico-when {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: 2px;
}

/* Optional note text — shown only when present */
.cd-storico-note {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-style: italic;
  margin-top: var(--space-1);
  word-break: break-word;
}

/* Loading / empty / error state inside the storico area */
.cd-storico-state {
  padding: var(--space-5) var(--space-5);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* Error variant: red text for fetch failures */
.cd-storico-error {
  color: var(--red);
}

@media (max-width: 600px) {
  /* Stack payment buttons vertically on very small screens */
  .cd-pay-actions {
    flex-direction: column;
  }

  .cd-pay-btn {
    min-width: 0;
    width: 100%;
  }
}

/* ── Dashboard view ─────────────────────────────────────────────────────────── */

/* Loading state — vertically centered in the content area */
.dash-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px var(--space-5);
  color: var(--text-muted);
}

/* 3-column stat grid variant used by the dashboard (overrides the 4-col default).
   Inherits the .stats-grid responsive breakpoints via cascade:
   at ≤1024px .stats-grid sets repeat(2,1fr); at ≤480px sets 1fr.
   Both beat this base rule because they appear later in source order. */
.stats-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

/* Emphasize the "in attesa" stat card with an orange left accent.
   This is the #1 pain point for the client (CLAUDE.md). */
.dash-stat-pending {
  border-left: 3px solid var(--orange);
}

/* Quick-access button stack inside the sidebar card.
   Not .card-body (which has padding:0 for tables) — own padding rule. */
.dash-quick-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
}

/* Each quick-access button fills the full card width */
.dash-q-btn {
  width: 100%;
  justify-content: center;
  padding: 10px var(--space-4);
}

/* Welcome-state action buttons — centered row, wraps on narrow screens */
.dash-welcome-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  flex-wrap: wrap;
  margin-top: var(--space-5);
}

/* "Mostra tutti →" text link at the bottom of the pending preview table */
.dash-more-link {
  color: var(--accent);
  font-weight: var(--weight-medium);
  font-size: var(--text-sm);
  text-decoration: none;
}

.dash-more-link:hover {
  text-decoration: underline;
}

/* Right-column vertical stack: Attività recenti card above Accesso rapido card.
   The .two-col grid places this div in the 360px column; inside, cards stack
   with a gap — no fixed heights needed, each card sizes to its content. */
.dash-sidebar-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* Muted italic placeholder rendered when the target client has been
   hard-erased (GDPR erasure sets target_client_id to NULL in the log). */
.activity-erased {
  font-style: italic;
  color: var(--text-muted);
}

/* ── Import (CSV) view ──────────────────────────────────────────────────────── */

/* Vertical rhythm between the top-level blocks (file card, preview, result). */
.import-view,
.import-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* Empty preview/result containers must not reserve gap space. */
.import-stack:empty {
  display: none;
}

/* Padded body for cards that hold form fields / text / buttons (not a table).
   The base .card-body is padding:0 because it is designed to wrap tables. */
.import-body {
  padding: var(--space-5);
}

/* First paragraph inside a padded body shouldn't add a top margin. */
.import-body > .search-hint:first-child {
  margin-top: 0;
}

/* Space between stacked controls inside a padded body — but not when the
   button is the only/first element (e.g. the standalone "Vai ai clienti"). */
.import-body > .btn:not(:first-child) {
  margin-top: var(--space-4);
}

/* Stats grid inside the import stack: the stack's gap already spaces it. */
.import-stack .stats-grid {
  margin-bottom: 0;
}

/* Small mono section label above a stats grid (matches info-section-title). */
.import-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: var(--space-3);
}

/* Inline "code" chips in the intro hint (column names). */
.import-body code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--surface2);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
}
