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

/* Custom Scrollbar styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    border: 3px solid transparent;
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
    border: 3px solid transparent;
    background-clip: padding-box;
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) rgba(0, 0, 0, 0.2);
}

:root {
    --bg-dark: #0a0a0c;
    --primary-gradient: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    --primary-color: #ea580c;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --text-main: #ffffff;
    --text-muted: #9ca3af;
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.05);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
}

/* Background Effects */
.bg-mesh {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(circle at 15% 50%, rgba(234, 88, 12, 0.15), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(234, 88, 12, 0.1), transparent 25%);
    z-index: -1;
    pointer-events: none;
}

/* Typography */
h1,
h2,
h3 {
    font-weight: 600;
    letter-spacing: -0.02em;
}

.mono {
    font-family: 'JetBrains Mono', monospace;
}

.text-xs {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
}

/* Glass Panel */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--glass-shadow);
}

/* Buttons */
.btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary-gradient);
    border: none;
    box-shadow: 0 4px 15px rgba(234, 88, 12, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #fb923c 0%, #f97316 100%);
    box-shadow: 0 6px 20px rgba(234, 88, 12, 0.4);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
    color: var(--danger-color);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* Inputs */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.form-control {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.15);
}

/* Layout */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    position: relative;
    z-index: 10;
    overflow: visible !important;
}

.header-logo {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Table */
.table-container {
    width: 100%;
    overflow-x: auto;
    border-radius: 16px;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    padding: 16px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--glass-border);
}

td {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    font-size: 0.9rem;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.badge {
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Modal */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
}

.modal-backdrop.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    width: 100%;
    max-width: 450px;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-backdrop.active .modal {
    transform: translateY(0) scale(1);
}

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

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 24px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Login Screen */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    width: 100%;
    max-width: 400px;
    padding: 40px;
    text-align: center;
}

.login-icon {
    width: 64px;
    height: 64px;
    background: rgba(234, 88, 12, 0.1);
    border: 1px solid rgba(234, 88, 12, 0.2);
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    color: var(--primary-color);
}

/* Custom Dropdown Styling */
.custom-select-wrapper {
    position: relative;
    user-select: none;
    z-index: 10;
    /* Z-index base baixo */
}

.custom-select-wrapper.open {
    z-index: 1001;
    /* Z-index alto quando aberto para ficar sobre a tabela */
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    font-size: 0.9rem;
    color: #fff;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;

}

.custom-select-trigger:after {
    content: '';
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #9ca3af;
    transition: transform 0.3s ease;
}

.custom-select-wrapper.open .custom-select-trigger:after {
    transform: rotate(180deg);
}

.custom-select-trigger:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary-color);
}

.custom-options {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: rgba(15, 15, 20, 0.98);
    backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.8);
    display: none;
    z-index: 1002;
    max-height: 250px;
    overflow-y: auto;
    padding: 8px;
}

.tabs-container {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
    overflow: visible !important;
    /* Garante que o select não seja cortado */
    position: relative;
    z-index: 100;
    /* Fica acima da tabela */
}

.custom-options.show {
    display: block;
    animation: slideDown 0.2s ease-out;
}

.custom-option {
    padding: 10px 15px;
    font-size: 0.85rem;
    color: #fff;
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.custom-option:hover {
    background: rgba(249, 115, 22, 0.15);
    color: var(--primary-color);
}

.custom-option.selected {
    background: var(--primary-gradient);
    color: #fff;
}

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

/* --- MOBILE RESPONSIVENESS --- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        z-index: 9999 !important; /* Garantir que fique acima de TUDO */
        position: fixed;
        background: rgba(15, 15, 20, 0.98) !important; /* Quase sólido para mobile */
        backdrop-filter: blur(20px);
        box-shadow: none;
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .sidebar.active {
        transform: translateX(0);
        box-shadow: 20px 0 60px rgba(0,0,0,0.8);
    }

    #sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.6);
        backdrop-filter: blur(5px);
        z-index: 9998 !important; /* Logo abaixo da sidebar */
        pointer-events: auto;
    }

    .sidebar.active + #sidebar-overlay {
        display: block;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 80px 15px 15px 15px !important; /* Aumentado padding-top para o header fixo */
        width: 100% !important;
    }

    .main-content > header {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        z-index: 1000;
        background: rgba(15, 15, 20, 0.8);
        backdrop-filter: blur(12px);
        padding: 15px !important;
        margin-bottom: 0 !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .dash-grid {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }

    .stats-container {
        grid-template-columns: 1fr !important;
    }

    /* --- Tabela transformada em Cards Mobile --- */
    .table-container {
        background: transparent;
        border: none;
        box-shadow: none;
        overflow: visible;
        margin: 0;
        width: 100%;
    }

    table, thead, tbody, th, td, tr {
        display: block; /* Transforma tudo em bloco */
    }

    thead {
        display: none; /* Esconde o cabeçalho da tabela */
    }

    tbody tr {
        background: rgba(255, 255, 255, 0.03);
        backdrop-filter: blur(10px);
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 16px;
        margin-bottom: 12px;
        padding: 15px;
        position: relative;
        transition: transform 0.2s;
    }

    tbody tr:active {
        transform: scale(0.98);
    }

    td {
        padding: 4px 0 !important;
        border: none !important;
        text-align: left !important;
        height: auto !important;
    }

    /* Nome do Gasto */
    td:nth-child(1) {
        font-size: 1.1rem !important;
        color: #fff !important;
        padding-bottom: 8px !important;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    /* Vencimento */
    td:nth-child(2) {
        font-size: 0.8rem !important;
        color: var(--text-muted) !important;
        display: inline-block;
    }
    td:nth-child(2)::before {
        content: "Vence em: ";
    }

    /* Mês (Ocultar no Mobile) */
    td:nth-child(3) {
        display: none;
    }

    /* Valor */
    td:nth-child(4) {
        font-size: 1.2rem !important;
        font-weight: 800 !important;
        color: #4ade80 !important;
        margin: 8px 0 !important;
    }

    /* Ações */
    td:nth-child(5) {
        margin-top: 10px !important;
        padding-top: 12px !important;
        border-top: 1px solid rgba(255, 255, 255, 0.05) !important;
        display: flex;
        gap: 8px;
        justify-content: flex-end;
    }

    td:nth-child(5) .btn {
        padding: 8px 15px !important;
        font-size: 0.75rem !important;
        flex: 1; /* Botões ocupam espaço igual */
    }

    td:nth-child(5) .btn:last-child {
        flex: 0; /* Botão de 'visto' continua pequeno */
        min-width: 40px;
    }

    .tabs-container {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 10px;
        gap: 8px;
    }

    .modal {
        width: 95% !important;
        max-height: 95vh !important;
        margin: 10px auto;
    }

    .modal-content {
        padding: 15px !important;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px;
    }

    .custom-select-wrapper {
        width: 100% !important;
    }
}