:root {
    --primary: #6d28d9;
    --primary-light: #8b5cf6;
    --secondary: #ec4899;
    --bg-dark: #0f172a;
    --text-main: #f8fafc;
    --text-muted: #cbd5e1;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 0% 0%, rgba(109, 40, 217, 0.25) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(236, 72, 153, 0.25) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    /* Removido align-items: center para não quebrar o scroll vertical quando a página crescer */
    padding: 20px 0;
}

.app-container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
}

.view {
    display: none;
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
}

.view.active {
    display: block;
    opacity: 1;
}

/* Glassmorphism */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    max-width: 450px;
    margin: 0 auto;
}

.add-expense-card {
    max-width: 100%;
}

.register-card {
    max-width: 700px;
}

h1, h2, h3 {
    margin-bottom: 10px;
    font-weight: 600;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 30px;
}

.partner-section {
    background: rgba(0,0,0,0.2);
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 20px;
    border: 1px solid var(--glass-border);
}

/* Formulários */
.input-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.input-row .input-group {
    flex: 1;
    min-width: 150px;
}

.align-end {
    align-items: flex-end;
}

.input-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
    text-align: left;
}

label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    margin-left: 4px;
}

input, select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 14px;
    color: #fff;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
    width: 100%;
    box-sizing: border-box;
}

input:focus, select:focus {
    border-color: var(--primary-light);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.1);
}

option {
    background-color: var(--bg-dark);
    color: var(--text-main);
}

/* Botões */
.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 10px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(236, 72, 153, 0.3);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid var(--glass-border);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.switch-view {
    margin-top: 25px;
    font-size: 0.9rem;
    text-align: center;
    color: var(--text-muted);
}

.switch-view a {
    color: var(--primary-light);
    text-decoration: none;
    font-weight: 600;
}

.switch-view a:hover {
    text-decoration: underline;
}

/* Dashboard */
.dash-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.dashboard-content {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.chart-container {
    max-width: 100%;
    padding: 20px;
}

.chart-wrapper {
    position: relative;
    height: 300px;
    width: 100%;
}

.partners-summary {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.partner-card {
    flex: 1;
    min-width: 250px;
    background: linear-gradient(135deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.02) 100%);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 25px;
    text-align: center;
    backdrop-filter: blur(10px);
}

.partner-name {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--primary-light);
}

.partner-stat {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.partner-stat span {
    color: #fff;
    font-weight: 600;
    font-size: 1.1rem;
}

.progress-bar-container {
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    height: 10px;
    width: 100%;
    margin-top: 15px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: 8px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    width: 0%;
    transition: width 1s ease-in-out;
}

.add-expense-card {
    max-width: 100%;
    margin-top: 30px;
    padding: 25px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-main);
    color: var(--bg-dark);
    padding: 12px 24px;
    border-radius: 30px;
    font-weight: 600;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    transition: bottom 0.4s ease;
    z-index: 1000;
}

.toast.show {
    bottom: 30px;
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    padding: 15px 30px;
    border-radius: 16px;
    margin-bottom: 20px;
}

.nav-brand {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
    cursor: pointer;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 15px;
}

.profile-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-light);
    cursor: pointer;
    transition: transform 0.2s;
}

.profile-avatar:hover {
    transform: scale(1.1);
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
}

.btn-icon:hover {
    color: var(--secondary);
}

/* Profile View */
.profile-pic-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 30px;
    gap: 15px;
}

#profile-preview {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.4);
}

.change-pic-btn {
    font-size: 0.9rem;
    padding: 8px 16px;
}

/* Navbar elements */
.nav-links {
    display: flex;
    gap: 20px;
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

.nav-link:hover {
    color: var(--text-main);
}

/* Barra de Progresso (Metas) */
.progress-bar-container {
    width: 100%;
    height: 12px;
    background: rgba(255,255,255,0.1);
    border-radius: 6px;
    margin: 15px 0;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 6px;
    transition: width 0.5s ease;
}

.goal-card {
    display: flex;
    flex-direction: column;
}

.goal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.goal-investors {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Container de Metas em Grid */
#goals-container {
    display: grid;
    grid-template-columns: 1fr; /* Padrão mobile */
    gap: 20px;
}

@media (min-width: 768px) {
    #goals-container {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    }
}

/* Botões de Aporte/Resgate */
.add-inv-form .input-row {
    flex-wrap: wrap;
    gap: 10px;
}

.add-inv-form .input-group {
    flex: 1 1 100%;
}

.add-inv-form .btn-primary, .add-inv-form .btn-withdraw {
    flex: 1 1 calc(50% - 5px);
    margin-top: 10px !important;
    padding: 12px;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.cropper-container-card {
    width: 90%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.cropper-canvas-wrapper {
    width: 100%;
    height: 300px;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
}

/* Deixa a área de corte do cropper redonda */
.cropper-view-box,
.cropper-face {
    border-radius: 50%;
}

.cropper-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.cropper-actions button {
    margin-top: 0;
    width: auto;
}

/* Dropdown de Notificações */
#notifications-dropdown {
    position: absolute;
    top: calc(100% + 15px);
    right: 0;
    width: 320px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    padding: 15px;
    margin: 0;
    text-align: left;
}

@media (max-width: 768px) {
    .app-container {
        padding: 10px;
        padding-bottom: 70px; /* Espaço para o bottom nav */
    }

    .glass-card {
        padding: 15px; /* Reduzido de 20 para ganhar espaço */
    }

    /* Navbar superior no mobile */
    .navbar {
        padding: 10px 15px;
        margin-bottom: 15px;
    }

    .nav-brand {
        font-size: 1.1rem;
    }

    /* Esconde os links horizontais no Mobile */
    .nav-links {
        display: none !important;
    }

    .profile-avatar {
        width: 35px;
        height: 35px;
    }

    .input-row {
        flex-direction: column;
        gap: 15px;
    }

    .align-end {
        align-items: stretch;
    }

    .input-group {
        margin-bottom: 0;
    }

    #installment-fields {
        margin-top: 15px;
    }

    .partners-summary {
        flex-direction: column;
    }

    .partner-card {
        min-width: 100%;
        padding: 15px;
    }

    /* Tabelas responsivas (Swipe horizontal) */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 15px;
        border-radius: 8px;
    }
    
    table {
        min-width: 500px; /* Garante que a tabela não fique espremida */
    }

    /* Gráfico Anual responsivo */
    .annual-chart-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .chart-wrapper {
        height: 250px;
    }

    #total-debt-value {
        font-size: 2rem !important;
    }

    h2 {
        font-size: 1.3rem;
    }
    
    /* Mostrar bottom nav */
    .bottom-nav {
        display: flex !important;
    }

    /* Correção do Dropdown de Notificações no Mobile */
    #notifications-dropdown {
        position: fixed;
        top: 70px;
        left: 10px;
        right: 10px;
        width: auto;
        max-width: none;
        z-index: 2100;
    }

    /* Otimização da IA para Mobile */
    .ai-chat-widget {
        bottom: 75px !important; /* Fica acima da bottom nav */
        right: 15px !important;
        opacity: 0.6; /* Escondendo automático */
        transition: opacity 0.3s;
    }
    
    .ai-chat-widget:focus-within, .ai-chat-widget:active {
        opacity: 1; /* Revela ao tocar */
    }

    .ai-chat-btn {
        width: 45px;
        height: 45px;
    }
    
    .ai-chat-btn svg {
        width: 20px;
        height: 20px;
    }

    .ai-chat-panel {
        width: 320px;
        height: 400px;
        right: 0;
    }
}

/* ==================================
   MOBILE BOTTOM NAVIGATION & DRAWER
   ================================== */
.bottom-nav {
    display: none; /* Só mostra no mobile */
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--glass-border);
    z-index: 1000;
    justify-content: space-around;
    align-items: center;
    padding: 0 10px;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.7rem;
    gap: 4px;
    padding: 5px;
    flex: 1;
    transition: 0.3s;
}

.bottom-nav-item.active {
    color: var(--color-primary);
}

.mobile-drawer {
    position: fixed;
    top: 0;
    right: -280px; /* Escondido */
    width: 280px;
    height: 100vh;
    background: var(--bg-dark);
    border-left: 1px solid var(--glass-border);
    z-index: 2001;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.mobile-drawer.open {
    right: 0;
}

.drawer-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
}

.drawer-header h3 {
    margin: 0;
    color: var(--color-primary);
}

.drawer-links {
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    overflow-y: auto;
}

.drawer-links a {
    padding: 15px 25px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 1.1rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.drawer-links a:hover {
    background: rgba(255,255,255,0.05);
    color: var(--color-primary);
}

.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(2px);
    z-index: 2000;
    display: none;
}

.drawer-overlay.active {
    display: block;
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 20px 0;
    margin-top: 40px;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--glass-border);
}

.app-footer p {
    margin: 5px 0;
}

/* Estilos de Impressão (PDF/Impressora) */
@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
    }

    .app-container, .modal-overlay:not(#report-modal), #toast {
        display: none !important;
    }

    #report-modal {
        display: block !important;
        position: static !important;
        background: transparent !important;
        padding: 0 !important;
    }

    .report-paper {
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
        background: #ffffff !important;
        color: #000000 !important;
    }

    .report-actions-bar {
        display: none !important;
    }

    @page {
        margin: 1.5cm;
        size: A4;
    }
}

/* =========================================
   FASE 13: CHATBOT IA FLUTUANTE
========================================= */
.ai-chat-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.ai-chat-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(236, 72, 153, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.ai-chat-btn:hover {
    transform: scale(1.1);
}

.ai-chat-panel {
    display: none;
    width: 350px;
    height: 500px;
    background: rgba(17, 24, 39, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    margin-bottom: 15px;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-chat-header {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2) 0%, rgba(236, 72, 153, 0.2) 100%);
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.ai-chat-header h3 {
    margin: 0;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.4;
    word-wrap: break-word;
}

.ai-message.user {
    align-self: flex-end;
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 2px;
}

.ai-message.bot {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border-bottom-left-radius: 2px;
}

.ai-chat-input-area {
    padding: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    gap: 10px;
}

.ai-chat-input-area input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 10px;
    border-radius: 20px;
    outline: none;
}

.ai-chat-input-area button {
    background: var(--primary);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ai-chat-input-area button:hover {
    background: var(--primary-hover);
}

.typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 5px 10px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}
