@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121e;
    --bg-card: rgba(26, 26, 38, 0.65);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --color-ativo: #10b981; /* Verde esmeralda */
    --color-passivo: #f43f5e; /* Coral/Vermelho suave */
    --color-pl: #8b5cf6; /* Roxo violeta */
    --color-receita: #06b6d4; /* Ciano */
    --color-despesa: #f59e0b; /* Âmbar */
    
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --shadow-premium: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.6;
    background-image: 
        radial-gradient(at 10% 20%, rgba(139, 92, 246, 0.05) 0px, transparent 50%),
        radial-gradient(at 90% 80%, rgba(6, 182, 212, 0.05) 0px, transparent 50%);
    background-attachment: fixed;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 3rem;
}

nav {
    display: flex;
    gap: 1.2rem;
}

.logout-form { margin: 0; }

.logout-button {
    border: 0;
    background: transparent;
    font-family: inherit;
    cursor: pointer;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    padding: 0.5rem 0.9rem;
    border-radius: 8px;
    border: 1px solid transparent;
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.nav-link.active {
    color: #a78bfa;
    background: rgba(167, 139, 250, 0.08);
    border: 1px solid rgba(167, 139, 250, 0.2);
    box-shadow: 0 0 10px rgba(167, 139, 250, 0.1);
}

.logo-section h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #a78bfa 0%, #14b8a6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.logo-section p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.2rem;
}

.status-badge {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(16, 185, 129, 0.1);
    color: var(--color-ativo);
    border: 1px solid rgba(16, 185, 129, 0.2);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.1);
}

.status-badge.error {
    background: rgba(244, 63, 94, 0.1);
    color: var(--color-passivo);
    border: 1px solid rgba(244, 63, 94, 0.2);
    box-shadow: 0 0 15px rgba(244, 63, 94, 0.1);
}

/* Grid Cards de Totais */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow-premium);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.card-ativo::before { background-color: var(--color-ativo); }
.card-passivo::before { background-color: var(--color-passivo); }
.card-pl::before { background-color: var(--color-pl); }
.card-dre::before { background-color: var(--color-receita); }

.card:hover {
    transform: translateY(-4px);
    border-color: var(--border-hover);
}

.card-header {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.card-value {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-top: 0.2rem;
}

.card-value.ativo { color: var(--color-ativo); }
.card-value.passivo { color: var(--color-passivo); }
.card-value.pl { color: var(--color-pl); }
.card-value.receita { color: var(--color-receita); }
.card-value.despesa { color: var(--color-despesa); }

/* Layout da Seção Principal */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 2rem;
    margin-bottom: 2.5rem;
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

.panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: var(--shadow-premium);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.panel-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

/* Gráfico */
.chart-container {
    width: 100%;
    max-width: 320px;
    margin: 1.5rem auto;
    position: relative;
}

/* Plano de Contas */
.accounts-list {
    max-height: 480px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.accounts-list::-webkit-scrollbar {
    width: 6px;
}

.accounts-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.account-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1rem;
    border-radius: 10px;
    margin-bottom: 0.5rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
    transition: all 0.2s;
}

.account-row:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border-color);
}

.account-row.parent {
    font-weight: 600;
    background: rgba(255, 255, 255, 0.05);
}

.account-info {
    display: flex;
    flex-direction: column;
}

.account-code {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: monospace;
}

.account-name {
    font-size: 0.95rem;
}

.account-tag {
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    margin-left: 0.5rem;
    display: inline-block;
    vertical-align: middle;
}

.tag-a { background: rgba(16, 185, 129, 0.15); color: var(--color-ativo); }
.tag-p { background: rgba(244, 63, 94, 0.15); color: var(--color-passivo); }
.tag-pl { background: rgba(139, 92, 246, 0.15); color: var(--color-pl); }
.tag-r { background: rgba(6, 182, 212, 0.15); color: var(--color-receita); }
.tag-d { background: rgba(245, 158, 11, 0.15); color: var(--color-despesa); }

.account-balance {
    font-family: monospace;
    font-weight: 600;
}

/* Lançamentos Recentes */
.transactions-section {
    margin-top: 2rem;
}

.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.premium-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    margin-top: 1rem;
}

.premium-table th {
    padding: 1rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

.premium-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
}

.premium-table tr:hover td {
    background: rgba(255, 255, 255, 0.01);
}

.badge-balanced {
    background: rgba(16, 185, 129, 0.15);
    color: var(--color-ativo);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

.item-list-inline {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.item-badge {
    display: inline-block;
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.item-badge.debito { background: rgba(16, 185, 129, 0.1); color: var(--color-ativo); }
.item-badge.credito { background: rgba(244, 63, 94, 0.1); color: var(--color-passivo); }

/* Formulário de Novo Lançamento */
.form-group {
    margin-bottom: 1.2rem;
}

.form-row-header {
    display: flex;
    gap: 1rem;
}

.form-row-header .form-group {
    flex: 1;
}

label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    font-weight: 500;
}

input, select {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.65rem 0.8rem;
    color: var(--text-primary);
    font-family: var(--font-sans);
    transition: all 0.3s;
}

select option {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

input:focus, select:focus {
    outline: none;
    border-color: #a78bfa;
    box-shadow: 0 0 10px rgba(167, 139, 250, 0.15);
}

.form-help {
    display: block;
    margin-top: 0.35rem;
    color: var(--text-secondary);
    font-size: 0.78rem;
    line-height: 1.35;
}



.btn-submit {
    background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 0.8rem 1.5rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.btn-submit:active {
    transform: translateY(0);
}

/* Notificações */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow-premium);
    backdrop-filter: blur(16px);
    z-index: 1000;
    transform: translateY(150%);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toast.show {
    transform: translateY(0);
}

.toast.success {
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--color-ativo);
}

.toast.error {
    border-color: rgba(244, 63, 94, 0.3);
    color: var(--color-passivo);
}

/* Botão de Exportação */
.btn-export {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    background: rgba(167, 139, 250, 0.12);
    color: #a78bfa;
    text-decoration: none;
    border: 1px solid rgba(167, 139, 250, 0.25);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 500;
    transition: all 0.25s ease;
}

.btn-export:hover {
    background: rgba(167, 139, 250, 0.22);
    border-color: rgba(167, 139, 250, 0.4);
    color: #f8fafc;
    transform: translateY(-1px);
    box-shadow: 0 0 12px rgba(167, 139, 250, 0.15);
}

.btn-export:active {
    transform: translateY(0);
}

/* Estilos Específicos da DRE */
.dre-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.dre-table td {
    padding: 1.1rem 1.5rem;
    font-size: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.dre-row-header {
    font-weight: 600;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.02);
    font-size: 1.05rem;
}

.dre-row-header td {
    border-bottom: 1px solid var(--border-color);
}

.dre-row-item {
    color: var(--text-secondary);
}

.dre-row-subtotal {
    font-weight: 700;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.dre-row-total {
    font-weight: 700;
    font-size: 1.2rem;
    color: white;
    background: rgba(167, 139, 250, 0.12);
    border: 1px solid rgba(167, 139, 250, 0.3);
}

.dre-row-total.lucro {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--color-ativo);
}

.dre-row-total.prejuizo {
    background: rgba(244, 63, 94, 0.15);
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: var(--color-passivo);
}

.dre-sign {
    font-family: monospace;
    font-weight: 600;
    display: inline-block;
    width: 25px;
    text-align: center;
}

.dre-sign.plus { color: var(--color-ativo); }
.dre-sign.minus { color: var(--color-passivo); }
.dre-sign.equals { color: #a78bfa; }

/* Modais Glassmorphism */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 15, 0.75);
    backdrop-filter: blur(12px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-card {
    background: rgba(18, 18, 30, 0.95);
    border: 1px solid rgba(167, 139, 250, 0.2);
    border-radius: 16px;
    width: 90%;
    max-width: 480px;
    padding: 2rem;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 20px rgba(167, 139, 250, 0.1);
    animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-card.modal-danger {
    border-color: rgba(244, 63, 94, 0.35);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 20px rgba(244, 63, 94, 0.1);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleUp {
    from { transform: scale(0.95) translateY(15px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 1rem;
}

.modal-card-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.btn-close-modal {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.btn-close-modal:hover {
    color: var(--text-primary);
}

.modal-card-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 1.2rem;
}

.btn-cancel {
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: all 0.2s;
}

.btn-cancel:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.btn-submit-modal {
    padding: 0.6rem 1.4rem;
    border-radius: 8px;
    background: var(--color-pl);
    color: #fff;
    border: 1px solid var(--color-pl);
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.2);
}

.btn-submit-modal:hover {
    background: #9d76fa;
    border-color: #9d76fa;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(139, 92, 246, 0.3);
}

.btn-submit-modal.btn-danger-action {
    background: var(--color-passivo);
    border-color: var(--color-passivo);
    box-shadow: 0 4px 12px rgba(244, 63, 94, 0.2);
}

.btn-submit-modal.btn-danger-action:hover {
    background: #f45e76;
    border-color: #f45e76;
    box-shadow: 0 6px 16px rgba(244, 63, 94, 0.3);
}

.modal-card select, .modal-card input {
    width: 100%;
    padding: 0.65rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    outline: none;
    font-family: var(--font-sans);
    transition: border-color 0.2s, background-color 0.2s;
    margin-top: 0.4rem;
}

.modal-card select:focus, .modal-card input:focus {
    border-color: var(--color-pl);
    background: rgba(255, 255, 255, 0.08);
}

.modal-card select option {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

/* Ações Dinâmicas nas Linhas da Tabela de Contas */
.account-row .account-actions {
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    transform: translateX(5px);
}

.account-row:hover .account-actions {
    opacity: 1;
    transform: translateX(0);
}

.btn-action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    transition: all 0.2s ease !important;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.2rem;
}

@media (max-width: 640px) {
    .modal-card { padding: 1.25rem; }
    .modal-card-footer { flex-direction: column-reverse; }
    .modal-card-footer button { width: 100%; }
    .account-row .account-actions { opacity: 1; transform: none; }
}

.btn-action-icon.edit:hover {
    background: rgba(167, 139, 250, 0.15) !important;
    color: #a78bfa !important;
}

.btn-action-icon.delete:hover {
    background: rgba(244, 63, 94, 0.15) !important;
    color: var(--color-passivo) !important;
}

.transaction-actions-heading,
.transaction-actions-cell {
    width: 64px;
    text-align: center !important;
}

.transaction-actions-cell .btn-action-icon {
    margin: 0 auto;
}

.transaction-delete-value {
    margin-top: 0.75rem;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
}

.transaction-delete-warning {
    margin-top: 1rem;
    color: var(--color-passivo);
    font-size: 0.85rem;
    line-height: 1.5;
}

/* Login administrativo */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background:
        radial-gradient(circle at 20% 20%, rgba(139, 92, 246, 0.16), transparent 35%),
        radial-gradient(circle at 80% 80%, rgba(6, 182, 212, 0.1), transparent 32%),
        var(--bg-primary);
}

.login-card {
    width: min(100%, 430px);
    padding: 2.25rem;
    border: 1px solid rgba(167, 139, 250, 0.25);
    border-radius: 18px;
    background: rgba(18, 18, 30, 0.92);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45), 0 0 30px rgba(139, 92, 246, 0.08);
    backdrop-filter: blur(16px);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.login-brand img {
    width: 58px;
    height: 58px;
    border: 2px solid rgba(167, 139, 250, 0.4);
    border-radius: 50%;
    object-fit: cover;
}

.login-brand h1 { font-size: 1.65rem; }
.login-brand p, .login-intro { color: var(--text-secondary); }
.login-intro { margin: 1.5rem 0; line-height: 1.55; }
.login-form { display: grid; gap: 1rem; }
.login-submit { width: 100%; margin-top: 0.5rem; }

.login-error {
    margin-bottom: 1.25rem;
    padding: 0.8rem 1rem;
    border: 1px solid rgba(244, 63, 94, 0.35);
    border-radius: 8px;
    color: #fda4af;
    background: rgba(244, 63, 94, 0.1);
    font-size: 0.9rem;
}
