/* ============================================================================
   av-core.css — Modulo CSS estratto da av.html
   AIVEK Vision — Generato automaticamente
   ============================================================================ */

/* Responsive AV chart styles */
.av-chart-wrapper { max-width: 100%; width: 100%; }
#avChartCanvas { display: block; max-width: 100% !important; width: 100% !important; height: auto !important; }

/* Mermaid diagram styles (rendered inside chat bubble) */
.av-diagram-wrapper {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 0;
}

.av-diagram-wrapper svg {
    max-width: 100%;
    height: auto;
    display: block;
}

.av-diagram-error {
    white-space: pre-wrap;
    font-size: 13px;
    opacity: 0.9;
}

/* Context Inspector panel styles (minimal, hidden by default) */
#contextInspector {
    position: fixed;
    top: 0;
    right: -320px; /* hidden by default */
    width: 320px;
    height: 100%;
    background: #0d0d0d;
    border-left: 1px solid #333;
    color: #e6e6e6;
    z-index: 1100;
    box-shadow: -8px 0 24px rgba(0,0,0,0.6);
    transition: right 220ms ease-in-out;
    font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
    padding: 16px;
    overflow-y: auto;
}
#contextInspector.open { right: 0; }
#contextInspector h3 { margin: 6px 0 8px 0; font-size: 14px; color: #fff; }
#contextInspector .ci-section { margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid #222; }
#contextInspector .ci-label { font-size: 12px; color: #9aa0a6; margin-bottom: 6px; display:block; }
#contextInspector .ci-value { font-size: 13px; color: #e6e6e6; }
#contextInspector .ci-bar { height: 8px; background: linear-gradient(90deg,#3b82f6,#7c3aed); border-radius:4px; margin-top:6px; }
#contextInspector .ci-list { list-style: none; padding-left: 0; margin: 6px 0 0 0; color: #cfcfcf; font-size: 13px; }
#contextInspector .ci-small { font-size: 12px; color: #aab0b6; }
.av-status {
    display: flex;
    justify-content: center;
    padding: 10px;
    margin-bottom: 10px;
}
.av-status-pill {
    padding: 10px 20px;
    border-radius: 25px;
    color: white;
    font-weight: bold;
    text-align: center;
    font-size: 14px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    background: linear-gradient(45deg, #667eea 0%, #764ba2 100%);
    background-size: 400% 400%;
    animation: gradientShift 2s ease infinite;
    animation-play-state: paused;
    will-change: auto;
}
.av-status-pill.thinking {
    animation-play-state: running;
    will-change: background-position;
}
.av-status-pill.ready {
    animation: none;
    background: linear-gradient(45deg, #28a745, #20c997);
    will-change: auto;
}
@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
.ai-message {
    position: relative;
}
/* ── Actions row under AI response ─────────────────────── */
.av-message-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid rgba(255,255,255,0.08);
    flex-wrap: wrap;
}

/* ── Confidence badge ─────────────────────────────────── */
.confidence-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,0.04);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 24px;
    padding: 8px 16px 8px 10px;
    opacity: 0;
    transform: translateY(8px) scale(0.96);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    flex: 0 0 auto;
}
.confidence-badge.appear {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.confidence-ring {
    width: 36px;
    height: 36px;
    position: relative;
    flex-shrink: 0;
}
.confidence-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
    filter: drop-shadow(0 0 3px currentColor);
}
.confidence-ring .ring-bg {
    fill: none;
    stroke: rgba(255,255,255,0.06);
    stroke-width: 2.5;
}
.confidence-ring .ring-fill {
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1);
}
.confidence-gauge {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    gap: 2px;
}
.confidence-number {
    font-size: 14px;
    font-weight: 700;
    color: #e6e6e6;
    letter-spacing: -0.02em;
}
.confidence-label {
    font-size: 10px;
    color: rgba(255,255,255,0.4);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* ── PDF download button ──────────────────────────────── */
.pdf-button-container {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) 0.12s;
    flex: 0 0 auto;
}
.pdf-button-container.appear {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.pdf-button-container .btn {
    background: linear-gradient(135deg, rgba(102,126,234,0.15), rgba(118,75,162,0.15));
    border: 1px solid rgba(102,126,234,0.25);
    color: #b4c2f0;
    border-radius: 24px;
    padding: 8px 18px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    gap: 7px;
    letter-spacing: 0.01em;
    white-space: nowrap;
}
.pdf-button-container .btn:hover {
    background: linear-gradient(135deg, rgba(102,126,234,0.28), rgba(118,75,162,0.28));
    border-color: rgba(102,126,234,0.45);
    color: #fff;
    box-shadow: 0 4px 16px rgba(102,126,234,0.2);
    transform: translateY(-1px);
}
.pdf-button-container .btn:active {
    transform: translateY(0);
    box-shadow: none;
}
/* spinner state while downloading */
.pdf-button-container .btn.downloading {
    pointer-events: none;
    opacity: 0.7;
}
.pdf-button-container .btn.downloading::before {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid rgba(180,194,240,0.3);
    border-top-color: #b4c2f0;
    border-radius: 50%;
    animation: pdfSpin 0.6s linear infinite;
}
@keyframes pdfSpin {
    to { transform: rotate(360deg); }
}
.ai-message {
    position: relative;
}
/* Switch iPhone-like */
.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
.switch input:checked + .slider {
    background-color: #667eea;
}
.switch input:checked + .slider:before {
    transform: translateX(26px);
}
.av-switch-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}
.av-switch-item:last-child {
    border-bottom: none;
}
.av-switch-label {
    font-weight: 500;
    color: white;
}
/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s ease-out;
}
.modal-content {
    background-color: #2c3e50;
    margin: 5% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    animation: slideIn 0.3s ease-out;
    position: relative;
}
.welcome-modal .modal-content {
    max-width: 600px;
    padding-bottom: 40px;
}
.modal-header {
    padding: 20px 30px;
    border-bottom: 1px solid #34495e;
    text-align: center;
}
.modal-header h2 {
    margin: 0;
    color: white;
    font-size: 24px;
    font-weight: 600;
}
.modal-body {
    padding: 30px;
    padding-bottom: 20px;
}
.welcome-hero {
    text-align: center;
    margin-bottom: 30px;
}
.welcome-kicker {
    color: #667eea;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}
.welcome-hero h3 {
    color: white;
    font-size: 20px;
    font-weight: 600;
    margin: 10px 0 15px 0;
}
.welcome-body {
    color: white;
    line-height: 1.6;
    margin: 0;
}
.section-label {
    font-weight: 600;
    color: white;
    margin-bottom: 15px;
    font-size: 16px;
}
.section-sub-label {
    color: white;
    font-size: 14px;
    margin-bottom: 20px;
    opacity: 0.8;
}
.av-switches {
    background: #34495e;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
}
.premium-section {
    margin-bottom: 30px;
    padding-bottom: 30px; /* Extra padding so floating button doesn't cover content */
}
.premium-description {
    color: white;
    font-size: 14px;
    margin-bottom: 15px;
    line-height: 1.5;
}
.premium-input-group {
    display: flex;
    gap: 10px;
}
.premium-input-group .form-control {
    flex: 1;
}
.av-note {
    color: white;
    font-size: 12px;
    text-align: center;
    margin-top: 15px;
    opacity: 0.7;
    font-style: italic;
}
.welcome-actions {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: transparent;
    padding: 25px 30px 30px 30px;
    text-align: center;
    border-radius: 0 0 12px 12px;
}
.welcome-actions .btn-primary {
    width: 100%;
    max-width: 300px;
    padding: 14px 24px;
    font-size: 16px;
}
.btn-primary, .btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}
.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}
.btn-secondary {
    background: #6c757d;
    color: white;
}
.btn-secondary:hover {
    background: #5a6268;
}
.form-control {
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}
.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
/* Bolle speciali per messaggi di errore */
.error-message {
    background: linear-gradient(to bottom right, white, red) !important;
    color: #000 !important;
    border: 2px solid #ff0000 !important;
    box-shadow: 0 8px 24px rgba(255, 0, 0, 0.3) !important;
}
.error-message strong,
.error-message b {
    color: #000 !important;
}


/* Patch: nascondi toggle CI (migrato da inline) */
#contextInspectorToggle { display: none !important; }

/* ── Light-theme overrides for actions row ────────────── */
body:not(.dark-mode) .av-message-actions {
    border-top-color: rgba(0,0,0,0.08);
}
body:not(.dark-mode) .confidence-badge {
    background: rgba(0,0,0,0.03);
    border-color: rgba(0,0,0,0.08);
}
body:not(.dark-mode) .confidence-number {
    color: #1a1a2e;
}
body:not(.dark-mode) .confidence-label {
    color: rgba(0,0,0,0.45);
}
body:not(.dark-mode) .confidence-ring .ring-bg {
    stroke: rgba(0,0,0,0.06);
}
body:not(.dark-mode) .pdf-button-container .btn {
    background: linear-gradient(135deg, rgba(102,126,234,0.08), rgba(118,75,162,0.08));
    border-color: rgba(102,126,234,0.2);
    color: #5b6abf;
}
body:not(.dark-mode) .pdf-button-container .btn:hover {
    background: linear-gradient(135deg, rgba(102,126,234,0.16), rgba(118,75,162,0.16));
    border-color: rgba(102,126,234,0.35);
    color: #3d4a9e;
    box-shadow: 0 4px 16px rgba(102,126,234,0.12);
}
