/* ========================================
   COHAB CURITIBA - PROGRAMA ESCRITURA NA MÃO
   Tema: Verde/Azul Institucional
======================================== */

:root {
    --vh: 100vh;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    height: var(--vh, 100vh);
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    font-family: 'Segoe UI', Arial, sans-serif;
    background: linear-gradient(135deg, #003B73 0%, #001A33 100%);
    color: #333;
    line-height: 1.6;
}

/* MAIN LAYOUT */
main {
    display: flex;
    flex-direction: column;
    height: calc(var(--vh, 100vh) - 65px);
    overflow: hidden;
}

/* HEADER */
.header {
    background: #ffffff;
    padding: 8px 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border-bottom: 4px solid #1a5a3a;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}

.logo-container {
    text-align: center;
}

.cohab-logo-img {
    height: 45px;
    width: auto;
}

/* CHAT CONTAINER */
.chat-container {
    display: flex;
    justify-content: center;
    padding: 10px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.chat-box {
    background: #ffffff;
    border-radius: 20px;
    width: 100%;
    max-width: 1000px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    height: 100%;
}

.chat-messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f0f2f5;
    display: flex;
    flex-direction: column;
    gap: 15px;
    font-size: 1.1rem;
    /* Aumentado para legibilidade */
}

/* INIT MESSAGE */
.init-message-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.init-message {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #1a5a3a, #2d7a4e);
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    box-shadow: 0 4px 15px rgba(26, 90, 58, 0.3);
    font-size: 14px;
}

/* Images inside bubbles */
.bubble img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    display: block;
    margin: 4px 0;
}

/* Allow bubbles with images to be wider */
.message.bot .bubble:has(img) {
    max-width: 95%;
    /* Aumentado de 80% */
    padding: 8px;
    /* Menos padding para aproveitar espaço */
}

.logos-footer {
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: 15px;
    margin-top: 8px;
    padding: 10px;
    background: white;
    border-radius: 12px;
}

.logos-footer img {
    max-height: 40px;
    width: auto;
    object-fit: contain;
}

.user-msg-indicator {
    position: absolute;
    right: 15px;
    background: #4ade80;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

.status-dot {
    width: 10px;
    height: 10px;
    background: #4ade80;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(1.2);
    }
}

/* MESSAGES */
.message {
    display: flex;
    margin: 12px 0;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    justify-content: flex-end;
}

.message.bot {
    justify-content: flex-start;
}

/* AVATAR */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 10px;
    flex-shrink: 0;
    object-fit: cover;
}

/* CHAT BUBBLES */
.bubble {
    padding: 14px 18px;
    border-radius: 18px;
    max-width: 80%;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 15px;
}

.message.bot .bubble {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    color: #333;
    border-bottom-left-radius: 4px;
}

.message.user .bubble {
    background: linear-gradient(135deg, #1a5a3a, #2d7a4e);
    color: white;
    border-bottom-right-radius: 4px;
}

/* TYPING INDICATOR */
.typing-bubble {
    display: flex;
    gap: 6px;
    padding: 14px 20px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
}

.typing-bubble .dot {
    width: 8px;
    height: 8px;
    background: #1a5a3a;
    border-radius: 50%;
    animation: bounce 1.2s infinite;
}

.typing-bubble .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-bubble .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-6px);
    }
}

/* INPUT AREA */
.input-area {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    background: #ffffff;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
}

#userInput {
    flex: 1;
    padding: 12px 18px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.3s;
    -webkit-appearance: none;
    appearance: none;
}

#userInput:focus {
    border-color: #1a5a3a;
}

#sendButton {
    background: linear-gradient(135deg, #1a5a3a, #2d7a4e);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    -webkit-tap-highlight-color: transparent;
}

#sendButton:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(26, 90, 58, 0.4);
}

#sendButton:active {
    transform: scale(0.95);
}

/* BUTTONS */
.button-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
    justify-content: flex-start;
}

.option-btn {
    background: #1a5a3a;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.option-btn:hover {
    background: #0d3d2a;
    transform: translateY(-2px);
}

/* FOOTER */
/* FOOTER */
.cohab-footer {
    width: 100%;
    background: #ffffff;
    margin-top: auto;
}

/* Linha divisória elegante */
.footer-divider {
    height: 4px;
    background: linear-gradient(90deg, #1a5a32 0%, #2d8a4e 50%, #1a5a32 100%);
    width: 100%;
}

/* Container principal - Layout de 3 colunas */
.footer-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    max-width: 1200px;
    margin: 0 auto;
    gap: 20px;
    flex-wrap: wrap;
}

.footer-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* Coluna esquerda - COHAB */
.footer-col-left {
    flex: 1;
    min-width: 180px;
}

.footer-logo-main {
    height: 50px;
    width: auto;
    margin-bottom: 8px;
}

.footer-tagline {
    font-size: 11px;
    color: #555;
    line-height: 1.3;
    margin: 0;
}

/* Coluna central - Informações */
.footer-col-center {
    flex: 2;
    min-width: 280px;
    border-left: 1px solid #e0e0e0;
    border-right: 1px solid #e0e0e0;
    padding: 0 25px;
}

.footer-program-title {
    font-size: 15px;
    font-weight: 700;
    color: #1a5a32;
    margin: 0 0 4px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.footer-program-desc {
    font-size: 12px;
    color: #666;
    margin: 0 0 12px 0;
}

.footer-contact-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.footer-contact-info span {
    font-size: 11px;
    color: #444;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.footer-contact-info i {
    color: #1a5a32;
    width: 14px;
}

/* Coluna direita - Parceiros */
.footer-col-right {
    flex: 1;
    min-width: 180px;
}

.footer-partners-label {
    font-size: 10px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0 0 10px 0;
}

.footer-partners-logos {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.footer-partners-logos img:first-child {
    height: 85px;
    width: auto;
}

.footer-partners-logos img:last-child {
    height: 65px;
    width: auto;
}

/* Barra inferior */
.footer-bottom {
    background: #1a5a32;
    color: white;
    padding: 10px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    flex-wrap: wrap;
    font-size: 11px;
}

.footer-bottom span {
    opacity: 0.9;
}

.footer-lgpd {
    opacity: 0.7 !important;
}

/* ========================================
   MOBILE RESPONSIVE
======================================== */
@media (max-width: 768px) {
    main {
        height: calc(var(--vh, 100vh) - 53px);
    }

    .header {
        padding: 6px 0;
    }

    .cohab-logo-img {
        height: 34px;
    }

    .chat-container {
        padding: 0;
    }

    .chat-box {
        border-radius: 0;
        box-shadow: none;
    }

    .chat-messages-area {
        padding: 12px;
        font-size: 1rem;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }

    .bubble {
        max-width: 88%;
        font-size: 14px;
        padding: 12px 14px;
    }

    .message.bot .bubble:has(img) {
        max-width: 92%;
    }

    .avatar {
        width: 30px;
        height: 30px;
        margin-right: 8px;
    }

    .init-message {
        font-size: 12px;
        padding: 8px 16px;
    }

    .message {
        margin: 8px 0;
    }

    .option-btn {
        padding: 11px 16px;
        font-size: 13px;
    }

    .button-wrapper {
        gap: 8px;
        margin-top: 10px;
    }

    .input-area {
        padding: 8px 10px;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
        gap: 8px;
    }

    #userInput {
        padding: 10px 14px;
        font-size: 16px;
        border-width: 1.5px;
    }

    #sendButton {
        padding: 10px 16px;
        font-size: 14px;
        white-space: nowrap;
    }

    /* Logos no bubble - garantir que apareçam */
    .logos-footer {
        gap: 10px;
        padding: 8px;
    }

    .logos-footer img {
        max-height: 30px;
    }

    /* Footer escondido no mobile - ocupa espaço e conflita com teclado */
    .cohab-footer {
        display: none;
    }
}

/* Responsivo para mobile footer em telas maiores */
@media (min-width: 769px) and (max-width: 1024px) {
    .footer-main {
        flex-direction: row;
        padding: 12px 15px;
        gap: 10px;
    }

    .footer-col {
        min-width: auto;
    }

    .footer-col-left {
        flex: 0.8;
    }

    .footer-logo-main {
        height: 35px;
    }

    .footer-tagline {
        font-size: 8px;
        display: none;
    }

    .footer-col-center {
        flex: 1.5;
        padding: 0 10px;
    }

    .footer-program-title {
        font-size: 11px;
    }

    .footer-program-desc {
        font-size: 9px;
        margin-bottom: 6px;
    }

    .footer-contact-info span {
        font-size: 8px;
    }

    .footer-partners-logos img:first-child {
        height: 55px;
    }

    .footer-partners-logos img:last-child {
        height: 42px;
    }
}

.footer-small {
    font-size: 11px;
    opacity: 0.7;
}

/* CRITICAL: Force inline elements to stay inline */
.bubble strong,
.bubble b,
.bubble em,
.bubble i,
.bubble span {
    display: inline !important;
    float: none !important;
}

.bubble {
    white-space: normal !important;
}

/* Styled DIVS IN MESSAGES */
.message.bot div[style] {
    max-width: 100%;
    display: block;
}

.bubble br {
    display: inline;
    content: " ";
}

.bubble br::after {
    content: "\A";
    white-space: pre;
}

/* ============================================
   MODAL DE DOCUMENTO/PIX
============================================ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-content.documento-modal {
    background: #ffffff;
    border-radius: 16px;
    width: 100%;
    max-width: 1100px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
}

.modal-header {
    background: linear-gradient(135deg, #1a5a3a, #2d7a4e);
    color: white;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.2rem;
    margin: 0;
}

.modal-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s;
}

.modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.modal-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* PDF Preview Area */
.pdf-preview-area {
    flex: 1.5;
    background: #f5f5f5;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    border-right: 1px solid #e0e0e0;
}

.pdf-loading {
    text-align: center;
    color: #666;
}

.pdf-loading .spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e0e0e0;
    border-top-color: #1a5a3a;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.pdf-frame {
    width: 100%;
    height: 100%;
    border: none;
    min-height: 500px;
}

.pdf-canvas-container {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #e0e0e0;
}

/* PIX Area */
.pix-area {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: #fafafa;
    max-width: 400px;
}

.pix-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 2px solid #1a5a3a;
}

.pix-header h3 {
    margin: 0;
    color: #1a5a3a;
}

.pix-icon {
    font-size: 1.5rem;
}

.pix-qr-container {
    text-align: center;
    padding: 15px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

#pixQrCode {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

#pixQrCode img,
#pixQrCode canvas {
    max-width: 180px !important;
    max-height: 180px !important;
}

.pix-valor {
    font-size: 1.5rem;
    font-weight: bold;
    color: #1a5a3a;
    margin: 10px 0 0 0;
}

.pix-code-section {
    background: white;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.pix-code-label {
    font-weight: bold;
    color: #333;
    margin: 0 0 10px 0;
    font-size: 0.9rem;
}

.pix-code-box {
    background: #f0f0f0;
    padding: 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    word-break: break-all;
    color: #333;
    max-height: 80px;
    overflow-y: auto;
    border: 1px solid #ddd;
    margin-bottom: 10px;
}

.copy-pix-btn {
    width: 100%;
    background: #1a5a3a;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1rem;
}

.copy-pix-btn:hover {
    background: #2d7a4e;
    transform: translateY(-2px);
}

.copy-pix-btn.copied {
    background: #28a745;
}

.pix-security {
    text-align: center;
    color: #666;
    font-size: 0.85rem;
    padding: 8px;
    background: #e8f5e9;
    border-radius: 8px;
}

.pix-timer {
    text-align: center;
    background: #fff3cd;
    padding: 10px;
    border-radius: 8px;
    color: #856404;
    font-weight: bold;
}

/* Modal Footer (legacy - kept for compatibility) */

.btn-download {
    background: #0d47a1;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-download:hover {
    background: #1565c0;
}

.btn-prosseguir {
    background: #1a5a3a;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-prosseguir:hover {
    background: #2d7a4e;
}

/* Responsive Modal */
@media (max-width: 900px) {
    .modal-overlay {
        padding: 10px;
    }

    .modal-content.documento-modal {
        max-height: 95vh;
    }

    .modal-body {
        flex-direction: column;
    }

    /* PDF área compacta em mobile */
    .pdf-preview-area {
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
        min-height: 200px;
        max-height: 250px;
        flex: none;
    }

    .pdf-frame {
        min-height: 200px;
    }

    .pix-area {
        max-width: 100%;
        flex: 1;
    }

    .modal-footer-desktop {
        flex-direction: column;
        padding: 12px 16px;
    }

    .btn-download,
    .btn-prosseguir {
        width: 100%;
        padding: 14px;
    }
}

/* Telas muito pequenas (celulares) */
@media (max-width: 480px) {
    .modal-overlay {
        padding: 0;
    }

    .modal-content.documento-modal {
        border-radius: 0;
        max-height: 100vh;
        height: 100vh;
    }

    .modal-header {
        padding: 12px 16px;
    }

    .modal-header h2 {
        font-size: 1rem;
    }

    /* MOSTRAR PDF no celular - ocupa espaço principal */
    .pdf-preview-area {
        display: flex !important;
        flex: 1 !important;
        min-height: 0 !important;
        max-height: none !important;
        border-right: none;
        border-bottom: none;
    }

    .pdf-frame {
        min-height: 100% !important;
    }

    /* ESCONDER PIX sidebar no celular */
    .pix-area {
        display: none !important;
    }

    .modal-body {
        flex-direction: column;
        flex: 1;
        min-height: 0;
    }

    /* Mostrar footer mobile, esconder desktop */
    .modal-footer-mobile {
        display: flex !important;
    }

    .modal-footer-desktop {
        display: none !important;
    }
}

/* ========================================
   MODAL FOOTER - MOBILE
======================================== */
.modal-footer-mobile {
    display: none;
    flex-direction: column;
    background: #f5f5f5;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.mobile-pix-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #e8f5e9;
    border-bottom: 1px solid #c8e6c9;
}

.mobile-pix-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mobile-pix-valor {
    font-size: 1.1rem;
    font-weight: bold;
    color: #1a5a3a;
}

.mobile-pix-timer {
    font-size: 0.75rem;
    color: #856404;
    font-weight: 600;
}

.mobile-copy-pix-btn {
    background: #1a5a3a;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
}

.mobile-copy-pix-btn:active {
    transform: scale(0.93);
}

.mobile-copy-pix-btn.copied {
    background: #28a745;
    animation: pulseBtn 0.4s ease;
}

@keyframes pulseBtn {
    0% { transform: scale(1); }
    30% { transform: scale(1.08); }
    60% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

.mobile-actions-bar {
    display: flex;
    gap: 10px;
    padding: 10px 14px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
}

.btn-download-mobile,
.btn-pago-mobile {
    flex: 1;
    border: none;
    padding: 12px 10px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 0.85rem;
    cursor: pointer;
}

.btn-download-mobile {
    background: #0d47a1;
    color: white;
}

.btn-pago-mobile {
    background: #1a5a3a;
    color: white;
}

/* ========================================
   MODAL FOOTER - DESKTOP
======================================== */
.modal-footer-desktop {
    padding: 16px 24px;
    background: #f5f5f5;
    display: flex;
    gap: 15px;
    justify-content: center;
    border-top: 1px solid #e0e0e0;
}

@media (max-width: 480px) {
    .modal-footer-desktop {
        display: none !important;
    }
}

/* Botões de documento para mobile - escondidos por padrão */
.mobile-doc-buttons {
    display: none;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
    padding: 0 10px;
}

.doc-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.view-doc-btn {
    background: linear-gradient(135deg, #1a5a32, #2d7a4d);
    color: white;
}

.view-doc-btn:hover {
    background: linear-gradient(135deg, #155028, #247040);
}

.download-doc-btn {
    background: #f5f5f5;
    color: #333;
    border: 1px solid #ddd;
}

.download-doc-btn:hover {
    background: #e8e8e8;
}