/* ************************************************************
   SECRETARIA MARIA IA — Widget de Chat Flutuante
   Colegio Sabiracema | Meet Digital
   Prefixo: ac1 (AI Chat 01)
   ************************************************************ */

/* === VARIAVEIS DO WIDGET === */
:root {
    --ac1-primary: #1a5276;
    --ac1-primary-light: #2980b9;
    --ac1-primary-dark: #0e3450;
    --ac1-accent: #27ae60;
    --ac1-accent-light: #2ecc71;
    --ac1-bg-chat: #f8f9fa;
    --ac1-bg-maria: #eef2f7;
    --ac1-bg-user: var(--ac1-primary);
    --ac1-text: #2c3e50;
    --ac1-text-light: #7f8c8d;
    --ac1-text-white: #ffffff;
    --ac1-border: #e0e6ed;
    --ac1-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    --ac1-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --ac1-radius: 16px;
    --ac1-radius-sm: 12px;
    --ac1-radius-msg: 18px;
    --ac1-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --ac1-font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --ac1-z-index: 9990;
}

/* === CONTAINER PRINCIPAL === */
.ac1-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: var(--ac1-z-index);
    font-family: var(--ac1-font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--ac1-text);
    -webkit-font-smoothing: antialiased;
}

/* === BOTAO FLUTUANTE (FAB) === */
.ac1-fab {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    background: var(--ac1-primary);
    color: var(--ac1-text-white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--ac1-shadow);
    transition: transform var(--ac1-transition), box-shadow var(--ac1-transition);
    position: relative;
    overflow: hidden;
    padding: 0;
}

.ac1-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.ac1-fab:focus-visible {
    outline: 3px solid var(--ac1-accent);
    outline-offset: 3px;
}

.ac1-fab__avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.ac1-fab__icon {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

.ac1-fab__badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: var(--ac1-accent);
    border-radius: 50%;
    border: 2px solid #fff;
    animation: ac1-pulse 2s ease-in-out infinite;
}

.ac1-fab--hidden {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

/* === BOLHA DE SAUDACAO === */
.ac1-greeting {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 300px;
    background: #ffffff;
    border-radius: var(--ac1-radius);
    box-shadow: var(--ac1-shadow);
    padding: 16px;
    opacity: 0;
    transform: translateY(16px) scale(0.95);
    transition: opacity var(--ac1-transition), transform var(--ac1-transition);
    pointer-events: none;
}

.ac1-greeting--visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.ac1-greeting__header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.ac1-greeting__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--ac1-primary-light);
}

.ac1-greeting__name {
    font-weight: 600;
    font-size: 13px;
    color: var(--ac1-text);
}

.ac1-greeting__role {
    font-size: 11px;
    color: var(--ac1-text-light);
}

.ac1-greeting__text {
    font-size: 14px;
    color: var(--ac1-text);
    line-height: 1.5;
    margin-bottom: 12px;
}

.ac1-greeting__btn {
    display: block;
    width: 100%;
    padding: 10px 16px;
    background: var(--ac1-primary);
    color: var(--ac1-text-white);
    border: none;
    border-radius: var(--ac1-radius-sm);
    font-family: var(--ac1-font);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--ac1-transition);
    text-align: center;
}

.ac1-greeting__btn:hover {
    background: var(--ac1-primary-dark);
}

.ac1-greeting__btn:focus-visible {
    outline: 3px solid var(--ac1-accent);
    outline-offset: 2px;
}

.ac1-greeting__close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--ac1-text-light);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background var(--ac1-transition);
    padding: 0;
    line-height: 1;
}

.ac1-greeting__close:hover {
    background: var(--ac1-border);
}

/* === JANELA DO CHAT === */
.ac1-chat {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 380px;
    height: 520px;
    background: #ffffff;
    border-radius: var(--ac1-radius);
    box-shadow: var(--ac1-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: scale(0.92) translateY(16px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
}

.ac1-chat--open {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

/* === HEADER DO CHAT === */
.ac1-chat__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--ac1-primary);
    color: var(--ac1-text-white);
    flex-shrink: 0;
}

.ac1-chat__header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

.ac1-chat__header-info {
    flex: 1;
    min-width: 0;
}

.ac1-chat__header-name {
    font-weight: 600;
    font-size: 15px;
}

.ac1-chat__header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.85;
}

.ac1-chat__header-dot {
    width: 8px;
    height: 8px;
    background: var(--ac1-accent-light);
    border-radius: 50%;
    animation: ac1-pulse 2s ease-in-out infinite;
}

.ac1-chat__close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: var(--ac1-text-white);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: background var(--ac1-transition);
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
}

.ac1-chat__close:hover {
    background: rgba(255, 255, 255, 0.25);
}

.ac1-chat__close:focus-visible {
    outline: 2px solid var(--ac1-text-white);
    outline-offset: 2px;
}

/* === AREA DE MENSAGENS === */
.ac1-chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--ac1-bg-chat);
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.ac1-chat__messages::-webkit-scrollbar {
    width: 4px;
}

.ac1-chat__messages::-webkit-scrollbar-track {
    background: transparent;
}

.ac1-chat__messages::-webkit-scrollbar-thumb {
    background: var(--ac1-border);
    border-radius: 4px;
}

/* === MENSAGEM (BOLHA) === */
.ac1-msg {
    display: flex;
    gap: 8px;
    max-width: 85%;
    animation: ac1-msgIn 0.3s ease-out;
}

.ac1-msg--maria {
    align-self: flex-start;
}

.ac1-msg--user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ac1-msg__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    margin-top: 2px;
}

.ac1-msg__bubble {
    padding: 10px 14px;
    border-radius: var(--ac1-radius-msg);
    word-wrap: break-word;
    overflow-wrap: break-word;
    font-size: 14px;
    line-height: 1.55;
}

.ac1-msg--maria .ac1-msg__bubble {
    background: var(--ac1-bg-maria);
    color: var(--ac1-text);
    border-bottom-left-radius: 6px;
}

.ac1-msg--user .ac1-msg__bubble {
    background: var(--ac1-bg-user);
    color: var(--ac1-text-white);
    border-bottom-right-radius: 6px;
}

.ac1-msg__time {
    font-size: 11px;
    color: var(--ac1-text-light);
    margin-top: 4px;
    padding: 0 4px;
}

.ac1-msg--user .ac1-msg__time {
    text-align: right;
}

/* === TYPING INDICATOR === */
.ac1-typing {
    display: none;
    align-self: flex-start;
    align-items: center;
    gap: 8px;
    padding: 0 4px;
}

.ac1-typing--visible {
    display: flex;
}

.ac1-typing__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.ac1-typing__dots {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--ac1-bg-maria);
    border-radius: var(--ac1-radius-msg);
    border-bottom-left-radius: 6px;
}

.ac1-typing__dot {
    width: 8px;
    height: 8px;
    background: var(--ac1-text-light);
    border-radius: 50%;
    animation: ac1-bounce 1.4s ease-in-out infinite;
}

.ac1-typing__dot:nth-child(2) {
    animation-delay: 0.2s;
}

.ac1-typing__dot:nth-child(3) {
    animation-delay: 0.4s;
}

/* === BOTOES DE SUGESTAO === */
.ac1-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 4px;
    animation: ac1-msgIn 0.3s ease-out;
}

.ac1-suggestions__btn {
    padding: 8px 14px;
    background: #ffffff;
    color: var(--ac1-primary);
    border: 1.5px solid var(--ac1-primary);
    border-radius: 20px;
    font-family: var(--ac1-font);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--ac1-transition);
    white-space: nowrap;
}

.ac1-suggestions__btn:hover {
    background: var(--ac1-primary);
    color: var(--ac1-text-white);
}

.ac1-suggestions__btn:focus-visible {
    outline: 3px solid var(--ac1-accent);
    outline-offset: 2px;
}

/* === IDENTIFICACAO POR TELEFONE (Sprint 6) === */
.ac1-identify {
    padding: 4px 0;
    text-align: center;
    animation: ac1-msgIn 0.3s ease-out;
}

.ac1-identify__link {
    background: none;
    border: none;
    color: var(--ac1-primary);
    font-family: var(--ac1-font);
    font-size: 12px;
    cursor: pointer;
    text-decoration: underline;
    opacity: 0.75;
    transition: opacity var(--ac1-transition);
    padding: 4px 0;
}

.ac1-identify__link:hover {
    opacity: 1;
}

.ac1-identify__link:focus-visible {
    outline: 3px solid var(--ac1-accent);
    outline-offset: 2px;
}

.ac1-identify--form {
    background: #f8f9fb;
    border-radius: var(--ac1-radius-sm);
    padding: 12px;
}

.ac1-identify__label {
    font-family: var(--ac1-font);
    font-size: 13px;
    color: var(--ac1-text-dark);
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.ac1-identify__row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ac1-identify__input {
    flex: 1;
    padding: 8px 12px;
    border: 1.5px solid #d1d5db;
    border-radius: var(--ac1-radius-sm);
    font-family: var(--ac1-font);
    font-size: 13px;
    color: var(--ac1-text-dark);
    outline: none;
    transition: border-color var(--ac1-transition);
}

.ac1-identify__input:focus {
    border-color: var(--ac1-primary);
}

.ac1-identify__btn {
    padding: 8px 16px;
    background: var(--ac1-primary);
    color: var(--ac1-text-white);
    border: none;
    border-radius: var(--ac1-radius-sm);
    font-family: var(--ac1-font);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--ac1-transition);
    white-space: nowrap;
}

.ac1-identify__btn:hover {
    background: var(--ac1-primary-dark, #1a4c8c);
}

.ac1-identify__btn:focus-visible {
    outline: 3px solid var(--ac1-accent);
    outline-offset: 2px;
}

.ac1-identify__cancel {
    display: block;
    margin: 8px auto 0;
    background: none;
    border: none;
    color: #6b7280;
    font-family: var(--ac1-font);
    font-size: 11px;
    cursor: pointer;
    text-decoration: underline;
    padding: 2px 0;
}

.ac1-identify__cancel:hover {
    color: var(--ac1-text-dark);
}

/* === CTA BUTTONS === */
.ac1-cta {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 0;
    animation: ac1-msgIn 0.3s ease-out;
}

.ac1-cta__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--ac1-radius-sm);
    font-family: var(--ac1-font);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--ac1-transition);
    border: none;
    text-align: center;
}

.ac1-cta__btn--whatsapp {
    background: #25d366;
    color: #ffffff;
}

.ac1-cta__btn--whatsapp:hover {
    background: #1da851;
}

.ac1-cta__btn--phone {
    background: var(--ac1-primary);
    color: var(--ac1-text-white);
}

.ac1-cta__btn--phone:hover {
    background: var(--ac1-primary-dark);
}

.ac1-cta__btn--continue {
    background: transparent;
    color: var(--ac1-text-light);
    border: 1px solid var(--ac1-border);
}

.ac1-cta__btn--continue:hover {
    background: var(--ac1-bg-chat);
    color: var(--ac1-text);
}

.ac1-cta__btn:focus-visible {
    outline: 3px solid var(--ac1-accent);
    outline-offset: 2px;
}

/* === INPUT DO CHAT === */
.ac1-chat__input {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--ac1-border);
    background: #ffffff;
    flex-shrink: 0;
}

.ac1-chat__textarea {
    flex: 1;
    border: 1px solid var(--ac1-border);
    border-radius: 24px;
    padding: 10px 16px;
    font-family: var(--ac1-font);
    font-size: 14px;
    color: var(--ac1-text);
    resize: none;
    outline: none;
    max-height: 80px;
    min-height: 40px;
    line-height: 1.4;
    transition: border-color var(--ac1-transition);
    background: var(--ac1-bg-chat);
}

.ac1-chat__textarea:focus {
    border-color: var(--ac1-primary-light);
}

.ac1-chat__textarea::placeholder {
    color: var(--ac1-text-light);
}

.ac1-chat__send {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--ac1-primary);
    color: var(--ac1-text-white);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--ac1-transition), transform var(--ac1-transition);
    flex-shrink: 0;
    padding: 0;
}

.ac1-chat__send:hover {
    background: var(--ac1-primary-dark);
    transform: scale(1.05);
}

.ac1-chat__send:focus-visible {
    outline: 3px solid var(--ac1-accent);
    outline-offset: 2px;
}

.ac1-chat__send:disabled {
    background: var(--ac1-border);
    cursor: not-allowed;
    transform: none;
}

.ac1-chat__send-icon {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* === LGPD BANNER === */
.ac1-lgpd {
    padding: 12px 16px;
    background: #fef9e7;
    border-top: 1px solid #f9e79f;
    font-size: 12px;
    color: var(--ac1-text);
    text-align: center;
    flex-shrink: 0;
}

.ac1-lgpd a {
    color: var(--ac1-primary-light);
    text-decoration: underline;
}

.ac1-lgpd__btn {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 16px;
    background: var(--ac1-primary);
    color: var(--ac1-text-white);
    border: none;
    border-radius: 16px;
    font-family: var(--ac1-font);
    font-size: 12px;
    cursor: pointer;
    transition: background var(--ac1-transition);
}

.ac1-lgpd__btn:hover {
    background: var(--ac1-primary-dark);
}

/* === FEEDBACK (AVALIACAO) === */
.ac1-feedback {
    padding: 12px 16px;
    background: #ffffff;
    border-radius: var(--ac1-radius-sm);
    box-shadow: var(--ac1-shadow-sm);
    text-align: center;
    animation: ac1-msgIn 0.3s ease-out;
}

.ac1-feedback__text {
    font-size: 13px;
    color: var(--ac1-text);
    margin-bottom: 8px;
}

.ac1-feedback__stars {
    display: flex;
    justify-content: center;
    gap: 6px;
}

.ac1-feedback__star {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--ac1-border);
    font-size: 24px;
    cursor: pointer;
    transition: color var(--ac1-transition), transform var(--ac1-transition);
    padding: 0;
    line-height: 1;
}

.ac1-feedback__star:hover {
    color: #f1c40f;
    transform: scale(1.2);
}

.ac1-feedback__star--active {
    color: #f1c40f;
}

.ac1-feedback__star:disabled {
    cursor: default;
    transform: none;
}

.ac1-feedback__star:focus-visible {
    outline: 2px solid var(--ac1-accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* === ANIMACOES === */
@keyframes ac1-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes ac1-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

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

/* === RESPONSIVO — TABLET === */
@media (max-width: 1024px) {
    .ac1-chat {
        width: 340px;
        height: 480px;
    }
}

/* === RESPONSIVO — MOBILE === */
@media (max-width: 768px) {
    .ac1-widget {
        bottom: 16px;
        right: 16px;
    }

    .ac1-fab {
        width: 56px;
        height: 56px;
    }

    .ac1-greeting {
        width: 280px;
        right: -8px;
        bottom: 72px;
    }

    .ac1-chat {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        max-width: none;
    }

    .ac1-chat__header {
        padding: 16px;
        padding-top: max(16px, env(safe-area-inset-top));
    }

    .ac1-chat__input {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .ac1-suggestions__btn {
        font-size: 12px;
        padding: 6px 12px;
    }
}

/* === ACESSIBILIDADE — REDUCED MOTION === */
@media (prefers-reduced-motion: reduce) {
    .ac1-fab,
    .ac1-greeting,
    .ac1-chat,
    .ac1-msg,
    .ac1-suggestions,
    .ac1-cta {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }

    .ac1-fab__badge,
    .ac1-chat__header-dot,
    .ac1-typing__dot {
        animation: none;
    }
}
