* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}



@keyframes gradientShift {

    0%,
    100% {
        transform: translate(0, 0) rotate(0deg);
    }

    33% {
        transform: translate(5%, 5%) rotate(120deg);
    }

    66% {
        transform: translate(-5%, 5%) rotate(240deg);
    }
}

/* LOGIN PAGE STYLES */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

.login-box {
    background: rgba(17, 24, 39, 0.8);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 48px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    box-shadow: 0 10px 10px rgba(0, 0, 0, 0.4);
    width: 100%;
    max-width: 420px;
}

.login-title {
    color: #f9fafb;
    text-align: center;
    margin: 0 0 12px 0;
    font-weight: 700;
    font-size: 32px;
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.login-subtitle {
    color: #94a3b8;
    text-align: center;
    margin-bottom: 32px;
    font-size: 14px;
}

.form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    color: #cbd5e1;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid rgba(99, 102, 241, 0.2);
    background: rgba(30, 41, 59, 0.5);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    font-size: 15px;
    color: #f9fafb;
    outline: none;
    transition: all 0.3s ease;
}

.form-input::placeholder {
    color: #64748b;
}

.form-input:focus {
    border-color: #6366f1;
    background: rgba(30, 41, 59, 0.7);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.login-button {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #6366f1 0%, #0080AD 100%);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}

.login-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(99, 102, 241, 0.4);
}

.login-button:active {
    transform: translateY(0);
}

.error-message {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid rgba(239, 68, 68, 0.3);
    font-size: 14px;
    text-align: center;
    display: none;
}

.error-message.show {
    display: block;
    animation: shake 0.5s;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-10px);
    }

    75% {
        transform: translateX(10px);
    }
}

/* APP STYLES */
.app-container {
    max-width: 950px;
    margin:0 auto;
    width: 100%;
}

.container {
    display: flex;
    gap: 24px;
    max-width: 1600px;
    margin: 0 auto;
    height: 500px;
    position: relative;
    z-index: 1;
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap; 
    border: 0;
  }

  input#messageInput:focus-visible {
    outline: 2px solid #00628B !important;
    outline-offset: 2px !important;
  }

.chat-container {
    flex: 1;
    background: transparent;
    padding: 0 32px;
    display: flex;
    flex-direction: column;
    margin-bottom: 40px;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Toolbar ingrandimento dentro #chatMessages (sticky in alto a destra) */
.chat-toolbar--inside {
    flex-shrink: 0;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 2;
    padding-bottom: 8px;
    margin-bottom: 4px;
    background: transparent;
}

.chat-messages-body {
    /* Non usare flex:1 qui: con i messaggi che crescono il flex item può “rompere” il contenimento
       e in DevTools sembra fuori da #chatMessages; l’altezza segue il contenuto, lo scroll resta su #chatMessages */
    flex: 0 1 auto;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    /* Respiro sotto l’ultimo messaggio rispetto al bordo di #chatMessages */
    padding-bottom: 28px;
}

.chat-expand-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 12px;
    background: rgba(17, 24, 39, 0.08);
    color: #00628b;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.chat-expand-btn:hover {
    background: rgba(0, 98, 139, 0.18);
    color: #102036;
}

.chat-expand-btn:focus-visible {
    outline: 2px solid #5bb4ea;
    outline-offset: 2px;
    color: #00628b;
    background: #fff;
}

.chat-expand-btn.is-expanded {
    background: #fff !important;
    border: 1px solid #0f729c;
}

/* Una sola icona: il tema può annullare [hidden] sui svg */
.chat-expand-btn .chat-expand-icon {
    display: block;
    flex-shrink: 0;
}

.chat-expand-btn .chat-expand-icon--close {
    display: none !important;
}

.chat-expand-btn.is-expanded .chat-expand-icon--open {
    display: none !important;
}

.chat-expand-btn.is-expanded .chat-expand-icon--close {
    display: block !important;
}

/* Vista popup quasi a tutto schermo */
body.isd-chat-fullscreen {
    overflow: hidden;
}

body.isd-chat-fullscreen .app-container {
    max-width: none;
}

body.isd-chat-fullscreen .container {
    height: 100%;
    min-height: 100dvh;
    max-width: none;
    margin: 0;
}

body.isd-chat-fullscreen .chat-container {
    position: fixed;
    inset: 0;
    /* Sopra header sticky / modali del tema (figlio diretto di body dopo append) */
    z-index: 2147483646;
    margin: 0;
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    background: rgba(15, 23, 42, 0.82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    box-sizing: border-box;
}

body.isd-chat-fullscreen .chat-main {
    width: 100%;
    max-width: 960px;
    flex: 1;
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
}

body.isd-chat-fullscreen .chat-messages {
    flex: 1;
    min-height: 120px;
    max-height: none;
}

body.isd-chat-fullscreen .debug-panel {
    display: none !important;
}

body.isd-chat-fullscreen #chatIco {
    visibility: hidden;
    pointer-events: none;
}

.debug-panel {
    width: 420px;
    background: rgba(17, 24, 39, 0.8);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 24px;
    border: 1px solid rgba(99, 102, 241, 0.1);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
    font-size: 12px;
}

h1 {
    color: #f9fafb;
    text-align: center;
    margin: 0 0 24px 0;
    font-weight: 700;
    font-size: 32px;
    background: linear-gradient(135deg, #0080AD 0%, #0080AD 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.debug-title {
    color: #10b981;
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 20px 0;
    text-align: center;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.chat-messages {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 24px;
    margin-bottom: 24px;
    background: white;
    border-radius: 50px;
    margin-bottom:20px;
    box-shadow:
        0 20px 60px rgba(111, 111,111, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

#chatIco{
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    max-width: 870px;
    margin: 0 auto;
    width: 100%;
}


.isd-ico{
    background-position: left 10px center;
    background-repeat: no-repeat;
    background-size: 20px;
    color:#16263e;
    border-radius: 40px;
    border:1px solid #5bb4ea;
    padding:5px 10px 5px 40px;
    margin:0 !important;
    transition: transform 0.2s ease;

}

.isd-ico:hover{
    cursor: pointer;
    transform: scale(1.05);
}

.isd-ico.ico-protezione{
    background-image: url('../img/ico-protezione.png');
}
.isd-ico.ico-supporto{
    background-image: url('../img/ico-supporto.png');
}
.isd-ico.ico-installazione{
    background-image: url('../img/ico-installazione.png');
}
.isd-ico.ico-backup{
    background-image: url('../img/ico-backup.png');
}

.isd-ico.ico-noleggio{
    background-image: url('../img/ico-noleggio.png');
}

.isd-ico.ico-stampanti{
    background-image: url('../img/ico-stampanti.png');
}
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(30, 41, 59, 0.3);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.3);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.5);
}

.debug-log {
    flex: 1;
    overflow-y: auto;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 12px;
    padding: 10px;
    border: 1px solid rgba(71, 85, 105, 0.2);
}

.debug-log::-webkit-scrollbar {
    width: 6px;
}

.debug-log::-webkit-scrollbar-track {
    background: rgba(30, 41, 59, 0.3);
    border-radius: 3px;
}

.debug-log::-webkit-scrollbar-thumb {
    background: rgba(16, 185, 129, 0.3);
    border-radius: 3px;
}

.message {
    margin-bottom: 10px;
    padding: 12px 20px;
    font-size: 1rem;
    border-radius: 16px;
    line-height: 1.5;
    max-width: 85%;
    word-wrap: break-word;
    animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    background: #e6f0f5;
    color: #00628B;
    margin-left: auto;
    text-align: right;
}

.assistant-message {
    background: #ececec;
    font-size: 1rem;
    color: #00628B;
    border-left: 4px solid #00628B;
    padding: 10px 20px;
    border-radius: 12px;
    max-width: 85%;
}

.result-message {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    margin: 12px 0;
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4);
}

.markdown-content {
    background: #ececec;
    color: #00628b;
    backdrop-filter: blur(10px);
    padding: 24px;
    border-radius: 16px;
    border: 1px solid rgba(71, 85, 105, 0.3);
    max-width: 95%;
    margin: 10px 0;
}

.markdown-content h1 {
    color: #203655;
    font-size: 26px;
    margin-top: 20px;
    margin-bottom: 12px;
    border-bottom: 2px solid rgba(16, 185, 129, 0.4);
    padding-bottom: 8px;
    background: none;
    -webkit-text-fill-color: #203655;
}

.markdown-content h2 {
    color: #203655;
    font-size: 22px;
    margin-top: 18px;
    margin-bottom: 10px;
    font-weight: bold !important;
}

.markdown-content h3 {
    color: #203655;
    font-size: 18px;
    margin-top: 16px;
    margin-bottom: 8px;
}

.markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    background: #e6f0f5;
    border-radius: 8px;
    overflow: hidden;
}

.markdown-content table th {
    background: #5BB4EA;
    color: #203655;
    padding: 14px;
    text-align: left;
    font-weight: 700;
    border-bottom: 2px solid rgba(99, 102, 241, 0.3);
    line-height: 1;
}

.markdown-content table td {
    padding: 12px 14px;
    border: 1px solid #00628B;
    color: #203655;
    line-height: 1;
}

.markdown-content table tr:nth-child(even) {
    background: rgba(30, 41, 59, 0.3);
}

.markdown-content table tr:hover {
    background: rgba(99, 102, 241, 0.1);
}

.markdown-content ul,
.markdown-content ol {
    margin: 12px 0;
    padding-left: 30px;
}

.markdown-content li {
    margin: 2px 0;
    line-height: 1.5;
    color: #00628B;
}

.markdown-content p {
    margin: 12px 0;
    line-height: 1.5;
    color: #00628B;
}

.markdown-content strong {
    color: #00628B;
    font-weight: 700;
}

.markdown-content hr {
    border: none;
    border-top: 1px solid rgba(71, 85, 105, 0.3);
    margin: 24px 0;
}

.markdown-content a {
    color: #112035;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.markdown-content a:hover {
    color: #00628B;
    text-decoration: underline;
}

/* CTA: link al prodotto (risposta finalize → product_link) */
.message.product-link-cta  {
    max-width: 300px;
    background-color: #5cb4ea;
    border-radius: 30px;
    text-align: center;
}

a.product-link-btn {
    color:#203655;
}

.message.product-link-cta:hover {
    background-color:#203655;
}

.message.product-link-cta:hover a{
    color:#fff;
}

.markdown-content code {
    background: rgba(99, 102, 241, 0.1);
    color: #00628B;
    padding: 3px 8px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
    font-size: 13px;
}

.markdown-content pre {
    background: #e6f0f5;
    padding: 10px;
    border-radius: 8px;
    overflow-x: auto;
    border: 1px solid rgba(71, 85, 105, 0.2);
}

.question-card {
    background: #ececec;
    color: #00628b;
    padding: 10px;
    border-radius: 15px;
    margin: 10px 0;
    max-width: 85%;
}

.question-text {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    line-height: 1.4;
}

.options-label {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 10px;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.option-item {
    background: #fff;
    backdrop-filter: blur(10px);
    padding: 10px 16px;
    font-size: 1rem;
    margin: 8px 0;
    border-radius: 10px;
    border-left: 4px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
    cursor: pointer;
}

.option-item:hover {
    background: #5BB4EA;
    border-left-color: #112035;
    color:#203655 ;
    transform: translateX(5px);
}

.option-number {
    display: inline-block;
    background:#e6f0f5;
    width: 28px;
    height: 28px;
    line-height: 28px;
    text-align: center;
    border-radius: 50%;
    margin-right: 10px;
    font-weight: 700;
    font-size: 14px;
}

.option-text {
    font-size: 1rem;
    line-height: 1.5;
}

.simple-question {
    background: #ececec;
    color: #00628B;
    padding: 10px 20px;
    border-radius: 12px;
    border-left: 4px solid #00628B;
    margin: 10px 0;
    font-size: 1rem;
    font-weight: 400;
    max-width: 85%;
}

.debug-node {
    margin-bottom: 16px;
    border-left: 3px solid #10b981;
    padding-left: 12px;
    background: rgba(16, 185, 129, 0.05);
    padding: 12px 12px 12px 16px;
    border-radius: 0 8px 8px 0;
}

.node-title {
    color: #10b981;
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 8px;
    letter-spacing: 0.05em;
}

.node-content {
    color: #94a3b8;
    line-height: 1.5;
}

.state-key {
    color: #f472b6;
    font-weight: 700;
}

.state-value {
    color: #22d3ee;
}

.input-container {
    display: flex;
    gap: 12px;
    align-items: center;
    border-radius: 50px;
    background: #fff;
    padding:5px;
    padding-right: 10px;
    box-shadow:10px 0px 18px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

#messageInput {
    flex: 1;
    padding: 16px 20px;
    border:0 !important;
    background: transparent;
    border-top-left-radius:50px;
    border-bottom-left-radius:50px;
    font-size: 16px;
    color: #000;
    outline: none;
    transition: all 0.3s ease;
}

#messageInput::placeholder {
    color: #64748b;
}

/*#messageInput:focus {
    border-color: #6366f1;
    background: rgba(30, 41, 59, 0.7);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}
*/
#sendButton {
    padding: 16px 28px;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    font-size: 15px;
    transition: all 0.3s ease;
}

#sendButton:hover:not(:disabled) {
    background-color: #102036;
}

#sendButton:active:not(:disabled) {
    transform: translateY(0);
}

#sendButton:disabled {
    background: rgba(71, 85, 105, 0.5);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.loading {
    color: #00628B;
    font-style: italic;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

.error {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    padding: 14px 18px;
    border-radius: 12px;
    margin: 12px 0;
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.3);
}

.intro {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(168, 85, 247, 0.15) 100%);
    backdrop-filter: blur(10px);
    padding: 20px 24px;
    border-radius: 16px;
    margin-bottom: 24px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    color: #cbd5e1;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.1);
}

.intro strong {
    color: #f9fafb;
    font-weight: 700;
}

.debug-controls {
    margin-bottom: 16px;
    display: flex;
    gap: 8px;
}

.debug-btn {
    padding: 8px 14px;
    background: rgba(51, 65, 85, 0.5);
    color: #cbd5e1;
    border: 1px solid rgba(71, 85, 105, 0.3);
    border-radius: 8px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.debug-btn:hover {
    background: rgba(71, 85, 105, 0.5);
    border-color: rgba(99, 102, 241, 0.4);
}

.debug-btn.active {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-color: #10b981;
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.workflow-status {
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(10px);
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 11px;
    border: 1px solid rgba(71, 85, 105, 0.3);
    font-weight: 600;
    letter-spacing: 0.05em;
}

.status-running {
    color: #fbbf24;
    border-color: rgba(251, 191, 36, 0.3);
    background: rgba(251, 191, 36, 0.1);
}

.status-complete {
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.1);
}

@media (max-width: 1024px) {
    .container {
        flex-direction: column;
    }

    .debug-panel {
        width: auto;
        height: 300px;
    }
}