:root {
    /* Paleta Dark Modern (Estilo Nubank/Inter Dark) */
    --bg-app: #111111;
    /* Fundo global muito escuro */
    --bg-header: #1a1a1a;
    /* Header ligeiramente mais claro */
    --bg-card: #1e1e1e;
    /* Cards */
    --bg-input: #2c2c2c;
    /* Inputs */

    --primary: #00bcd4;
    /* Ciano (Konomisk brand) */
    --primary-dark: #008ba3;

    --text-main: #ffffff;
    --text-sec: #a0a0a0;

    --success: #4caf50;
    --danger: #f44336;

    --shadow-header: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-card: 0 4px 6px rgba(0, 0, 0, 0.2);
    --radius: 16px;
}

/* Reset Básico */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    overflow-x: hidden;
    width: 100%;
}

/* Layout Principal */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
}

/* --- OVERLAY (Fundo escuro quando menu abre) --- */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}

.overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* --- HEADER FIXO --- */
.main-header {
    position: fixed;
    top: 0;
    /* No desktop ele precisa começar após a sidebar, no mobile do zero */
    left: 0;
    right: 0;
    height: 60px;
    background-color: var(--bg-header);
    z-index: 100;
    display: flex;
    align-items: center;
    padding: 0 15px;
    gap: 15px;
    box-shadow: var(--shadow-header);
}

/* Botão Menu Hambúrguer */
#menu-toggle {
    background: none;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    padding: 5px;
    display: flex;
}

/* Busca */
.search-container {
    flex-grow: 1;
}

.search-bar {
    width: 100%;
    background: var(--bg-input);
    border: none;
    padding: 10px 15px;
    border-radius: 20px;
    color: var(--text-main);
    font-size: 0.9rem;
}

input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

/* Botão Atualizar */
#atualizar {
    background: var(--bg-input);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 0;
}

#atualizar:hover {
    cursor: pointer;
}

#atualizar:disabled {
    cursor: default !important;
}

#atualizar span {
    font-size: 1.2rem;
    color: var(--primary-dark);
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

.offline-mode span {
    color: var(--danger) !important;
}

.in-sync {
    background: var(--primary) !important;
}

.in-sync span {
    animation: spin 1s linear infinite;
}

/* --- SIDEBAR (GAVETA) --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100%;
    background-color: var(--bg-card);
    z-index: 200;
    transform: translateX(-100%);
    /* Escondido à esquerda */
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
}

.sidebar.active {
    transform: translateX(0);
}

/* Logo Sidebar */
.sidebar .logo {
    font-size: 1.5rem;
    color: var(--primary);
    font-weight: bold;
    margin-bottom: 20px;
    padding-left: 10px;
}

/* Perfil na Sidebar */
.user-profile-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    margin-bottom: 20px;
}

.profile-pic {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #000;
}

.profile-info strong {
    display: block;
    font-size: 0.95rem;
}

.profile-info span {
    font-size: 0.8rem;
    color: var(--text-sec);
}

/* Links Sidebar */
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 15px;
    color: var(--text-sec);
    text-decoration: none;
    font-size: 1rem;
    border-radius: 8px;
    margin-bottom: 5px;
    transition: all 0.2s;
}

.sidebar nav a:hover,
.sidebar nav a.active {
    background: rgba(0, 188, 212, 0.15);
    color: var(--primary);
}

.sidebar nav a .icon {
    width: 24px;
    text-align: center;
}


/* --- CONTEÚDO PRINCIPAL --- */
.main-content {
    flex: 1;
    /* Faz o conteúdo ocupar TODO o espaço restante ao lado da sidebar */
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding-top: 60px;
    /* Espaço para o header fixo */
    width: 100%;
    box-sizing: border-box;
}

.scrollable-content {
    padding: 15px;
    /* Reduzi um pouco para dar mais espaço aos cards */
    width: 100%;
    box-sizing: border-box;
    /* Garante que o padding não aumente o tamanho total */
}

/* Grids */
.dashboard-grid,
.transacoes-grid,
.faturas-grid {
    display: none;
    grid-template-columns: 1fr;
    /* Padrão 1 coluna */
    gap: 15px;
    width: 100%;
}

.recent-activity {
    grid-row: span 3;
}

#cartoes-container::-webkit-scrollbar {
    display: none;
}

@media (min-width: 1024px) {
    .sidebar {
        transform: translateX(0);
        width: 260px;
        position: fixed;
        /* Sidebar fixa à esquerda */
    }

    .main-content {
        margin-left: 260px;
        /* Empurra o conteúdo para o lado da sidebar */
    }

    .main-header {
        left: 260px;
        /* Alinha o header com o início do conteúdo */
    }

    .dashboard-grid {
        /* 3 colunas iguais que se ajustam sozinhas */
        grid-template-columns: repeat(2, 1fr);
    }

    #menu-toggle,
    .overlay {
        display: none !important;
    }

    .credit-card-item {
        min-width: 250px !important;
        width: 24%;
    }
}

/* Cards */
.card {
    background: var(--bg-card);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.card h3 {
    color: var(--text-sec);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Formulários Modernos */
.nova-transacao form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.row-inputs {
    display: flex;
    gap: 10px;
}

.row-inputs>* {
    flex: 1;
}

input,
select {
    background: var(--bg-input);
    border: 1px solid transparent;
    color: white;
    padding: 12px;
    border-radius: 8px;
    width: 100%;
}

input:focus,
select:focus {
    border-color: var(--primary);
}

button.btn-primary {
    background: var(--primary);
    color: #000;
    font-weight: bold;
    padding: 12px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
}

button.btn-secondary {
    background: #333;
    color: white;
    padding: 12px;
    border-radius: 8px;
    border: none;
}

/* Métricas (Saldos) */
.metric-card p {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 10px 0;
}

.sub-saldos-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 5px;
}

.sub-saldos-scroll::-webkit-scrollbar {
    height: 4px;
}

.sub-saldos-scroll::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 2px;
}

.banco-pill {
    background: #252525;
    padding: 6px 12px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    font-size: 0.85rem;
}

.banco-pill img {
    width: 18px;
    height: 18px;
    border-radius: 50%;
}

/* Tabela Responsiva */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.activity-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
}

.activity-table td,
.activity-table th {
    padding: 12px;
    border-bottom: 1px solid #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.activity-table tr:hover {
    background: #252525;
    cursor: pointer;
}

.td-descricao {
    width: auto;
    text-align: left;
}

.td-descricao div {
    display:flex;
    flex-direction:column;
    overflow:hidden;
}

.td-desc-desc {
    font-weight:bold;
    color:white;
    overflow:hidden;
    text-overflow:ellipsis;
}

.td-desc-data {
    font-size:0.75rem;
    color:#aaa;
}

.td-valor {
    width: 130px;
    text-align: right; /* Alinha o valor à direita */
    padding-left: 15px; /* Garante um respiro entre a descrição e o valor */
}

.valor-positivo {
    color: var(--success);
    font-weight:bold;
}

.valor-negativo {
    color: var(--danger);
    font-weight:bold;
}

.td-valor-conta {
    font-size:0.7rem;
    color:#aaa;
}

/* Modal Estilo Bottom Sheet em Mobile */
.modal {
    display: none;
    position: fixed;
    z-index: 500;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    align-items: center;
    justify-content: center;
}

.modal-conteudo {
    background: var(--bg-card);
    width: 90%;
    max-width: 450px;
    border-radius: 20px;
    padding: 25px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    border-bottom: 1px solid #333;
    padding-bottom: 10px;
}

.fechar {
    font-size: 2rem;
    cursor: pointer;
}

.detalhe-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.detalhe-item.full {
    grid-column: span 2;
}

.detalhe-item strong {
    display: block;
    margin-bottom: 5px;
    color: var(--text-sec);
    font-size: 0.8rem;
}

.detalhe-item span {
    font-size: 1rem;
    color: white;
}

.big-value {
    font-size: 1.5rem !important;
    font-weight: bold;
}

.row-inputs button {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    border: none;
    font-weight: bold;
    cursor: pointer;
}

.btn-editar {
    background: #333;
    color: white;
}

.btn-remover {
    background: #330000;
    color: #ff5252;
    border: 1px solid #ff5252;
}

/* Utilitários */
.right-header-button {
    float: right;
    background: var(--bg-input);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
}

/**************** CREDIT CARD ********************/
/* Estilos para o Cartão de Crédito Selecionável */

#cartoes-container {
    display: flex;
    grid-auto-flow: column;
    overflow-x: auto;
    gap: 15px;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.fatura-status {
    font-size: 0.75rem;
    background: var(--primary);
    color: #000;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: bold;
}

.PAGA {
    background: var(--success);
}

.VENCIDA {
    background: var(--danger);
}

.FECHADA {
    background: var(--primary-dark);
}

.credit-card-item {
    scroll-snap-align: center;
    background: #252525; /* Um tom acima do bg-card para destaque */
    border-radius: var(--radius);
    padding: 20px;
    min-width: 90%;
    margin-top: 5px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.credit-card-item:hover, .credit-card-selected {
    border-color: var(--primary);
    background: #2a2a2a;
    transform: translateY(-2px);
}

.card-brand-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand-logo {
    font-weight: bold;
    color: var(--primary);
    letter-spacing: 1px;
}

.valor-fatura {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 4px;
}

.card-dates {
    display: flex;
    gap: 30px;
}

.date-group strong, .limit-item strong {
    display: block;
    font-size: 0.75rem;
    color: var(--text-sec);
    text-transform: uppercase;
}

.date-group span {
    font-size: 0.9rem;
}

/* Barra de Limite */
.limit-container {
    margin-top: 5px;
}

.limit-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-input);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 8px;
}

.limit-progress {
    height: 100%;
    background: var(--primary);
    border-radius: 10px;
}

.limit-values {
    display: flex;
    justify-content: space-between;
}

.text-right {
    text-align: right;
}

.label {
    font-size: 0.8rem;
    color: var(--text-sec);
}

.month-selector {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    padding: 2px 8px;
    border-radius: 8px;
}

.month-label {
    min-width: 120px;
    text-align: center;
    cursor: pointer;
    font-weight: bold;
}

.month-label:hover {
  color: var(--primary);
}

.nav-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 0 8px;
  color: var(--text-main);
  font-weight: bold;
}