/* cards.css - stile condiviso per le card moderne */
:root {
  --card-surface-bg: #ffffff;
  --card-surface-shadow: 0 8px 24px rgba(15, 20, 25, 0.06);
  --card-surface-radius: 12px;
  --card-surface-padding: 16px;
  --card-surface-muted: #6b7280;
  --card-surface-value: #0f1724;
}

.card-modern {
  background: var(--card-surface-bg);
  border-radius: var(--card-surface-radius);
  box-shadow: var(--card-surface-shadow);
  padding: var(--card-surface-padding);
  display: flex;
  flex-direction: column;
  border: none;
  min-height: 0;
}

.card-modern > .card-content {
  padding: 0;
  margin: 0;
  flex: 1 1 auto;
}

.card-modern .card-title,
.card-modern .title {
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin: 0 0 12px 0;
  color: #374151;
}

.card-modern .card-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--card-surface-value);
  margin: 0 0 8px 0;
}

.card-modern .card-note {
  color: var(--card-surface-muted);
  font-size: 0.9rem;
  margin-top: 6px;
  margin-bottom: 0;
}

.card-modern .delta {
  font-size: 0.9rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 10px;
  display: inline-block;
  margin-top: 4px;
}

.card-modern .delta.up {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
}

.card-modern .delta.down {
  background: rgba(239, 68, 68, 0.08);
  color: #dc2626;
}

.card-modern .delta.flat {
  background: rgba(99, 102, 241, 0.06);
  color: #4f46e5;
}

.card-modern .delta.new {
  background: rgba(14, 165, 233, 0.08);
  color: #0369a1;
}
/* Common card layouts */
.card-modern.metric {
  flex: 1 1 220px;
  min-width: 220px;
  min-height: var(--card-modern-metric-min-height, var(--card-min-h, 120px));
  text-align: center;
  transition: transform 0.12s ease;
}

.card-modern.metric:hover {
  transform: translateY(-4px);
}

.card-modern.metric .card-title,
.card-modern.metric .card-value,
.card-modern.metric .card-note {
  text-align: center;
}

.card-modern.graph {
  flex: 1 1 300px;
  min-width: 280px;
}

.card-modern.graph.full {
  flex: 1 1 100%;
  min-width: 100%;
}

.card-modern.graph .title,
.card-modern.list .title {
  text-align: center;
}

.card-modern.graph .card-note,
.card-modern.list .card-note {
  text-align: center;
}

.card-modern.list {
  flex: 1 1 480px;
  min-width: 300px;
}

.card-modern-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--card-modern-grid-gap, 16px);
  width: 100%;
  align-items: stretch;
}

@media (max-width: 1000px) {
  .card-modern.metric {
    flex: 1 1 calc(50% - 12px);
  }

  .card-modern.graph,
  .card-modern.list {
    flex: 1 1 100%;
  }
}

@media (max-width: 600px) {
  .card-modern.metric {
    flex: 1 1 100%;
  }
}

/* Layout helpers for card-modern (toolbar + tables) */
.card-modern__toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.card-modern__heading {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #374151;
}

.card-modern__toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.card-modern__table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.card-modern__table-wrapper table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.card-modern__table-wrapper thead th {
  text-align: left;
  padding: 8px 6px;
  color: var(--card-surface-muted);
  font-weight: 700;
  border-bottom: 1px solid #f0f2f5;
  font-size: 0.85rem;
}

.card-modern__table-wrapper tbody td {
  padding: 8px 6px;
  border-bottom: 1px solid #f1f3f8;
  color: #0f172a;
  vertical-align: middle;
}

.card-modern__table-wrapper tbody tr:hover {
  background-color: #f8fafc;
}

.card-modern__table-wrapper tbody tr:last-child td {
  border-bottom: none;
}

.card-modern__table-wrapper table a:not(.pdf-icon) {
  color: #2563eb;
  font-weight: 600;
  text-decoration: none;
}

.card-modern__table-wrapper table a:not(.pdf-icon):hover {
  text-decoration: underline;
}

.card-modern__table-wrapper .dataTables_wrapper {
  width: 100%;
}

.card-modern__table-wrapper table input[type="number"] {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 0.9rem;
  height: 36px;
  box-sizing: border-box;
}

@media (max-width: 768px) {
  .card-modern__table-wrapper table {
    font-size: 0.9rem;
  }

  .card-modern__table-wrapper thead th,
  .card-modern__table-wrapper tbody td {
    padding: 10px 8px;
  }
}

/* Catalog list cards (serramatic/templates/serramatic/catalog/catalog_list.html) */
.product-grid {
  display: grid;
  grid-template-columns: 2fr 3fr 3fr;
  gap: 15px;
  align-items: start;
}

.col-image {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
}

.col-image img {
  max-width: 150px;
  max-height: 150px;
  width: auto;
  height: auto;
  display: block;
  margin-bottom: 10px;
  background: #fff;
  object-fit: contain;
}

.col-image .btn-small,
.col-image form {
  display: inline-block;
  margin: 0 4px;
}

.col-main,
.col-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px 15px;
}

.col-main p {
  display: flex;
  flex-direction: column;
  margin: 4px 0 !important;
}

.col-options p {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  margin: 2px 8px 2px 0;
}

.col-main p strong,
.col-options p strong {
  margin-bottom: 2px;
  color: #555;
}

.category-section.grid-view .category-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.category-section.grid-view .card.card-modern {
  flex: 1 1 280px;
  min-width: 240px;
  max-width: 360px;
  margin: 0;
  align-items: center;
  text-align: center;
}

.category-section.grid-view .col-image {
  gap: 8px;
}

.category-section.grid-view .card.card-modern:not(.expanded) .product-grid {
  grid-template-columns: 1fr;
  justify-items: center;
}

.category-section.grid-view .card.card-modern:not(.expanded) .col-image {
  align-items: center;
  justify-content: center;
}

.category-section.grid-view .card.card-modern:not(.expanded) .col-image img {
  margin-left: auto;
  margin-right: auto;
}

.category-section.grid-view .card.card-modern:not(.expanded) .col-image .btn-small,
.category-section.grid-view .card.card-modern:not(.expanded) .col-image form {
  margin: 4px 6px;
}

.category-section.grid-view .card.card-modern.expanded .col-image .btn-small,
.category-section.grid-view .card.card-modern.expanded .col-image form {
  margin: 4px 6px;
}

.category-section.grid-view .card.card-modern .col-main,
.category-section.grid-view .card.card-modern .col-options {
  display: none;
}

.category-section.grid-view .card.card-modern.expanded {
  flex: 1 1 100%;
  max-width: none;
  align-items: stretch;
  text-align: left;
}

.category-section.grid-view .card.card-modern.expanded .card-content {
  display: block;
}

.category-section.grid-view .card.card-modern.expanded .col-image {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
}

.category-section.grid-view .card.card-modern.expanded .col-image .btn-small,
.category-section.grid-view .card.card-modern.expanded .col-image form {
  margin: 0 4px;
}

.category-section.grid-view .card.card-modern.expanded .product-grid {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(200px, 1fr) minmax(200px, 1fr);
  gap: 15px;
}

.category-section.grid-view .card.card-modern.expanded .product-grid .col-image {
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
}

.category-section.grid-view .card.card-modern.expanded .col-main,
.category-section.grid-view .card.card-modern.expanded .col-options {
  display: block;
}

.view-btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  margin-left: 5px;
  border: 1px solid #ccc;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.view-btn.active,
.view-btn:hover {
  background-color: #e0e0e0;
}

.catalog-actions .catalog-export-btn {
  display: none !important;
}

@media (max-width: 768px) {
  .catalog-actions .view-toggle {
    display: none;
  }

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

  .product-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .category-section.grid-view .card.card-modern.expanded {
    text-align: left;
  }

  .category-section.grid-view .card.card-modern.expanded .product-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .category-section.grid-view .card.card-modern.expanded .product-grid .col-image {
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }

  .category-section.grid-view .card.card-modern.expanded .col-image .btn-small,
  .category-section.grid-view .card.card-modern.expanded .col-image form {
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .category-section.grid-view .card.card-modern.expanded .col-main,
  .category-section.grid-view .card.card-modern.expanded .col-options {
    display: block;
  }

  .category-section.grid-view .card.card-modern.expanded .col-options p {
    width: 100%;
  }
}

/* Catalog form cards (serramatic/templates/serramatic/catalog/form.html) */
.form-compact .row {
  margin-bottom: 15px;
}

.form-compact .input-field {
  margin-bottom: 12px;
  position: relative;
}

.card-image img {
  max-width: 220px;
  max-height: 100%;
  display: block;
  margin: 0 auto;
}

.file-field input[type="file"] {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-path-display {
  word-break: break-all;
  text-align: center;
}

.field-errors {
  color: #d32f2f;
  font-size: 0.9em;
  margin-top: 4px;
}

.non-field-errors {
  color: #b00020;
  margin-bottom: 8px;
}

.row.equal-height {
  display: flex;
  flex-wrap: wrap;
}

.row.equal-height > .col {
  display: flex;
  flex-direction: column;
}

.row.equal-height > .col > .card-modern {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.row.equal-height > .col > .card-modern .card-content {
  padding-bottom: 12px;
}

.card-content p.helper-text {
  margin-top: 4px;
  margin-bottom: 16px;
}


/* Account grid inside cards (serramatic/templates/serramatic/account.html) */
.company-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  align-items: start;
}
.company-info {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px 20px;
}
.company-info .field { display: flex; flex-direction: column; }
.company-info .label { font-weight: 600; color: #555; margin-bottom: 2px; }
.company-info .value { color: #333; }
.company-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed #ccc;
  border-radius: 6px;
  padding: 8px;
  min-height: 120px;
}
.company-logo img { max-height: 100px; max-width: 100%; }
.logo-placeholder { color: #999; font-size: 0.9rem; }
.form-toggle { margin-top: 0; }
.grid-span-2 { grid-column: span 2; }
@media (max-width: 768px) { .company-grid { grid-template-columns: 1fr; } }
