/* ========================================
   INPAL Romania Platform – Stili personalizzati
   ======================================== */

:root {
  --inpal-blue: #003da5;
  --inpal-blue-dark: #002a73;
  --inpal-gold: #b8a040;
  --inpal-gold-light: #f5c518;
  --inpal-gray: #f8f9fa;
}

/* --- HEADER --- */
.inpal-header {
  background: linear-gradient(135deg, var(--inpal-blue) 0%, var(--inpal-blue-dark) 100%);
  border-bottom: 3px solid var(--inpal-gold);
}

.inpal-logo {
  height: 80px;
  width: auto;
  filter: none;
  background: transparent;
}

.inpal-logo-footer {
  filter: none;
  opacity: 1;
}

/* Logo AIC – bianco invertito su sfondo scuro */
.aic-logo {
  filter: brightness(0) invert(1);
  opacity: 0.9;
}

/* --- NAVBAR --- */
.inpal-nav {
  background: var(--inpal-blue-dark);
}

.inpal-nav .navbar-nav .nav-link {
  color: rgba(255,255,255,0.85) !important;
  font-weight: 500;
  padding: 10px 14px;
  border-radius: 4px;
  transition: background 0.2s, color 0.2s;
}

.inpal-nav .navbar-nav .nav-link:hover,
.inpal-nav .navbar-nav .nav-link.active {
  background: rgba(255,255,255,0.18);
  color: #fff !important;
}

.inpal-nav .dropdown-menu {
  border: none;
  box-shadow: 0 4px 20px rgba(0,0,0,0.18);
  border-radius: 8px;
}

/* --- BARRA DOCUMENTI OBBLIGATORI --- */
.doc-obbligatori-bar {
  background: #1a1a2e;
  border-bottom: 2px solid var(--inpal-gold);
}

/* --- FOOTER --- */
.inpal-footer {
  background: var(--inpal-blue-dark);
  border-top: 3px solid var(--inpal-gold);
}

/* --- HERO SECTION --- */
.hero-section {
  background: linear-gradient(135deg, var(--inpal-blue) 0%, #1a5276 50%, #0a3d62 100%);
  border: none;
}

/* --- MODULO CARDS (homepage) --- */
.modulo-card {
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: default;
  border-radius: 12px !important;
}

.modulo-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 30px rgba(0,0,0,0.18) !important;
}

.modulo-icon {
  min-width: 65px;
  min-height: 65px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- FORM SECTIONS --- */
.form-section {
  border: 1px solid #dee2e6;
  border-radius: 12px;
  overflow: hidden;
}

.section-header {
  background: linear-gradient(90deg, #f8f9fa, #e9ecef);
  border-bottom: 2px solid var(--inpal-gold);
  padding: 14px 20px;
}

.required-field::after {
  content: " *";
  color: #dc3545;
  font-weight: bold;
}

/* --- BOX MANDATO/LIBERATORIA --- */
.doc-obblig-box {
  transition: box-shadow 0.2s;
  border-radius: 10px !important;
}

.doc-obblig-box:hover {
  box-shadow: 0 3px 12px rgba(0,0,0,0.12);
}

/* --- DOCUMENTO CARDS --- */
.documento-card {
  border-radius: 8px !important;
  transition: box-shadow 0.2s;
  border: 1px solid #e9ecef;
}

.documento-card:hover {
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

/* Stato documento: caricato */
.documento-card.doc-caricato,
.doc-obblig-box.doc-caricato {
  background-color: #f0fff4 !important;
  border-color: #28a745 !important;
}

/* --- MODULO HEADER --- */
.modulo-header {
  border-left: 5px solid var(--inpal-gold);
  border-radius: 12px;
}

/* --- PROGRESS BAR --- */
.progress-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- GUIDA OPERATIVA --- */
.guida-sezione {
  border-left: 4px solid var(--inpal-blue);
  padding-left: 20px;
}

.guida-titolo {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--inpal-blue);
  margin-bottom: 16px;
}

.guida-corpo {
  background: #fff;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* --- SCRIPT VIDEO --- */
.script-scena .script-testo p {
  margin-bottom: 12px;
  line-height: 1.7;
}

.script-scena .script-testo p:last-child {
  margin-bottom: 0;
}

/* --- FAQ --- */
.faq-sezione .accordion-button {
  font-weight: 600;
  color: var(--inpal-blue);
}

.faq-sezione .accordion-button:not(.collapsed) {
  background-color: #e8f0fe;
  color: var(--inpal-blue);
}

/* --- LINK UTILI --- */
.link-utili-card {
  transition: transform 0.15s, box-shadow 0.15s;
  border-radius: 10px;
}

.link-utili-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12) !important;
}

/* --- MODAL CONFIRM --- */
.modal-conferma-riepilogo {
  background: #f8fff8;
  border: 1px solid #28a745;
  border-radius: 8px;
  padding: 16px;
}

/* --- PRINT STYLES --- */
@media print {
  .inpal-nav, .doc-obbligatori-bar, footer .btn,
  button, .no-print { display: none !important; }
  .guida-sezione { border-left-color: #000; }
  body { font-size: 12pt; }
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
  .hero-section { padding: 24px !important; }
  .hero-section .display-6 { font-size: 1.4rem; }
  .modulo-header { padding: 16px !important; }
  .section-header { padding: 10px 14px; }
  .progress-container { display: none; }
  .inpal-logo { height: 52px; }
  .doc-obbligatori-bar .btn { font-size: 0.75rem; padding: 4px 8px; }
}

/* --- UTILITY --- */
.text-uppercase { text-transform: uppercase; }
.badge.bg-warning-subtle {
  background-color: #fff3cd;
  color: #664d03;
}

/* File input */
.form-control[type=file] {
  padding: 4px 8px;
  cursor: pointer;
}

/* Validazione */
.was-validated .form-control:invalid,
.form-control.is-invalid {
  border-color: #dc3545;
}

/* Sezione link utili – categorie */
.link-categoria-header {
  background: linear-gradient(90deg, var(--inpal-blue), #1a5276);
  color: white;
  padding: 10px 16px;
  border-radius: 8px 8px 0 0;
  font-weight: 700;
}

/* ============================================================
   CHATBOT CICCIO – Stili widget
   ============================================================ */

/* --- PULSANTE DI APERTURA (grande, con la faccia) --- */
.ciccio-toggle-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  background: var(--inpal-blue);
  border: 3px solid var(--inpal-gold);
  border-radius: 50px;
  padding: 6px 16px 6px 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 6px 28px rgba(0,0,0,0.32);
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
  outline: none;
}

.ciccio-toggle-btn:hover {
  transform: scale(1.06) translateY(-2px);
  box-shadow: 0 10px 36px rgba(0,0,0,0.40);
  background: var(--inpal-blue-dark);
}

.ciccio-toggle-btn:active {
  transform: scale(0.97);
}

.ciccio-btn-label {
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

/* Badge pallino notifica */
.ciccio-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #e63946;
  color: #fff;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  animation: ciccioPulse 1.8s infinite;
}

@keyframes ciccioPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.25); }
}

/* --- FINESTRA CHAT --- */
.ciccio-chat-window {
  position: fixed;
  bottom: 110px;
  right: 28px;
  z-index: 9998;
  width: 380px;
  max-width: calc(100vw - 32px);
  max-height: 580px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 16px 60px rgba(0,0,0,0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(18px) scale(0.96);
  transition: opacity 0.25s ease, transform 0.25s ease;
  border: 1px solid #e0e0e0;
}

.ciccio-chat-window.ciccio-chat-open {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* --- HEADER DELLA CHAT --- */
.ciccio-chat-header {
  background: linear-gradient(135deg, var(--inpal-blue) 0%, var(--inpal-blue-dark) 100%);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--inpal-gold);
  flex-shrink: 0;
}

.ciccio-header-avatar {
  /* Definito nella sezione CICCIOBOT Avatar umanoide digitale */
  flex-shrink: 0;
}

.ciccio-header-name {
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
}

.ciccio-header-subtitle {
  color: rgba(255,255,255,0.7);
  font-size: 0.75rem;
  line-height: 1.2;
}

.ciccio-header-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  border-radius: 6px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 0.85rem;
}

.ciccio-header-btn:hover {
  background: rgba(255,255,255,0.30);
}

/* --- AREA MESSAGGI --- */
.ciccio-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f6f8fb;
  scroll-behavior: smooth;
}

.ciccio-messages::-webkit-scrollbar {
  width: 4px;
}

.ciccio-messages::-webkit-scrollbar-thumb {
  background: #c8d0e0;
  border-radius: 4px;
}

/* --- SINGOLO MESSAGGIO --- */
.ciccio-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: ciccioBubbleIn 0.22s ease;
}

@keyframes ciccioBubbleIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ciccio-msg-assistant {
  justify-content: flex-start;
}

.ciccio-msg-user {
  justify-content: flex-end;
}

.ciccio-msg-error {
  justify-content: center;
}

.ciccio-msg-avatar {
  /* Definito nella sezione CICCIOBOT Avatar umanoide digitale */
  flex-shrink: 0;
  align-self: flex-end;
}

.ciccio-msg-user-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--inpal-blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
  align-self: flex-end;
}

/* --- BOLLE DEI MESSAGGI --- */
.ciccio-bubble {
  max-width: 78%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.5;
  word-break: break-word;
}

.ciccio-bubble-assistant {
  background: #fff;
  color: #1a1a2e;
  border-radius: 4px 14px 14px 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.10);
  border: 1px solid #e8ecf0;
}

.ciccio-bubble-user {
  background: var(--inpal-blue);
  color: #fff;
  border-radius: 14px 4px 14px 14px;
}

.ciccio-bubble-error {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffc107;
  border-radius: 10px;
  font-size: 0.82rem;
  max-width: 90%;
  text-align: center;
}

/* Link nelle bolle */
.ciccio-bubble a {
  color: var(--inpal-gold);
  text-decoration: underline;
}

.ciccio-bubble-user a {
  color: #ffd966;
}

/* --- TYPING INDICATOR --- */
.ciccio-typing-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
}

.ciccio-dot {
  width: 8px;
  height: 8px;
  background: #a0a8b8;
  border-radius: 50%;
  display: inline-block;
  animation: ciccioTyping 1.2s infinite ease-in-out;
}

.ciccio-dot:nth-child(1) { animation-delay: 0s; }
.ciccio-dot:nth-child(2) { animation-delay: 0.2s; }
.ciccio-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes ciccioTyping {
  0%, 80%, 100% { transform: scale(1); opacity: 0.4; }
  40%           { transform: scale(1.35); opacity: 1; }
}

/* --- CHIP SUGGERIMENTI --- */
.ciccio-suggerimenti {
  padding: 8px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: #f0f2f8;
  border-top: 1px solid #e3e8f0;
  flex-shrink: 0;
}

.ciccio-chip {
  background: #fff;
  border: 1px solid var(--inpal-blue);
  color: var(--inpal-blue);
  border-radius: 20px;
  padding: 4px 11px;
  font-size: 0.77rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.ciccio-chip:hover {
  background: var(--inpal-blue);
  color: #fff;
}

/* --- AREA INPUT --- */
.ciccio-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 8px;
  background: #fff;
  border-top: 1px solid #e3e8f0;
  flex-shrink: 0;
}

.ciccio-textarea {
  flex: 1;
  border: 1px solid #ced4da;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 0.875rem;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
  line-height: 1.4;
  max-height: 90px;
  overflow-y: auto;
}

.ciccio-textarea:focus {
  border-color: var(--inpal-blue);
  box-shadow: 0 0 0 2px rgba(0,61,165,0.15);
}

.ciccio-send-btn {
  background: var(--inpal-blue);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
  font-size: 0.9rem;
}

.ciccio-send-btn:hover {
  background: var(--inpal-blue-dark);
}

.ciccio-send-btn:active {
  transform: scale(0.93);
}

.ciccio-send-btn:disabled {
  background: #a0a8b8;
  cursor: not-allowed;
  transform: none;
}

/* --- NOTE A PIÈ DELLA CHAT --- */
.ciccio-footer-note {
  background: #f8f9fa;
  border-top: 1px solid #e3e8f0;
  padding: 5px 12px;
  font-size: 0.72rem;
  color: #6c757d;
  text-align: center;
  flex-shrink: 0;
}

.ciccio-footer-note a {
  color: var(--inpal-blue);
  text-decoration: none;
}

.ciccio-footer-note a:hover {
  text-decoration: underline;
}

/* --- RESPONSIVE --- */
@media (max-width: 480px) {
  .ciccio-toggle-btn {
    bottom: 16px;
    right: 16px;
    padding: 5px 12px 5px 5px;
  }

  .ciccio-btn-avatar {
    width: 48px;
    height: 48px;
  }

  .ciccio-chat-window {
    bottom: 90px;
    right: 10px;
    left: 10px;
    width: auto;
    max-height: 72vh;
  }
}

/* Nasconde in stampa */
@media print {
  .ciccio-toggle-btn,
  .ciccio-chat-window { display: none !important; }
}

/* ============================================================
   CICCIOBOT – Avatar umanoide digitale
   ============================================================ */

/* Avatar CiccioBot nel pulsante (ritratto circolare) */
.ciccio-btn-avatar {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center top;
  border: 2px solid var(--inpal-gold);
  display: block;
  flex-shrink: 0;
  transition: filter 0.3s;
}

.ciccio-toggle-btn:hover .ciccio-btn-avatar {
  filter: brightness(1.05);
}

/* Anello luminoso animato intorno all'avatar (effetto AI) */
.ciccio-avatar-wrapper::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: conic-gradient(
    var(--inpal-gold) 0deg,
    transparent 60deg,
    var(--inpal-gold) 120deg,
    transparent 180deg,
    var(--inpal-gold) 240deg,
    transparent 300deg,
    var(--inpal-gold) 360deg
  );
  animation: ciccioRotateRing 3s linear infinite;
  opacity: 0.6;
  z-index: -1;
}

@keyframes ciccioRotateRing {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Header avatar nella finestra di chat */
.ciccio-header-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center top;
  border: 2px solid var(--inpal-gold);
  flex-shrink: 0;
  filter: contrast(1.05) saturate(1.1);
}

/* Avatar piccolo nei messaggi */
.ciccio-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center top;
  border: 1px solid var(--inpal-gold);
  flex-shrink: 0;
  align-self: flex-end;
}

/* ============================================================
   CICCIOBOT – Avatar animato e badge robot
   ============================================================ */

/* Wrapper avatar nel pulsante */
.ciccio-avatar-wrapper {
  position: relative;
  display: inline-block;
}

/* Pulsazione continua sull'avatar */
.ciccio-avatar-pulse {
  animation: ciccioPulse 2.5s ease-in-out infinite;
}

@keyframes ciccioPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--bs-warning-rgb), 0.5); }
  50%       { box-shadow: 0 0 0 8px rgba(var(--bs-warning-rgb), 0); }
}

/* .ciccio-bot-icon rimosso (non più usato) */

/* Wrapper avatar nell'header della chat */
.ciccio-header-avatar-wrap {
  position: relative;
  display: inline-block;
}

/* Badge robot nell'header */
.ciccio-header-bot-badge {
  position: absolute;
  bottom: -3px;
  right: -3px;
  background: var(--inpal-gold);
  color: var(--inpal-blue);
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  border: 1px solid #fff;
}
