:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --success: #10b981;
    --pending: #f59e0b;
    --danger: #ef4444;
    --border: #e2e8f0;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 80px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body { 
    background-color: var(--bg-page); 
    color: var(--text-main); 
    min-height: 100vh; 
    display: flex; 
    flex-direction: row;
    line-height: 1.5;
    overflow-x: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100vh;
    z-index: 1000;
    transition: var(--transition);
}

.sidebar-header {
    padding: 1rem 1.5rem;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.sidebar-menu { flex: 1; padding: 1rem; overflow-y: auto; }

.menu-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 0.75rem;
    margin-bottom: 0.25rem;
    transition: var(--transition);
    font-weight: 500;
    font-size: 0.95rem;
    white-space: nowrap;
}

.menu-item i { font-style: normal; margin-right: 1rem; font-size: 1.25rem; min-width: 24px; text-align: center; }
.menu-item:hover { background: #f1f5f9; color: var(--text-main); }
.menu-item.active { background: var(--primary); color: white; box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2); }

/* Main Content */
.main-content { 
    margin-left: var(--sidebar-width); 
    flex: 1; 
    padding: 2rem; 
    min-width: 0; /* Importante para flexbox não quebrar com conteúdo largo */
    transition: var(--transition); 
}

/* Barra superior mobile */
.mobile-header { display: none; }

@media (max-width: 992px) {
    body {
        flex-direction: column;
    }

    .sidebar { 
        transform: translateX(-100%); 
        width: 280px; /* Um pouco mais largo no mobile */
    }
    body.sidebar-open .sidebar { transform: translateX(0); }
    
    .main-content { 
        margin-left: 0; 
        width: 100%; 
        padding: 1.25rem; 
        padding-top: 1rem;
    }
    
    /* Overlay para fechar o menu ao clicar fora */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
        backdrop-filter: blur(2px);
    }
    body.sidebar-open .sidebar-overlay { display: block; }
    
    /* Barra superior mobile */
    .mobile-header {
        display: flex !important;
        position: sticky;
        top: 0;
        background: white;
        padding: 0.75rem 1.25rem;
        border-bottom: 1px solid var(--border);
        z-index: 100;
        justify-content: space-between;
        align-items: center;
        height: 60px;
        width: 100%;
    }
}

.container { max-width: 1100px; margin: 0 auto; }

/* Cards */
.card { 
    background: var(--bg-card); 
    border: 1px solid var(--border); 
    border-radius: 1.25rem; 
    padding: 1.5rem; 
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.02); 
    margin-bottom: 1.5rem; 
}

/* Forms */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; margin-bottom: 0.5rem; color: var(--text-main); font-size: 0.85rem; font-weight: 600; }

input, select, textarea { 
    width: 100%; 
    padding: 0.75rem 1rem; 
    background: #ffffff; 
    border: 1px solid var(--border); 
    border-radius: 0.75rem; 
    color: var(--text-main); 
    font-size: 0.95rem;
    transition: all 0.2s;
    outline: none;
}
input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1); }

/* Buttons */
.btn { 
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    padding: 0.75rem 1.5rem; 
    border-radius: 0.75rem; 
    font-weight: 600; 
    cursor: pointer; 
    transition: 0.2s; 
    text-decoration: none; 
    gap: 0.5rem; 
    border: none;
}
.btn-primary { background: var(--primary); color: white; }
.btn-outline { background: white; border: 1px solid var(--border); color: var(--text-main); }
.btn-sm { padding: 0.5rem 1rem; font-size: 0.8rem; }

/* Tables */
.table-responsive { overflow-x: auto; width: 100%; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 1rem; color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; border-bottom: 1px solid var(--border); }
td { padding: 1rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }

/* Mobile Table Cards */
@media (max-width: 640px) {
    .table-mobile-cards table, 
    .table-mobile-cards thead, 
    .table-mobile-cards tbody, 
    .table-mobile-cards th, 
    .table-mobile-cards td, 
    .table-mobile-cards tr { 
        display: block; 
    }
    
    .table-mobile-cards thead tr { 
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    .table-mobile-cards tr { 
        border: 1px solid var(--border);
        border-radius: 1rem;
        margin-bottom: 1rem;
        background: white;
        padding: 0.5rem;
    }
    
    .table-mobile-cards td { 
        border: none;
        border-bottom: 1px solid #f1f5f9;
        position: relative;
        padding-left: 50%; 
        text-align: right;
        min-height: 3rem;
        display: flex;
        align-items: center;
        justify-content: flex-end;
    }
    
    .table-mobile-cards td:last-child {
        border-bottom: none;
    }
    
    .table-mobile-cards td:before { 
        content: attr(data-label);
        position: absolute;
        left: 1rem;
        width: 45%; 
        padding-right: 10px; 
        white-space: nowrap;
        text-align: left;
        font-weight: 700;
        color: var(--text-muted);
        font-size: 0.75rem;
        text-transform: uppercase;
    }

    .table-mobile-cards td.no-label {
        padding-left: 1rem;
        justify-content: center;
        text-align: center;
    }
    .table-mobile-cards td.no-label:before {
        display: none;
    }
}

/* Badges */
.badge { padding: 0.35rem 0.75rem; border-radius: 2rem; font-size: 0.65rem; font-weight: 700; border: 1px solid transparent; }
.badge-paid { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.badge-pending { background: #fffbeb; color: #b45309; border-color: #fde68a; }

/* Client List */
.client-list-item {
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    transition: var(--transition);
}
.client-list-item:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.client-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

@media (max-width: 640px) {
    .client-list-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    .client-actions {
        width: 100%;
        justify-content: space-between;
        border-top: 1px solid #f1f5f9;
        padding-top: 0.75rem;
    }
    .client-actions .btn {
        flex: 1;
        min-width: 40px;
    }
    .client-actions form {
        flex: 1;
        display: flex;
    }
    .client-actions form .btn {
        width: 100%;
    }
}

.report-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 900px) {
    .report-grid {
        grid-template-columns: 1fr;
    }
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.webhook-group {
    display: flex;
    gap: 0.5rem;
}

@media (max-width: 800px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }
    .webhook-group {
        flex-direction: column;
    }
    .btn-save-all {
        width: 100%;
        padding: 1rem !important;
    }
}

.animate-fade { animation: fadeIn 0.4s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* Estilos de Impressão */
@media print {
    .sidebar, .mobile-header, .sidebar-overlay, .btn, .header p, .card:has(form), .report-grid .card:last-child {
        display: none !important;
    }
    
    body {
        background: white !important;
        padding: 0 !important;
        display: block !important;
    }
    
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
    
    .container {
        max-width: 100% !important;
    }
    
    .card {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin-bottom: 2rem !important;
    }
    
    .card h3 {
        margin-bottom: 1rem !important;
        border-bottom: 2px solid #000 !important;
        padding-bottom: 0.5rem !important;
    }
    
    table {
        border: 1px solid #eee !important;
    }
    
    th {
        background: #f8fafc !important;
        color: black !important;
        -webkit-print-color-adjust: exact;
    }
    
    .badge {
        border: 1px solid #ccc !important;
        color: black !important;
        background: white !important;
    }
    
    /* Mostrar cabeçalho do relatório na impressão */
    .header h1 {
        text-align: center;
        margin-bottom: 2rem;
    }
}
