/* --- IMPORTAÇÃO DAS FONTES --- */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;600;700;800&family=Roboto:wght@400;500;700&family=Work+Sans:wght@600&display=swap');

/* --- VARIÁVEIS DE COR --- */
:root {
    --primary-blue: #2A44A0;
    /* Azul Fiemg */
    --user-msg-bg: #D2E3FC;
    /* Azul Claro (Imagem Home 2) */
    --ai-msg-bg: #FFFFFF;
    /* Branco (Imagem Home 2) */
    --bg-gray: #F4F4F4;
    --white: #FFFFFF;
    --text-dark: rgba(19, 23, 32, 0.90);
    --text-muted: rgba(19, 23, 32, 0.60);
    --border-color: #C4C4C4;
}

/* --- RESET --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--bg-gray);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* --- UTILITÁRIOS --- */
.font-jakarta {
    font-family: 'Plus Jakarta Sans', sans-serif;
}

.font-work {
    font-family: 'Work Sans', sans-serif;
}

.font-roboto {
    font-family: 'Roboto', sans-serif;
}

/* SPA Visibility */
.block {
    display: none;
    width: 100%;
    height: 100%;
}

.block.active {
    display: flex;
}

.content-step {
    display: none;
    width: 100%;
    height: 100%;
    flex-direction: column;
}

.content-step.active-step {
    display: flex;
    animation: fadeIn 0.4s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ================= LOGIN (BLOCO 1) ================= */
.login-container {
    width: 100%;
    height: 100%;
    background: var(--bg-gray);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 24px;
}

.login-card {
    width: 412px;
    background: var(--white);
    border-radius: 6px;
    padding: 48px 42px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    z-index: 10;
}

.brand-title {
    color: var(--text-dark);
    line-height: 1.2;
}

.brand-title .smart {
    font-family: 'Plus Jakarta Sans';
    font-weight: 800;
    font-size: 36px;
}

.brand-title .brief {
    font-family: 'Plus Jakarta Sans';
    font-weight: 400;
    font-size: 36px;
    letter-spacing: 3px;
}

.welcome-text {
    font-family: 'Work Sans';
    font-weight: 600;
    font-size: 20px;
    color: var(--text-muted);
}

.input-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 8px;
    display: block;
    letter-spacing: 0.8px;
}

.input-wrapper {
    height: 46px;
    background: rgba(255, 255, 255, 0.54);
    border: 1px solid var(--primary-blue);
    border-radius: 6px;
    display: flex;
    align-items: center;
    padding: 0 16px;
}

.input-wrapper input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    color: var(--text-dark);
    font-size: 14px;
}

.input-decor {
    width: 2px;
    height: 18px;
    background: var(--primary-blue);
    border-radius: 10px;
    margin-left: 10px;
}

.btn-fiemg,
.btn-back {
    height: 48px;
    width: 180px;
    /* Fixed width instead of 100% */
    padding: 0 20px;
    /* Reduced side padding since width is fixed */
    border-radius: 6px;
    font-weight: 500;
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: 0.2s;
    border: none;
    font-family: 'Roboto', sans-serif;
}

.btn-fiemg {
    background: var(--primary-blue);
    color: white;
}

.btn-fiemg:hover {
    background-color: #1e327a;
}

.btn-back {
    background: #E0E0E0;
    color: var(--text-muted);
}

.btn-back:hover {
    background-color: #D4D4D4;
    color: var(--text-dark);
}

.code-box-container {
    display: flex;
    gap: 4px;
}

#code-input {
    letter-spacing: 8px;
    font-size: 20px;
    text-align: center;
    font-weight: 700;
    color: var(--primary-blue);
}

/* ================= APP LAYOUT ================= */
.app-layout {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 234px;
    min-width: 234px;
    background: var(--primary-blue);
    padding: 48px 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.sidebar-logo .smart {
    color: white;
    font-weight: 800;
    font-size: 16px;
}

.sidebar-logo .brief {
    color: white;
    font-weight: 600;
    font-size: 16px;
    letter-spacing: 1.5px;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar-circle {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.54);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.user-info .name {
    color: white;
    font-weight: 700;
    font-size: 12px;
}

.user-info .role {
    color: rgba(255, 255, 255, 0.87);
    font-size: 12px;
}

/* Main Content */
.main-content {
    flex: 1;
    background: var(--bg-gray);
    padding: 40px 60px;
    /* Reduced top padding */
    height: 100vh;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.page-title {
    color: var(--primary-blue);
    font-family: 'Work Sans';
    font-weight: 600;
    font-size: 32px;
    margin-bottom: 32px;
}

.chat-title {
    color: var(--primary-blue);
    font-family: 'Work Sans';
    font-weight: 600;
    font-size: 20px;
    margin-bottom: 24px;
    flex-shrink: 0;
}

/* ================= FORMS (Block 2 & 3) ================= */
.form-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 740px;
    overflow-y: auto;
    padding-bottom: 80px;
}

.form-input-box {
    background: var(--white);
    border-radius: 4px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    min-height: 48px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.form-input-box input,
.form-input-box select {
    border: none;
    width: 100%;
    font-weight: 700;
    color: var(--primary-blue);
    font-size: 16px;
    outline: none;
    background: transparent;
}

.form-input-box textarea {
    border: none;
    width: 100%;
    min-height: 100px;
    font-weight: 400;
    color: var(--text-dark);
    font-size: 14px;
    outline: none;
    resize: none;
    background: transparent;
}

/* Radio */
.radio-group {
    display: flex;
    gap: 32px;
}

.radio-item {
    display: flex;
    gap: 8px;
    align-items: center;
    cursor: pointer;
}

.radio-circle {
    width: 12px;
    height: 12px;
    border: 1px solid #aaa;
    border-radius: 50%;
}

.radio-item.active .radio-circle {
    background: var(--primary-blue);
    border-color: var(--primary-blue);
}

.radio-label {
    font-weight: 500;
    font-size: 15px;
    color: #aaa;
    text-transform: uppercase;
}

.radio-item.active .radio-label {
    color: var(--primary-blue);
}

/* ================= CHAT (Block 4 - REFATORADO) ================= */
.chat-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    overflow: hidden;
    /* Added to contain children */
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding-right: 15px;
    /* Better scrollbar breathing room */
    padding-bottom: 30px;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-blue) transparent;
}

/* Balão IA (Cartão Branco) */
.msg-ai {
    background: var(--white);
    color: var(--text-muted);
    padding: 24px;
    border-radius: 6px;
    font-size: 16px;
    line-height: 1.5;
    max-width: 85%;
    align-self: flex-start;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

/* Balão Usuário (Azul Claro) */
.msg-user {
    background: var(--user-msg-bg);
    color: var(--text-dark);
    /* Texto mais escuro para contraste */
    padding: 16px 24px;
    border-radius: 6px;
    font-size: 16px;
    line-height: 1.5;
    max-width: 60%;
    align-self: flex-end;
    text-align: left;
}

/* Área de Input (Fixo no fundo do container main-content ou estático no final) */
.chat-input-container {
    margin-top: 0;
    padding: 24px 0 40px 0;
    background: var(--bg-gray);
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-shrink: 0;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    /* Subtle separation */
}

.chat-textarea {
    width: 100%;
    height: 80px;
    background: var(--bg-gray);
    /* Ou branco se preferir */
    border: 1px solid #AAAAAA;
    border-radius: 6px;
    padding: 16px;
    font-family: 'Roboto';
    font-size: 14px;
    color: var(--text-dark);
    outline: none;
    resize: none;
}

.chat-textarea:focus {
    border-color: var(--primary-blue);
    background: var(--white);
}

.btn-chat-send {
    align-self: flex-end;
    background: var(--primary-blue);
    color: white;
    border: none;
    border-radius: 6px;
    height: 48px;
    width: 180px;
    /* Standardized fixed width matching others */
    padding: 0 20px;
    font-weight: 500;
    font-family: 'Roboto', sans-serif;
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-chat-send:hover {
    background: #1e327a;
}

/* ================= UTILS ================= */
.fab-next {
    position: absolute;
    bottom: 48px;
    right: 60px;
    background: var(--primary-blue);
    color: white;
    padding: 12px 24px;
    border-radius: 6px;
    border: none;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(42, 68, 160, 0.3);
}

/* LOADER */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    z-index: 9999;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #eee;
    border-top: 4px solid var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* MODAL PILOTO */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: none;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

.modal-card {
    background: var(--white);
    width: 100%;
    max-width: 500px;
    padding: 40px;
    border-radius: 8px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    animation: modalIn 0.3s ease-out;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-card h2 {
    color: var(--primary-blue);
    font-family: 'Work Sans';
    font-size: 18px;
    margin-bottom: 20px;
    line-height: 1.4;
}

.modal-card p {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 16px;
}

.modal-card ul {
    list-style: none;
    margin-bottom: 24px;
    padding-left: 10px;
}

.modal-card li {
    font-size: 14px;
    color: var(--text-dark);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-card li::before {
    content: "";
    width: 6px;
    height: 6px;
    background: var(--primary-blue);
    border-radius: 50%;
    opacity: 0.6;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: 0.2s;
}

.modal-close:hover {
    color: var(--primary-blue);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}

/* ================= TYPING INDICATOR ================= */
.typing-indicator {
    background: var(--white);
    color: var(--text-muted);
    padding: 24px;
    border-radius: 6px;
    max-width: 85px;
    align-self: flex-start;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    display: flex;
    gap: 6px;
    align-items: center;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #AAAAAA;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.6;
    }

    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* ================= RESPONSIVE DESIGN ================= */

/* Large Tablets and Small Desktops (max-width: 1024px) */
@media (max-width: 1024px) {
    .main-content {
        padding: 20px 30px;
    }

    .sidebar {
        width: 250px;
        padding: 30px 20px;
    }

    .chat-wrapper {
        max-width: 100%;
    }

    .msg-ai {
        max-width: 90%;
    }

    .msg-user {
        max-width: 70%;
    }
}

/* Tablets (max-width: 768px) */
@media (max-width: 768px) {
    body {
        overflow: auto;
        height: auto;
        min-height: 100vh;
    }

    /* Login Card */
    .login-card {
        width: 100%;
        max-width: 400px;
        padding: 32px 24px;
        margin: 16px;
    }

    .brand-title .smart,
    .brand-title .brief {
        font-size: 28px;
    }

    .welcome-text {
        font-size: 16px;
    }

    /* Main App Layout */
    #block-2 {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    .sidebar {
        width: 100%;
        height: auto;
        min-height: auto;
        padding: 20px;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 16px;
        align-items: center;
        justify-content: space-between;
    }

    .logo-seta,
    .sidebar-divider,
    .menu-help {
        display: none;
    }

    .user-info-card {
        width: auto;
        flex-direction: row;
        gap: 12px;
        padding: 12px 16px;
    }

    .user-avatar {
        width: 40px;
        height: 40px;
    }

    .user-details {
        text-align: left;
    }

    .main-content {
        padding: 16px;
        min-height: calc(100vh - 120px);
    }

    /* Form */
    .form-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .form-field.half {
        width: 100%;
    }

    .radio-group {
        flex-direction: column;
        gap: 16px;
    }

    .actions-row {
        flex-direction: column;
        gap: 12px;
    }

    .btn-fiemg,
    .btn-back {
        width: 100%;
    }

    /* Chat */
    .chat-wrapper {
        max-width: 100%;
    }

    .msg-ai,
    .msg-user {
        max-width: 95%;
        padding: 16px;
        font-size: 14px;
    }

    .chat-textarea {
        height: 60px;
        font-size: 14px;
    }

    /* Editor */
    .editor-wrapper {
        flex-direction: column;
    }

    .editor-main,
    .editor-sidebar {
        width: 100%;
        max-width: 100%;
    }

    .editor-sidebar {
        order: -1;
        padding: 16px;
    }

    .editor-main {
        padding: 16px;
    }

    /* Modal */
    .modal-card {
        width: 95%;
        max-height: 90vh;
        padding: 24px;
    }
}

/* Mobile Phones (max-width: 480px) */
@media (max-width: 480px) {
    .login-container {
        padding: 16px;
    }

    .login-card {
        padding: 24px 16px;
        gap: 24px;
    }

    .brand-title .smart,
    .brand-title .brief {
        font-size: 24px;
    }

    .welcome-text {
        font-size: 14px;
    }

    .input-wrapper {
        height: 44px;
    }

    .btn-fiemg,
    .btn-back {
        height: 44px;
        font-size: 13px;
    }

    .sidebar {
        padding: 12px 16px;
    }

    .user-info-card {
        padding: 8px 12px;
    }

    .user-avatar {
        width: 32px;
        height: 32px;
    }

    .user-name {
        font-size: 12px;
    }

    .user-email {
        font-size: 10px;
    }

    .main-content {
        padding: 12px;
    }

    .step-header {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    .step-title {
        font-size: 18px;
    }

    .step-subtitle {
        font-size: 12px;
    }

    .msg-ai,
    .msg-user {
        padding: 12px;
        font-size: 13px;
    }

    .chat-input-container {
        margin-bottom: 20px;
    }

    .typing-indicator {
        padding: 16px;
    }

    .modal-card {
        padding: 20px 16px;
    }

    .modal-card h2 {
        font-size: 18px;
    }
}

/* Landscape Mode for Phones */
@media (max-height: 500px) and (orientation: landscape) {
    body {
        overflow: auto;
    }

    .login-container {
        min-height: 100vh;
        padding: 20px;
    }

    .login-card {
        padding: 20px;
        gap: 16px;
    }

    .sidebar {
        flex-direction: row;
        height: auto;
        min-height: auto;
    }
}

/* High DPI / Retina Displays */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {

    .login-card,
    .msg-ai,
    .user-info-card {
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    }
}

/* Print Styles */
@media print {

    .sidebar,
    .chat-input-container,
    .actions-row,
    .btn-fiemg,
    .btn-back {
        display: none !important;
    }

    .main-content {
        padding: 0;
    }

    body {
        background: white;
    }
}