/* ══════════════════════════════════════════════
   Assistent d'Ajuda IA — FAB + Panell lateral
   ══════════════════════════════════════════════ */

/* ── FAB (Floating Action Button) ── */
.ajuda-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 22px;
    background: linear-gradient(135deg, #d9a441 0%, #b8862d 100%);
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-size: .92rem;
    font-weight: 600;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(217, 164, 65, .35), 0 2px 6px rgba(0,0,0,.3);
    transition: transform .2s, box-shadow .2s, background .2s;
    letter-spacing: .3px;
}

.ajuda-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 28px rgba(217, 164, 65, .45), 0 3px 10px rgba(0,0,0,.35);
    background: linear-gradient(135deg, #e0b04e 0%, #c99535 100%);
}

.ajuda-fab:active {
    transform: translateY(0);
}

.ajuda-fab svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Pols suau per cridar l'atenció */
@keyframes ajuda-pulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(217, 164, 65, .35), 0 0 0 0 rgba(217, 164, 65, .4); }
    50%      { box-shadow: 0 4px 20px rgba(217, 164, 65, .35), 0 0 0 10px rgba(217, 164, 65, 0); }
}

.ajuda-fab--pulse {
    animation: ajuda-pulse 2.5s ease-in-out infinite;
}

/* Amagar FAB quan el panell és obert */
.ajuda-fab.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(.8);
}

/* ── Overlay ── */
.ajuda-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 290;
}

.ajuda-overlay.open {
    display: block;
}

/* ── Panell lateral ── */
.ajuda-panel {
    position: fixed;
    top: 0;
    bottom: 0;
    right: -400px;
    width: 380px;
    background: linear-gradient(180deg, #111827 0%, #0f172a 100%);
    border-left: 1px solid rgba(255,255,255,.08);
    z-index: 310;
    transition: right .3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    font-family: 'Inter', sans-serif;
}

.ajuda-panel.open {
    right: 0;
}

/* ── Header del panell ── */
.ajuda-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.15rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
}

.ajuda-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #FFDE59;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: .3px;
}

.ajuda-header-title svg {
    width: 22px;
    height: 22px;
    opacity: .9;
}

.ajuda-close {
    background: none;
    border: none;
    color: #d1d5db;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: background .15s, color .15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ajuda-close:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
}

.ajuda-close svg {
    width: 20px;
    height: 20px;
}

/* ── Cos del panell ── */
.ajuda-body {
    flex: 1;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    overflow-y: auto;
}

/* ── Grup de camp (label + input) ── */
.ajuda-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ajuda-label {
    color: #9ca3af;
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.ajuda-select {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,.12);
    background: rgba(255,255,255,.06);
    color: #e5e5e5;
    font-size: .9rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: border-color .2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.ajuda-select:focus {
    outline: none;
    border-color: #d9a441;
}

.ajuda-textarea {
    width: 100%;
    min-height: 120px;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,.12);
    background: rgba(255,255,255,.06);
    color: #e5e5e5;
    font-size: .9rem;
    font-family: 'Inter', sans-serif;
    resize: vertical;
    transition: border-color .2s;
    line-height: 1.5;
}

.ajuda-textarea:focus {
    outline: none;
    border-color: #d9a441;
}

.ajuda-textarea::placeholder {
    color: #6b7280;
}

/* ── Botó Enviar ── */
.ajuda-send {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 20px;
    background: linear-gradient(135deg, #d9a441 0%, #b8862d 100%);
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-size: .92rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background .2s, transform .1s;
}

.ajuda-send:hover {
    background: linear-gradient(135deg, #e0b04e 0%, #c99535 100%);
}

.ajuda-send:active {
    transform: scale(.98);
}

.ajuda-send:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none;
}

.ajuda-send svg {
    width: 16px;
    height: 16px;
}

/* ── Spinner d'enviament ── */
.ajuda-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ajuda-spin .6s linear infinite;
}

@keyframes ajuda-spin {
    to { transform: rotate(360deg); }
}

/* ── Zona de resposta ── */
.ajuda-response {
    display: none;
    flex-direction: column;
    gap: 12px;
}

.ajuda-response.visible {
    display: flex;
}

.ajuda-response-box {
    background: rgba(255,255,255,.04);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 10px;
    padding: 16px;
    color: #d1d5db;
    font-size: .88rem;
    line-height: 1.65;
    max-height: 350px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(217,164,65,.4) transparent;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.ajuda-response-box strong,
.ajuda-response-box b {
    color: #FFDE59;
}

/* ── Feedback (m'agrada / no m'agrada) ── */
.ajuda-feedback {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    flex-wrap: wrap;
}

.ajuda-feedback-label {
    color: #9ca3af;
    font-size: .8rem;
    font-weight: 500;
}

.ajuda-feedback-buttons {
    display: flex;
    gap: 6px;
}

.ajuda-feedback-btn {
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .1s;
    line-height: 1;
    opacity: .7;
}

.ajuda-feedback-btn:hover {
    background: rgba(255,255,255,.12);
    border-color: rgba(255,255,255,.2);
    opacity: 1;
    transform: scale(1.1);
}

.ajuda-feedback-btn.active {
    opacity: 1;
    background: rgba(217, 164, 65, .2);
    border-color: #d9a441;
    transform: scale(1.1);
}

.ajuda-feedback-btn:disabled {
    cursor: default;
    transform: none;
}

.ajuda-feedback-btn:disabled:not(.active) {
    opacity: .3;
}

.ajuda-feedback-msg {
    display: none;
    color: #6ee7b7;
    font-size: .78rem;
    font-weight: 500;
    width: 100%;
}

.ajuda-feedback-msg.visible {
    display: block;
}

/* ── Botó "Nova pregunta" ── */
.ajuda-reset {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    background: rgba(255,255,255,.06);
    color: #d1d5db;
    font-family: 'Inter', sans-serif;
    font-size: .85rem;
    font-weight: 500;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s, color .15s;
}

.ajuda-reset:hover {
    background: rgba(255,255,255,.1);
    color: #fff;
}

/* ── Secció d'incidència ── */
.ajuda-incidencia {
    margin-top: 12px;
    padding: 14px;
    background: rgba(217, 164, 65, .08);
    border: 1px solid rgba(217, 164, 65, .25);
    border-radius: 10px;
}

.ajuda-incidencia-text {
    color: #d1d5db;
    font-size: .85rem;
    line-height: 1.5;
    margin: 0 0 10px 0;
}

.ajuda-btn-incidencia {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 10px 16px;
    background: rgba(217, 164, 65, .15);
    color: #d9a441;
    font-family: 'Inter', sans-serif;
    font-size: .85rem;
    font-weight: 600;
    border: 1px solid rgba(217, 164, 65, .3);
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s, color .15s;
    justify-content: center;
}

.ajuda-btn-incidencia:hover {
    background: rgba(217, 164, 65, .25);
    color: #e0b04e;
}

.ajuda-btn-incidencia svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ── Footer amb botó de contacte ── */
.ajuda-footer {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,.08);
}

.ajuda-btn-contacte {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    background: rgba(255,255,255,.04);
    color: #9ca3af;
    font-family: 'Inter', sans-serif;
    font-size: .82rem;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 8px;
    transition: background .15s, color .15s;
}

.ajuda-btn-contacte:hover {
    background: rgba(255,255,255,.08);
    color: #d1d5db;
}

.ajuda-btn-contacte svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.ajuda-reset svg {
    width: 14px;
    height: 14px;
}

/* ── Missatge d'error ── */
.ajuda-error {
    display: none;
    padding: 12px 14px;
    background: rgba(239, 68, 68, .12);
    border: 1px solid rgba(239, 68, 68, .25);
    border-radius: 8px;
    color: #fca5a5;
    font-size: .85rem;
    line-height: 1.5;
}

.ajuda-error.visible {
    display: block;
}

/* ── Responsive ── */
@media (max-width: 480px) {
    .ajuda-panel {
        width: 100%;
        right: -100%;
    }
    .ajuda-fab span {
        display: none;
    }
    .ajuda-fab {
        padding: 14px;
        border-radius: 50%;
    }
}

@media (max-width: 768px) {
    .ajuda-panel {
        width: 320px;
        right: -340px;
    }
}
