/* ============================================================
   TAB 4 — DOCUMENTI CONTRATTUALI & CLAUSOLE — CSS
   ============================================================ */

/* ── LAYOUT ───────────────────────────────────────────────── */
#tab4-container {
  padding: 0;
}

#doc-root {
  max-width: 860px;
}

/* ── MESSAGGIO GLOBALE ────────────────────────────────────── */
.doc-msg {
  display: none;
  padding: 10px 16px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
}
.doc-msg-success { background: #E1F5EE; color: #085041; }
.doc-msg-error   { background: #FCEBEB; color: #791F1F; }

/* ── SECTION HEADER ───────────────────────────────────────── */
.doc-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.doc-section-title {
  font-size: 14px;
  font-weight: 600;
  color: #222;
  margin-bottom: 2px;
}

.doc-section-sub {
  font-size: 12px;
  color: #888;
}

/* ── EMPTY STATE ──────────────────────────────────────────── */
.doc-empty {
  padding: 28px 20px;
  text-align: center;
  font-size: 13px;
  color: #888;
  background: #fafafa;
  border: 1px dashed #ddd;
  border-radius: 8px;
}

/* ── CARD DOCUMENTO ───────────────────────────────────────── */
.doc-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 10px;
  margin-bottom: 8px;
  transition: border-color 0.15s;
}

.doc-card:hover {
  border-color: #bbb;
}

.doc-card-active {
  border-color: #2d6a4f;
  background: #f4fbf7;
}

.doc-card-left {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.doc-card-ordine {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #f0f0f0;
  color: #555;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.doc-card-active .doc-card-ordine {
  background: #2d6a4f;
  color: #fff;
}

.doc-card-nome {
  font-size: 13px;
  font-weight: 600;
  color: #222;
  margin-bottom: 5px;
}

.doc-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.doc-card-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ── CARD CLAUSOLA ────────────────────────────────────────── */
.doc-cl-group-title {
  font-size: 11px;
  font-weight: 700;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
  padding-left: 2px;
}

.doc-cl-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  margin-bottom: 6px;
  transition: border-color 0.15s;
}

.doc-cl-card:hover {
  border-color: #bbb;
}

.doc-cl-card-left {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.doc-cl-ordine {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: #f0f0f0;
  color: #666;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
  font-family: 'DM Mono', monospace;
}

.doc-cl-nome {
  font-size: 13px;
  font-weight: 600;
  color: #222;
  margin-bottom: 2px;
}

.doc-cl-rif {
  font-size: 11px;
  color: #888;
  margin-bottom: 3px;
}

.doc-cl-testo {
  font-size: 12px;
  color: #555;
  line-height: 1.5;
}

/* ── BADGE ────────────────────────────────────────────────── */
.doc-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}

.doc-badge-accent  { background: #d8ede3; color: #1a4a31; }
.doc-badge-green   { background: #E1F5EE; color: #085041; }
.doc-badge-gray    { background: #f0f0f0; color: #666; }
.doc-badge-info    { background: #ddeaf9; color: #0C447C; }
.doc-badge-warn    { background: #FAEEDA; color: #633806; }
.doc-badge-purple  { background: #f0eaff; color: #5b21b6; }

/* ── BOTTONI ──────────────────────────────────────────────── */
.doc-btn-primary {
  background: #222;
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.doc-btn-primary:hover { background: #444; }

.doc-btn-secondary {
  background: #fff;
  color: #444;
  border: 1px solid #ddd;
  border-radius: 7px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.doc-btn-secondary:hover { background: #f5f5f5; }

.doc-btn-danger {
  background: #FCEBEB;
  color: #791F1F;
  border: 1px solid #f5a0a0;
  border-radius: 7px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.doc-btn-danger:hover { background: #fde0e0; }

.doc-btn-sm {
  background: #fff;
  color: #444;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s;
  white-space: nowrap;
}
.doc-btn-sm:hover { background: #f5f5f5; }

/* ── MODAL ────────────────────────────────────────────────── */
.doc-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.doc-modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.doc-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid #eee;
}

.doc-modal-title {
  font-size: 15px;
  font-weight: 600;
  color: #222;
}

.doc-modal-close {
  background: none;
  border: none;
  font-size: 16px;
  color: #888;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: background 0.12s;
}
.doc-modal-close:hover { background: #f0f0f0; color: #333; }

.doc-modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.doc-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid #eee;
}

/* ── FORM FIELDS ──────────────────────────────────────────── */
.doc-field-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.doc-label {
  font-size: 12px;
  font-weight: 500;
  color: #555;
}

.doc-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  color: #222;
  background: #fafafa;
  font-family: 'DM Sans', sans-serif;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.doc-input:focus {
  outline: none;
  border-color: #999;
  background: #fff;
}

textarea.doc-input {
  resize: vertical;
  min-height: 70px;
}

/* ── EDITOR TESTO ───────────────────── */
.doc-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 8px;
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
}
.doc-toolbar-btn {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 12px;
  cursor: pointer;
  color: #333;
  transition: background 0.1s;
}
.doc-toolbar-btn:hover { background: #e8e8e8; }
.doc-toolbar-sep { width: 1px; background: #ddd; margin: 0 2px; }
.doc-vars-wrap {
  background: #f9f9f9;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 10px 14px;
  margin: 8px 0;
}
.doc-vars-title {
  font-size: 11px;
  font-weight: 700;
  color: #888;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 8px;
}
.doc-vars-list { display: flex; flex-wrap: wrap; gap: 6px; }
.doc-var-chip {
  font-size: 11px;
  background: #f0f0f0;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 2px 9px;
  cursor: pointer;
  color: #555;
  font-family: 'DM Mono', monospace;
  transition: background 0.1s;
}
.doc-var-chip:hover { background: #2d6a4f; color: #fff; border-color: #2d6a4f; }
.doc-editor-area {
  min-height: 360px;
  padding: 16px;
  border: 1px solid #ddd;
  border-radius: 0 0 8px 8px;
  font-size: 13px;
  line-height: 1.7;
  outline: none;
  background: #fff;
  color: #111;
  overflow-y: auto;
  margin-bottom: 4px;
}
.doc-editor-area:focus { border-color: #999; }
