/**
 * APP STYLE - Design Moderno tipo Aplicativo Nativo
 * Baseado em apps financeiros profissionais
 */

/* ========================================
   RESET E CONFIGURAÇÕES GLOBAIS
   ======================================== */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f7fa;
    color: #1a1a1a;
    overflow-x: hidden;
    padding-bottom: 80px;
    /* Espaço para bottom nav */
}

/* ========================================
   CONTAINER PRINCIPAL
   ======================================== */

.app-container {
    width: 100%;
    margin: 0;
    padding: 15px;
    padding-bottom: 90px;
    background: #f5f7fa;
    min-height: 100vh;
}

/* ========================================
   HEADER - OLÁ, NOME
   ======================================== */

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0 20px 0;
}

.app-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0;
}

.app-header .bell-icon {
    font-size: 24px;
    color: #666;
    cursor: pointer;
}

/* ========================================
   CARD DE TOTAL - PRINCIPAL
   ======================================== */

.total-card {
    background: linear-gradient(135deg, #2a9d8f 0%, #1a7a6e 100%);
    border-radius: 20px;
    padding: 25px 20px;
    color: white;
    margin-bottom: 20px;
    box-shadow: 0 8px 20px rgba(42, 157, 143, 0.3);
    position: relative;
    overflow: hidden;
}

.total-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 200px;
    height: 200px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

.total-card-label {
    font-size: 14px;
    font-weight: 400;
    opacity: 0.9;
    margin-bottom: 5px;
}

.total-card-value {
    font-size: 42px;
    font-weight: 800;
    margin-bottom: 15px;
    position: relative;
    z-index: 1;
}

.total-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    opacity: 0.9;
}

.total-card-footer .pago {
    color: rgba(255, 255, 255, 0.8);
}

.total-card-footer .pendente {
    color: #ffecb3;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* ========================================
   SEÇÃO VENCENDO EM BREVE
   ======================================== */

.section-title {
    font-size: 18px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 25px 0 15px 0;
}

/* ========================================
   CARDS DAS CONTAS - ESTILO MODERNO
   ======================================== */

.conta-card {
    background: white;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
    border: none;
}

.conta-card:active {
    transform: scale(0.98);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

/* Ícone da conta */
.conta-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

/* Cores dos ícones por categoria */
.conta-icon.luz {
    background: #fef3c7;
    color: #f59e0b;
}

.conta-icon.internet {
    background: #fef3c7;
    color: #f59e0b;
}

.conta-icon.agua {
    background: #dbeafe;
    color: #3b82f6;
}

.conta-icon.aluguel {
    background: #dbeafe;
    color: #3b82f6;
}

.conta-icon.casa {
    background: #dbeafe;
    color: #3b82f6;
}

.conta-icon.cartao {
    background: #dcfce7;
    color: #10b981;
}

.conta-icon.banco {
    background: #dcfce7;
    color: #10b981;
}

.conta-icon.telefone {
    background: #e0e7ff;
    color: #6366f1;
}

.conta-icon.transporte {
    background: #fce7f3;
    color: #ec4899;
}

.conta-icon.alimentacao {
    background: #fef3c7;
    color: #f59e0b;
}

.conta-icon.saude {
    background: #fee2e2;
    color: #ef4444;
}

.conta-icon.outros {
    background: #f3f4f6;
    color: #6b7280;
}

/* Info da conta */
.conta-info {
    flex: 1;
    min-width: 0;
}

.conta-nome {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conta-vencimento {
    font-size: 12px;
    color: #6b7280;
}

.conta-vencimento.vencida {
    color: #ef4444;
    font-weight: 600;
}

.conta-vencimento.hoje {
    color: #f59e0b;
    font-weight: 600;
}

/* Valor da conta */
.conta-valor {
    font-size: 17px;
    font-weight: 700;
    color: #1a1a1a;
    text-align: right;
    flex-shrink: 0;
}

/* Badge de status */
.conta-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
}

.conta-badge.paga {
    background: #d1fae5;
    color: #059669;
}

.conta-badge.vence-hoje {
    background: #fef3c7;
    color: #d97706;
}

.conta-badge.vencida {
    background: #fee2e2;
    color: #dc2626;
}

/* ========================================
   BOTTOM NAVIGATION - FIXO
   ======================================== */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    height: auto;
    min-height: 80px;
    padding: 12px 20px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    flex: 0 1 auto;
    min-width: 48px;
    text-decoration: none;
    color: #9ca3af;
    transition: all 0.2s ease;
    padding: 8px 4px;
}

@media (max-width: 380px) {
    .bottom-nav {
        padding-left: 10px;
        padding-right: 10px;
        justify-content: space-between;
    }

    .bottom-nav-item {
        min-width: auto;
        padding: 8px 2px;
    }

    .bottom-nav-item i {
        font-size: 20px;
    }

    .bottom-nav-item span {
        font-size: 10px;
    }
}

.bottom-nav-item.active {
    color: #2a9d8f;
}

.bottom-nav-item i {
    font-size: 22px;
}

.bottom-nav-item span {
    font-size: 11px;
    font-weight: 500;
    margin-top: 2px;
}

/* Botão + central */
.bottom-nav-item.add-button {
    position: relative;
    top: -10px;
}

.bottom-nav-item.add-button .add-circle {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #2a9d8f 0%, #1a7a6e 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(42, 157, 143, 0.4);
}

.bottom-nav-item.add-button i {
    font-size: 28px;
    color: white;
}

/* ========================================
   ÍCONES DAS CONTAS
   ======================================== */

/* Mapeamento automático de ícones */
.icon-luz::before {
    content: '💡';
}

.icon-internet::before {
    content: '📶';
}

.icon-wifi::before {
    content: '📶';
}

.icon-agua::before {
    content: '💧';
}

.icon-aluguel::before {
    content: '🏠';
}

.icon-casa::before {
    content: '🏠';
}

.icon-moradia::before {
    content: '🏠';
}

.icon-cartao::before {
    content: '💳';
}

.icon-banco::before {
    content: '🏦';
}

.icon-telefone::before {
    content: '📱';
}

.icon-celular::before {
    content: '📱';
}

.icon-transporte::before {
    content: '🚗';
}

.icon-carro::before {
    content: '🚗';
}

.icon-alimentacao::before {
    content: '🍔';
}

.icon-comida::before {
    content: '🍔';
}

.icon-mercado::before {
    content: '🛒';
}

.icon-saude::before {
    content: '⚕️';
}

.icon-hospital::before {
    content: '🏥';
}

.icon-academia::before {
    content: '💪';
}

.icon-educacao::before {
    content: '📚';
}

.icon-lazer::before {
    content: '🎮';
}

.icon-outros::before {
    content: '📋';
}

/* ========================================
   ESTILOS DE FORMULÁRIO (GLOBAL)
   ======================================== */

.add-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0 20px 0;
    position: sticky;
    top: 0;
    background: #f5f7fa;
    z-index: 100;
}

.add-header h1 {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
    color: #1a1a1a;
}

.close-btn {
    font-size: 24px;
    color: #1a1a1a;
    text-decoration: none;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.close-btn:active {
    background: rgba(0, 0, 0, 0.05);
}

.save-button {
    background: #2a9d8f;
    color: white;
    border: none;
    width: 100%;
    padding: 16px;
    border-radius: 16px;
    font-size: 16px;
    font-weight: 700;
    margin-top: 20px;
    box-shadow: 0 10px 20px rgba(42, 157, 143, 0.2);
    transition: transform 0.2s;
}

.save-button:active {
    transform: scale(0.98);
}

/* ========================================
   MENU DROPDOWN MOBILE
   ======================================== */

.dropdown-menu {
    border-radius: 12px !important;
    border: none !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
    padding: 8px !important;
}

.dropdown-item {
    border-radius: 8px !important;
    padding: 10px 15px !important;
    font-size: 14px !important;
}

.dropdown-item:hover {
    background: #f3f4f6 !important;
}

/* ========================================
   RESPONSIVIDADE
   ======================================== */

@media (max-width: 768px) {
    body {
        background: #f5f7fa;
    }

    .container {
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
    }

    /* Esconder elementos desktop */
    .header-section>div:first-child,
    .header-section>h1,
    .header-section>div:last-child {
        display: none !important;
    }

    /* Esconder tabela */
    .table-responsive,
    .card {
        display: none !important;
    }

    .card.shadow-sm {
        display: none !important;
    }

    /* Mostrar app container */
    .app-container {
        display: block !important;
    }

    /* Ajustar alertas */
    .alert {
        border-radius: 12px !important;
        margin: 10px 15px !important;
    }
}

/* ========================================
   RESPONSIVO - DESKTOP (MOBILE FRAME)
   ======================================== */

@media (min-width: 769px) {
    body {
        background: #e2e8f0;
        display: flex;
        justify-content: center;
        align-items: center;
        min-height: 100vh;
        padding: 20px;
    }

    /* Esconder elementos legados do desktop se existirem */
    .container,
    .header-section,
    .card.shadow-sm {
        display: none !important;
    }

    /* Mostrar e centralizar o App Container */
    .app-container {
        display: block !important;
        width: 100%;
        max-width: 414px;
        /* Largura aproximada iPhone Max */
        height: 90vh;
        /* Altura relativa ao viewport */
        max-height: 900px;
        /* Limite máximo */
        min-height: 600px;
        /* Limite mínimo */
        background: #f5f7fa;
        border-radius: 40px;
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
        position: relative;
        overflow-y: auto;
        overflow-x: hidden;
        margin: 0 auto;
        border: 8px solid #1a1a1a;
        padding-bottom: 90px;
        /* Espaço para nav */
    }

    /* Scrollbar bonita dentro do frame */
    .app-container::-webkit-scrollbar {
        width: 6px;
    }

    .app-container::-webkit-scrollbar-thumb {
        background-color: rgba(0, 0, 0, 0.2);
        border-radius: 3px;
    }

    /* Ajustar Bottom Nav para ficar dentro do frame */
    .bottom-nav {
        display: flex !important;
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        border-bottom-left-radius: 32px;
        /* Descontar borda */
        border-bottom-right-radius: 32px;
        padding-bottom: 10px;
    }

    /* Ajustes específicos para telas de cadastro/edição que usam body direto */
    body:has(.add-form),
    body:has(.auth-card) {
        background: #e2e8f0;
    }

    /* Se a página não tem .app-container (ex: cadastro.php), encapsular visualmente */
    .add-header {
        max-width: 414px;
        margin: 0 auto;
        border-top-left-radius: 32px;
        border-top-right-radius: 32px;
        top: auto !important;
        /* Remover sticky global */
    }

    .add-form {
        max-width: 414px;
        margin: 0 auto;
        min-height: calc(850px - 60px);
        /* Altura frame menos header */
        background: #f5f7fa;
        padding-bottom: 120px !important;
        position: relative;
        /* Ensure absolute children are relative to this */
    }

    /* Centralizar o botão salvar dentro do frame */
    .save-button {
        position: absolute;
        bottom: 90px;
        left: 50%;
        transform: translateX(-50%);
        width: calc(100% - 30px);
        max-width: 384px;
    }

    /* ... (previous styles) ... */
}

/* Page Transitions - DESABILITADO para evitar tremor no mobile */
/* body {
    animation: fadeIn 0.4s ease-out;
} */

/* Animação desabilitada - causava tremor
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    width: 90%;
    max-width: 400px;
    pointer-events: none;
}

.toast-notification {
    background: white;
    color: #1a1a1a;
    padding: 16px 20px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    animation: slideDown 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: auto;
    border-left: 5px solid #2a9d8f;
}

.toast-notification.error {
    border-left-color: #e76f51;
}

.toast-notification i {
    font-size: 20px;
    margin-right: 15px;
    color: #2a9d8f;
}

.toast-notification.error i {
    color: #e76f51;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

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

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* ========================================
   PAGINAÇÃO
   ======================================== */

.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: white;
    border-radius: 16px;
    margin: 20px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.pagination-info {
    font-size: 14px;
    color: #6c757d;
    font-weight: 500;
}

.pagination-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.pagination-btn {
    min-width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid #e5e7eb;
    color: #1a1a1a;
    text-decoration: none;
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 600;
    padding: 0 12px;
}

.pagination-btn:hover:not(.disabled) {
    background: #f8f9fa;
    border-color: #2a9d8f;
    color: #2a9d8f;
    transform: translateY(-1px);
}

.pagination-btn.active {
    background: #2a9d8f;
    color: white;
    border-color: #2a9d8f;
}

.pagination-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.pagination-prev,
.pagination-next {
    background: linear-gradient(135deg, #2a9d8f 0%, #26a69a 100%);
    color: white;
    border: none;
}

.pagination-prev.disabled,
.pagination-next.disabled {
    background: #e5e7eb;
    color: #9ca3af;
}

.pagination-prev:hover:not(.disabled),
.pagination-next:hover:not(.disabled) {
    background: linear-gradient(135deg, #26a69a 0%, #2a9d8f 100%);
    color: white;
}

/* Mobile */
@media (max-width: 576px) {
    .pagination-container {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }

    .pagination-info {
        order: -1;
        font-size: 13px;
    }

    .pagination-btn {
        min-width: 36px;
        height: 36px;
        font-size: 13px;
    }
}