/* Google Fonts - Inter */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

@keyframes slideInBar {
    from {
        width: 0;
    }

    to {
        width: 100%;
    }
}

@keyframes growWidth {
    from {
        width: 0;
    }
}

.progress-bar-animated {
    animation: growWidth 1s ease-out forwards;
}

:root {
    --primary-color: #6C5DD3;
    --primary-light: #8B7DE8;
    --primary-dark: #5849BE;
    --accent-color: #FF754C;

    --success-bg: #E1FCEF;
    --success-text: #14B133;

    --danger-bg: #FFEEE8;
    --danger-text: #FF754C;

    --warning-bg: #FFF8E1;
    --warning-text: #FFB000;

    --info-bg: #E4E2F5;
    --info-text: #6C5DD3;

    --bg-body: #F7F8FC;
    --bg-card: #FFFFFF;
    --bg-sidebar: #6C5DD3;

    --text-main: #11142D;
    /* Darker, bolder */
    --text-muted: #808191;
    --text-sidebar: #FFFFFF;
    --text-sidebar-muted: rgba(255, 255, 255, 0.7);

    --border-color: #F0F0F0;

    --font-family: 'Inter', sans-serif;
    --sidebar-width: 280px;
    /* Slightly wider for modern feel */
    --card-radius: 24px;
    /* Matches reference rounded look */
    --btn-radius: 16px;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    /* Smoother bounce */

    --shadow-soft: 0 10px 40px rgba(29, 22, 23, 0.07);
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.03);
}

/* Modern Card & List Styles */
.card-modern {
    background: var(--bg-card);
    border-radius: var(--card-radius);
    padding: 25px;
    box-shadow: var(--shadow-card);
    border: 1px solid rgba(0, 0, 0, 0.02);
}

.icon-box-modern {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

/* Transaction List Item (Reference Style) */
.transaction-item {
    display: flex;
    align-items: center;
    padding: 18px 0;
    border-bottom: 1px solid #F8F8F8;
    gap: 15px;
}

.transaction-item:last-child {
    border-bottom: none;
}

.t-icon {
    width: 50px;
    height: 50px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
}

.t-details {
    flex: 1;
}

.t-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-main);
    margin-bottom: 4px;
}

.t-subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

.t-amount {
    font-weight: 700;
    font-size: 15px;
    text-align: right;
}

.t-time {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 2px;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-family);
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    display: block;
    /* Fixed: Removed flex to prevent layout overflow */
    min-height: 100vh;
    overflow-x: hidden;
    /* Prevent horizontal scroll causing zoom out on mobile */
}

a {
    text-decoration: none;
    color: inherit;
}

/* Layout - Flexbox Architecture (Industry Standard) */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
    position: relative;
    overflow-x: hidden;
}

/* Mobile Overlay - Default Hidden */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    backdrop-filter: blur(2px);
}

/* Sidebar */
.sidebar {
    width: 280px;
    /* Fixed Width */
    flex-shrink: 0;
    /* Never shrink */
    background-color: var(--bg-sidebar);
    color: var(--text-sidebar);
    display: flex;
    flex-direction: column;
    padding: 30px 20px;

    /* Revert to Sticky for better flow safety */
    position: sticky;
    top: 0;
    height: 100dvh;
    overflow-y: auto;

    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    justify-content: flex-start;
    gap: 20px;
    border-right: 1px solid rgba(0, 0, 0, 0.02);
    /* Hide scrollbar for clean UI */
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

.sidebar::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

.sidebar-bottom {
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 20px;
}

.sidebar .brand {
    font-size: 24px;
    font-weight: 700;
    color: white;
    margin-bottom: 40px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding-left: 10px;
}

.sidebar nav ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar nav ul li a {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    color: var(--text-sidebar-muted);
    border-radius: 12px;
    font-weight: 500;
    font-size: 15px;
    transition: var(--transition);
}

.sidebar nav ul li a i {
    margin-right: 15px;
    font-size: 18px;
    width: 20px;
    text-align: center;
}

.sidebar nav ul li a:hover,
.sidebar nav ul li a.active {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    font-weight: 600;
}

/* Content Area */
.content {
    flex: 1;
    min-width: 0;
    transition: var(--transition);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* Removed margin-left to restore flux */
    width: 100%;
}

.page-content {
    padding: 10px 30px;
    /* Reduced from 30px 40px */
    width: 100%;
}

/* Header */
.main-header {
    height: auto;
    /* Allow auto height */
    min-height: 60px;
    /* Reduced from fixed 90px */
    display: flex;
    align-items: center;
    justify-content: flex-start;
    /* Changed from space-between to align left */
    gap: 20px;
    /* Spacing between title and logo/toggle */
    padding: 10px 30px;
    /* Reduced padding */
    margin-top: 0;
    /* Removed top margin */
    margin-bottom: 0;
}

/* Push widgets and user info to the right */
.header-widgets {
    margin-left: auto;
}

/* Tables */
.table-container,
.table-responsive {
    background: var(--bg-card);
    border-radius: var(--card-radius);
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* Smooth scrolling on iOS */
    margin-bottom: 20px;
}

/* User Info */
.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    background: white;
    padding: 6px 14px;
    /* Slightly reduced */
    border-radius: 30px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.03);
    font-size: 14px;
    font-weight: 600;
}

/* Dashboard Cards */
.dashboard-cards {
    display: flex;
    gap: 20px;
    /* Reduced gap */
    margin-bottom: 25px;
    /* Reduced margin */
    flex-wrap: wrap;
    margin-top: 5px;
    /* Ensure small top margin */
}

.stat-card {
    flex: 1;
    min-width: 260px;
    background: var(--bg-card);
    padding: 25px;
    border-radius: var(--card-radius);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
    display: flex;
    align-items: center;
    gap: 20px;
}

.icon-box {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.icon-box.income {
    background-color: var(--success-bg);
    color: var(--success-text);
}

.icon-box.expense {
    background-color: var(--danger-bg);
    color: var(--danger-text);
}

.icon-box.balance {
    background-color: var(--info-bg);
    color: var(--info-text);
}

.stat-info .label {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 8px;
    font-weight: 500;
}

.stat-info .value {
    color: var(--text-main);
    font-size: 24px;
    font-weight: 700;
}

/* Charts & Lists */
.chart-section {
    background: var(--bg-card);
    border-radius: var(--card-radius);
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
    margin-bottom: 30px;
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 25px;
}

/* Tables */
/* Tables - styles moved up */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th {
    text-align: left;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 13px;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 20px;
    color: var(--text-main);
    border-bottom: 1px solid #F8F8F8;
    font-size: 14px;
    font-weight: 600;
}

tr:last-child td {
    border-bottom: none;
}

/* Forms & Inputs */
input,
select {
    width: 100%;
    padding: 14px 16px;
    background-color: #FFFFFF;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 14px;
    color: var(--text-main);
    margin-bottom: 20px;
    outline: none;
    transition: var(--transition);
}

.header-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 20px;
    gap: 10px;
}

.filter-card {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 16px;
    margin-bottom: 30px;
    border: 1px solid var(--border-color);
}

.filter-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.filter-header h4 {
    margin: 0;
    color: var(--text-main);
    font-weight: 700;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    align-items: end;
}

.filter-actions {
    display: flex;
    gap: 10px;
    margin-top: 25px;
}

.badge-category {
    background: rgba(0, 0, 0, 0.05);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-muted);
}

.btn-outline-success {
    background: var(--bg-card);
    color: var(--success-text);
    border: 1px solid var(--border-color);
    font-size: 14px;
    padding: 8px 15px;
}

.btn-outline-danger {
    background: var(--bg-card);
    color: #E74C3C;
    border: 1px solid var(--border-color);
    font-size: 14px;
    padding: 8px 15px;
}

.btn-outline {
    padding: 10px 25px;
    border-radius: 8px;
    background: var(--bg-body);
    color: var(--text-muted);
    text-decoration: none;
}

.btn-icon,
.btn-icon-danger {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
}

.btn-icon {
    color: var(--text-muted);
}

.btn-icon-danger {
    color: var(--danger-text);
}

.text-success {
    color: var(--success-text);
}

.text-danger {
    color: var(--danger-text);
}

.text-primary {
    color: var(--primary-color);
}

.text-muted {
    color: var(--text-muted);
}

.fw-500 {
    font-weight: 500;
    color: var(--text-main);
}

.fw-600 {
    font-weight: 600;
}

input:focus,
select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(108, 93, 211, 0.1);
}

.btn {
    padding: 14px 24px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.login-card {
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.05);
    max-width: 400px;
    margin: auto;
    text-align: center;
}

.menu-toggle {
    display: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-main);
    margin-right: 15px;
}

/* ========================================= */
/*       MOBILE & RESPONSIVE STYLES          */
/* ========================================= */

/* MOBILE STYLES REMOVED - SEE public/css/mobile-header.css AND mobile-app.css */

/* --- DESKTOP SPECIFIC RESTORES --- */
@media (min-width: 769px) {
    .mobile-only-list {
        display: none !important;
    }

    .bottom-nav {
        display: none !important;
    }

    .desktop-only-table {
        display: block;
    }

    /* Ensure Header looks normal on desktop */
    .main-header {
        justify-content: flex-start;
        gap: 20px;
    }

    .user-info {
        display: flex !important;
    }

    .menu-toggle {
        display: none;
    }

    /* --- STRICT FIXED SIDEBAR (User Requirement) --- */
    .sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        height: 100vh !important;
        /* Fallback */
        height: 100dvh !important;
        z-index: 1000;
        overflow-y: auto;
    }

    /* Content push for fixed sidebar */
    .content {
        margin-left: 280px !important;
        width: auto !important;
        /* Let flex/block handle width */
        flex: none !important;
        /* Disable flex behavior if generic */
        display: block !important;
    }

    /* Ensure App Container allows this layout mode */
    .app-container {
        display: block !important;
    }
}

/* Utilities */
.table-responsive {
    margin-top: 20px !important;
}

.mobile-only-cell {
    display: none;
}

/* Auth Background Animation */
@keyframes gradientAnimation {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.auth-bg-animated {
    background: linear-gradient(-45deg, #6C5DD3, #8B7DE8, #5849BE, #1F2128);
    background-size: 400% 400%;
    animation: gradientAnimation 15s ease infinite;
    padding: 0 !important;
    width: 44px !important;
    height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    /* Cola na Esquerda */
}

html body .user-info {
    padding: 0 !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    /* Cola na Direita */
}

/* 3. Containers Internos: REMOVEMOS o padding p/ não duplicar */
html body .dashboard-controls,
html body .stats-grid-mobile {
    padding: 0 !important;
    margin: 0 0 20px 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 15px !important;
}

/* 4. Filtros e Pesquisa */
html body .date-pill-text {
    width: 100% !important;
    display: flex !important;
    justify-content: center !important;
    padding: 12px !important;
    border-radius: 12px !important;
    background: white !important;
    border: 1px solid var(--border-color) !important;
    font-weight: 500 !important;
}

html body #monthFilterForm {
    width: 100% !important;
    display: flex !important;
    flex-direction: row !important;
    gap: 8px !important;
    align-items: stretch !important;
    /* Força altura igual */
    justify-content: space-between !important;
}

html body #monthFilterForm select {
    flex: 1 !important;
    min-width: 0 !important;
    height: 48px !important;
    border-radius: 12px !important;
    background: white !important;
    border: 1px solid var(--border-color) !important;
    padding: 0 10px !important;
    font-size: 14px !important;
    margin: 0 !important;
}

html body .btn-icon {
    width: 48px !important;
    height: 48px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 12px !important;
    background: white !important;
    border: 1px solid var(--border-color) !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
}

/* 5. Todos os Cards: largura 100% do espaço disponível */
html body .card-modern,
html body .stat-card,
html body .login-card,
html body .chart-section {
    margin: 0 0 15px 0 !important;
    width: 100% !important;
    border-radius: 20px !important;
    padding: 20px !important;
    background: white !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04) !important;
    box-sizing: border-box !important;
    border: 1px solid rgba(0, 0, 0, 0.03) !important;
}

/* REGRA ESTRITA: Cards de estatísticas (Dashboard) */
html body .stats-grid-mobile .card-modern {
    display: flex !important;
    flex-direction: row !important;
}

/* 6. ÁREA ADMIN (Módulo Isolado - v60.0) */

html body .admin-container {
    padding: 0 !important;
    margin: 0 !important;
}

html body .admin-container .section-header {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    height: auto !important;
    margin-bottom: 25px !important;
}

/* Ações do Topo (Filtros, Busca, Botões) */
html body .admin-container .header-actions {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    gap: 15px !important;
    height: auto !important;
    /* Permitir empilhamento sem corte */
}

/* Filtros Rápidos: ESTADO HORIZONTAL */
html body .admin-container .status-filter-container {
    display: flex !important;
    flex-direction: row !important;
    width: 100% !important;
    height: 48px !important;
    background: #f1f5f9 !important;
    padding: 4px !important;
    border-radius: 12px !important;
    gap: 4px !important;
    box-sizing: border-box !important;
}

html body #tab-all,
html body #tab-trial,
html body #tab-sub,
html body .admin-container .filter-tab {
    flex: 1 !important;
    height: 100% !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    border-radius: 10px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 5px !important;
    background: transparent;
    color: #64748b;
}

html body .admin-container .filter-tab.active {
    background: white !important;
    color: var(--primary-color) !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05) !important;
}

/* Busca Estilo Pill (Canto Arredondado Total) */
html body .admin-container .search-container {
    width: 100% !important;
    height: 48px !important;
    position: relative !important;
}

html body .admin-container .search-container input#user-search {
    width: 100% !important;
    height: 100% !important;
    border-radius: 50px !important;
    border: 2px solid #f1f5f9 !important;
    padding: 0 15px 0 45px !important;
    box-sizing: border-box !important;
    font-size: 14px !important;
}

/* Botões de Ação do Topo */
html body .admin-container .header-actions-buttons {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    gap: 10px !important;
}

html body .admin-container .btn-admin {
    width: 100% !important;
    height: 48px !important;
    border-radius: 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Cards de Estatística */
html body .admin-container>div[style*="grid"]:not(.admin-table-container) {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    margin-bottom: 25px !important;
}

html body .admin-container .admin-card:not(:has(.admin-table)) {
    background: white !important;
    border-radius: 20px !important;
    padding: 20px !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 15px !important;
    border: 1px solid rgba(0, 0, 0, 0.03) !important;
}

/* TABELA TRANSFORMADA EM LISTA (v60.0) */
html body .admin-container .admin-card:has(.admin-table) {
    background: white !important;
    border-radius: 20px !important;
    padding: 0 20px !important;
    /* Padding lateral 15-20px */
    border: 1px solid rgba(0, 0, 0, 0.04) !important;
}

html body .admin-table thead {
    display: none !important;
}

html body .admin-table,
html body .admin-table tbody,
html body .admin-table tr,
html body .admin-table td {
    display: block !important;
    width: 100% !important;
}

html body .admin-table tr {
    padding: 20px 0 !important;
    border-bottom: 1px solid #f1f5f9 !important;
    background: transparent !important;
    margin: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

html body .admin-table tr:last-child {
    border-bottom: none !important;
}

html body .admin-table td {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 8px 0 !important;
    border: none !important;
}

/* Destaque para o primeiro item (Utilizador) */
html body .admin-table td:first-child {
    justify-content: flex-start !important;
    margin-bottom: 10px !important;
    padding-bottom: 15px !important;
    border-bottom: 1px solid #f8fafc !important;
}

/* Selo de Estado (Badge) - Alinhado à direita na linha dele */
html body .admin-table td:not([data-label]):not(:first-child):not(:last-child) {
    justify-content: flex-end !important;
}

/* Labels de Dados (Plano, Expira em) */
html body .admin-table td::before {
    content: attr(data-label);
    font-weight: 700;
    color: #94a3b8;
    font-size: 11px;
    text-transform: uppercase;
}

html body .admin-table td:first-child::before,
html body .admin-table td:last-child::before {
    display: none !important;
}

/* Ações na base da linha */
html body .admin-table td:last-child {
    margin-top: 10px !important;
    padding-top: 15px !important;
    border-top: 1px solid #f8fafc !important;
    justify-content: center !important;
    gap: 10px !important;
}

html body .admin-table .action-btn {
    width: 44px !important;
    height: 44px !important;
    border-radius: 12px !important;
    background: #f8fafc !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
}


/* FIM DO BLOCO MOBILE @media (max-width: 768px) */

/* 7. Tipografia e Botões */
h2,
.main-header h2 {
    font-size: 18px !important;
}

h3,
.section-title {
    font-size: 16px !important;
    margin-bottom: 20px !important;
}

input,
select,
textarea,
button,
.btn {
    border-radius: 12px !important;
    height: 48px !important;
}