/* ==========================================================================
   1. GERAL E LAYOUT BASE
   ========================================================================== */
   
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    background-color: #f4f7fa;
    margin: 0;
    font-family: 'Poppins', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #333;
}

.grid-container {
    display: grid;
    grid-template-columns: 260px 1fr;
    grid-template-areas: "sidebar main";
    min-height: 100vh;
}

.main-content {
    grid-area: main;
    padding: 25px;
}

.main-footer {
    text-align: center;
    padding-top: 20px;
    margin-top: 20px;
    border-top: 1px solid #e0e0e0;
    color: #777;
    font-size: 13px;
}

/* ==========================================================================
   2. SIDEBAR (MENU LATERAL)
   ========================================================================== */
.sidebar {
    grid-area: sidebar;
    background-color: #0d1b2a;
    color: #e0e1dd;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100%;
    width: 260px;
    z-index: 100;
}
.sidebar-header {
    display: flex;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #1b263b;
}
.sidebar-header .fa-whatsapp {
    color: #25D366;
    font-size: 32px;
    margin-right: 15px;
}
.sidebar-header h1 {
    font-size: 20px;
    margin: 0;
    font-weight: 600;
    color: #ffffff;
}
.sidebar-nav {
    flex-grow: 1;
    padding-top: 15px;
}
.sidebar-nav a, .sidebar-footer a {
    display: flex;
    align-items: center;
    color: #e0e1dd;
    padding: 15px 25px;
    text-decoration: none;
    font-size: 16px;
    transition: background-color 0.3s, color 0.3s;
}
.sidebar-nav a:hover, .sidebar-footer a:hover {
    background-color: #1a73e8;
    color: #ffffff;
}
.sidebar-nav a i, .sidebar-footer a i {
    margin-right: 20px;
    width: 20px;
    text-align: center;
}
.sidebar-footer {
    padding-bottom: 15px;
    border-top: 1px solid #1b263b;
}
.usuario-logado {
    display: flex;
    align-items: center;
    padding: 15px 25px;
    border-top: 1px solid #1b263b;
    background-color: rgba(0,0,0,0.2);
}
.usuario-logado i {
    font-size: 24px;
    margin-right: 15px;
    color: #fff;
}
.usuario-logado span {
    color: #fff;
    font-weight: 500;
    line-height: 1.2;
}
.usuario-logado small {
    display: block;
    font-size: 12px;
    color: #adb5bd;
    font-weight: 400;
}

/* ==========================================================================
   3. COMPONENTES REUTILIZÁVEIS
   ========================================================================== */

/* --- Títulos de Página --- */
h2 {
    color: #0d1b2a;
    border-bottom: 2px solid #1a73e8;
    padding-bottom: 10px;
    margin-top: 0;
    margin-bottom: 25px;
}

/* Header Flexível para as páginas com botões do lado direito */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}
.page-header h2 {
    margin: 0;
    border: none;
    padding: 0;
}

/* --- Cards --- */
.card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.07);
    margin-bottom: 25px;
}
/* Cards com destaque no topo para módulos específicos */
.card-danger { border-top: 4px solid #dc3545; }
.card-success { border-top: 4px solid #198754; }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #eee;
}
.card-header h3 {
    margin: 0;
    font-size: 20px;
    color: #0d1b2a;
}
.card-header h3 i {
    margin-right: 10px;
    color: #1a73e8;
}
.card-body {
    padding: 25px;
    line-height: 1.8;
}
.card-body i {
    margin-right: 10px;
    color: #555;
    width: 20px;
    text-align: center;
}

/* --- Bolinha de Cor (Categorias) --- */
.color-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    vertical-align: middle;
}

/* --- Botões --- */
.btn {
    display: inline-block;
    padding: 10px 18px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}
.btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    color: #fff;
}
.btn i {
    color: inherit !important;
}
.btn-sm { padding: 6px 12px; font-size: 14px; margin-right: 8px; }
.btn-icon {
    width: 32px;  
    height: 32px; 
    padding: 0;   
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.btn-icon i {
    margin-right: 0;
    font-size: 14px;
}

.btn-primary { background-color: #1a73e8; }
.btn-success { background-color: #28a745; }
.btn-danger { background-color: #e53935; }
.btn-warning { background-color: #ffc107; color: #333; }
.btn-info { background-color: #31a0e3; } 

/* --- Alertas --- */
.alert {
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid transparent;
    border-radius: 6px;
}
.alert-sucesso { background-color: #d4edda; color: #155724; border-color: #c3e6cb; }
.alert-erro { background-color: #f8d7da; color: #721c24; border-color: #f5c6cb; }

/* --- Tabelas de Listagem --- */
.tabela-listagem {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
}
.tabela-listagem thead th {
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    background-color: #f8f9fa;
    color: #333;
    border-bottom: 2px solid #e9ecef;
}
.tabela-listagem th.sortable a {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 8px;
}
.tabela-listagem th.sortable a:hover {
    color: #1a73e8;
}
.tabela-listagem th.sortable i {
    font-size: 12px;
}
.tabela-listagem tbody tr {
    background-color: #ffffff;
    border-radius: 8px;
    transition: box-shadow 0.2s ease-in-out, transform 0.2s ease-in-out;
}
.tabela-listagem tbody tr:hover {
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}
.tabela-listagem tbody td {
    padding: 15px;
    vertical-align: middle;
    border-bottom: 1px solid #f1f1f1;
}
.tabela-listagem tbody tr td:first-child { border-top-left-radius: 8px; border-bottom-left-radius: 8px; }
.tabela-listagem tbody tr td:last-child { border-top-right-radius: 8px; border-bottom-right-radius: 8px; }
.tabela-listagem tbody tr:last-child td { border-bottom: none; }
.sem-dados { text-align: center; padding: 40px; color: #777; }

/* --- Status Badges --- */
.status-badge {
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 600;
    color: white;
    text-transform: capitalize;
}
.status-ativo, .status-pago { background-color: #28a745; }
.status-pendente { background-color: #ffc107; color: #333; }
.status-encerrado { background-color: #6c757d; }
.status-cancelado { background-color: #dc3545; }
.status-assinado { background-color: #198754; font-size: 10px; padding: 2px 8px;}
.status-assinado i { font-size: 9px; margin-right: 3px; }

/* ==========================================================================
   4. FORMULÁRIOS E FILTROS (REVISADO PARA ALINHAMENTO PERFEITO)
   ========================================================================== */

/* Padrão para todos os labels do sistema */
.form-card label, .form-group label {
    display: block;
    font-weight: 600;
    color: #495057;
    margin-bottom: 8px;
    font-size: 14px;
}

/* Garante que os campos fiquem sempre alinhados por baixo, mesmo se um label tiver 2 linhas */
.form-group { 
    flex: 1; 
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

/* Campos de Input, Select e Textarea do form principal */
.form-card input, .form-card textarea, .form-card select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    margin-bottom: 20px;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 15px;
    color: #495057;
    background-color: #fff;
    transition: border-color 0.3s, box-shadow 0.3s;
    height: 48px; /* Força a mesma altura para tudo */
}

/* --- Layout Base do Card de Formulário --- */
.form-card { border: none; padding: 0; margin: 0; }
.form-card fieldset { border: none; padding: 0; margin: 0 0 25px 0; }
.form-card legend {
    font-size: 18px;
    font-weight: 600;
    color: #1a73e8;
    margin-bottom: 20px;
    padding-bottom: 5px;
    width: 100%;
    border-bottom: 1px solid #e0e0e0;
}

.form-card input:focus, .form-card textarea:focus, .form-card select:focus {
    border-color: #1a73e8;
    box-shadow: 0 0 5px rgba(26, 115, 232, 0.2);
    outline: none;
}
.form-row { display: flex; gap: 20px; }

/* ---------------------------------------------------
   FILTROS AVANÇADOS (VISUAL DASHBOARD)
   --------------------------------------------------- */
.form-filtro {
    background-color: #fff;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 25px;
}

.form-filtro form {
    display: flex;
    gap: 15px;
    width: 100%;
    align-items: flex-end; /* Alinha magicamente os botões e inputs pela base */
    margin: 0;
    flex-wrap: wrap; /* Evita quebrar layout no tablet */
}

.form-filtro .form-group {
    margin-bottom: 0; /* No filtro, a margem vem do box de fora */
}

.form-filtro label {
    font-size: 12px;
    font-weight: 700;
    color: #6c757d;
    text-transform: uppercase;
    display: block;
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

.form-filtro input, .form-filtro select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 0; 
    height: 42px; /* Altura padrão e esbelta específica para o filtro */
    background-color: #fff;
    color: #495057;
    box-sizing: border-box;
}

.form-filtro .botoes-acao {
    display: flex;
    gap: 10px;
    height: 42px; /* Força os botões a terem exatamente a mesma altura dos inputs do filtro */
}

.form-filtro .btn {
    height: 100%; 
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 15px;
    margin: 0;
}

/* ==========================================================================
   5. DASHBOARD E CARDS DE RESUMO
   ========================================================================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
}
.dashboard-grid .full-width-card { grid-column: 1 / -1; }
.dashboard-grid .span-2-card { grid-column: span 2; }

.stat-card {
    background-color: #ffffff;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.07);
    display: flex;
    flex-direction: column;
}
.stat-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #5a6268;
    font-weight: 700;
}
.stat-card-header i { font-size: 24px; color: #1a73e8; opacity: 0.7; }
.stat-card-value { font-size: 36px; font-weight: 700; color: #0d1b2a; margin: 10px 0; }

.list-card ul { list-style: none; padding: 0; margin: 15px 0 0 0; }
.list-card li { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid rgba(0,0,0,0.05); font-size: 14px; }
.list-card li:last-child { border-bottom: none; }
.list-card li a { text-decoration: none; font-weight: 500; color: #333; }
.list-card li a:hover { color: #1a73e8; }
.list-card li span, .list-card li small { color: #6c757d; }
.list-card.aguardando-assinatura { background-color: #e7f3ff; border-left: 5px solid #0d6efd; }
.list-card.proximo-vencimento { background-color: #fff8e1; border-left: 5px solid #ffc107; }

.tabela-detalhes { width: 100%; border-collapse: collapse; margin-top: 15px; }
.tabela-detalhes th, .tabela-detalhes td { padding: 8px 5px; text-align: left; border-bottom: 1px solid #f1f1f1; font-size: 14px; }
.tabela-detalhes th { font-weight: 600; color: #6c757d; }
.tabela-detalhes tbody tr:last-child td { border-bottom: none; }
.tabela-detalhes a { text-decoration: none; font-weight: 500; color: #333; }
.tabela-detalhes a:hover { color: #1a73e8; }

/* Cards de Resumo Rápido (Usados no Financeiro) */
.summary-cards {
    display: flex;
    gap: 20px;
    margin-bottom: 25px;
}
.summary-card {
    flex: 1;
    background-color: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    border-left: 5px solid #1a73e8;
}
.summary-card.danger { border-left-color: #dc3545; }
.summary-card.warning { border-left-color: #ffc107; }
.summary-card.success { border-left-color: #198754; }
.summary-card.info { border-left-color: #20c997; }

.summary-card p {
    margin: 0;
    color: #6c757d;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
}
.summary-card h3 {
    margin: 5px 0 0 0;
    color: #333;
    font-size: 24px;
}

/* ==========================================================================
   6. PAGINAÇÃO E LOGIN
   ========================================================================== */
.paginacao {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 25px;
}
.paginacao a {
    text-decoration: none;
    color: #1a73e8;
    padding: 8px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    transition: all 0.3s;
}
.paginacao a:hover {
    background-color: #e7f3ff;
    border-color: #1a73e8;
}
.paginacao a.ativo {
    background-color: #1a73e8;
    color: white;
    border-color: #1a73e8;
    font-weight: 600;
}

/* Login - Split Screen */
.login-wrapper {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden; 
}
.login-branding {
    flex: 1;
    background-image: linear-gradient(135deg, #1a73e8 0%, #0d1b2a 100%);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 40px;
}
.login-branding .brand-logo .fa-whatsapp { font-size: 80px; margin-bottom: 20px; text-shadow: 0 4px 15px rgba(0,0,0,0.2); }
.login-branding h1 { font-size: 2.5rem; font-weight: 700; margin: 0 0 10px 0; letter-spacing: 1px; }
.login-branding p { font-size: 1.125rem; max-width: 400px; opacity: 0.8; line-height: 1.6; }

.login-form-area {
    flex: 1;
    background-color: #f4f7fa;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}
.form-container { width: 100%; max-width: 400px; }
.form-container h2 { font-size: 2rem; color: #0d1b2a; margin-bottom: 30px; text-align: left; border-bottom: 3px solid #1a73e8; padding-bottom: 10px; }
.form-container .form-group { margin-bottom: 25px; position: relative; }
.form-container .form-group label { display: block; font-weight: 600; color: #5a6268; margin-bottom: 8px; font-size: 14px; }
.form-container .form-group input { width: 100%; padding: 15px; border: 1px solid #ccc; border-radius: 8px; font-size: 16px; font-family: 'Poppins', sans-serif; transition: all 0.3s ease; }
.form-container .form-group input:focus { border-color: #1a73e8; box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.2); outline: none; }
.form-container .options { display: flex; justify-content: space-between; align-items: center; font-size: 14px; margin-bottom: 30px; }
.form-container .options .remember-me { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.form-container .options a { color: #1a73e8; text-decoration: none; font-weight: 600; }
.form-container .options a:hover { text-decoration: underline; }
.form-container .btn-login { width: 100%; padding: 16px; font-size: 18px; font-weight: 600; letter-spacing: 0.5px; border-radius: 8px; }
.form-container .alert-erro { text-align: center; }

/* ==========================================================================
   7. RESPONSIVIDADE
   ========================================================================== */
@media (max-width: 992px) {
    .dashboard-grid .full-width-card { grid-column: span 1; }
    
    .login-wrapper { flex-direction: column; }
    .login-branding { flex: 0; padding: 50px 20px; }
    .login-branding h1 { font-size: 2rem; }
    .login-branding p { font-size: 1rem; }
    .login-form-area { flex: 1; }
}

@media (max-width: 768px) {
    .grid-container { grid-template-columns: 1fr; grid-template-areas: "main"; }
    .sidebar { position: relative; width: 100%; height: auto; }
    .main-content { padding: 15px; }
    
    /* Formulários e Filtros */
    .form-row, .form-row-highlight { flex-direction: column; gap: 15px; }
    .form-filtro form { flex-direction: column; align-items: stretch; gap: 10px; }
    .summary-cards { flex-direction: column; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 15px; }
    
    /* Tabelas Responsivas */
    .tabela-listagem { display: block; width: 100%; }
    .tabela-listagem thead { display: none; }
    .tabela-listagem tr { display: block; margin-bottom: 15px; border-radius: 8px; background-color: #fff; padding: 15px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
    .tabela-listagem td { display: flex; justify-content: space-between; align-items: center; text-align: right !important; padding: 10px 0; border-bottom: 1px solid #f1f1f1; }
    .tabela-listagem td:last-child { border-bottom: none; }
    .tabela-listagem td::before { content: attr(data-label); font-weight: 600; text-align: left; margin-right: 15px; color: #333; }
}