/* =====================================================
   ChurchManager Pro — Estilo Principal
   Identidade Visual: Azul-ardósia + Verde-esmeralda
   ===================================================== */

/* --- Variáveis ---------------------------------------- */
:root {
    --cm-primary:    #1e3a5f;
    --cm-primary-d:  #152d4a;
    --cm-accent:     #16a34a;
    --cm-accent-l:   #dcfce7;
    --cm-sidebar-bg: #1e3a5f;
    --cm-sidebar-txt:#cbd5e1;
    --cm-sidebar-act:#16a34a;
    --cm-sidebar-w:  260px;

    --cm-bg:         #f1f5f9;
    --cm-card:       #ffffff;
    --cm-border:     #e2e8f0;
    --cm-text:       #1e293b;
    --cm-muted:      #64748b;

    --cm-danger:     #dc2626;
    --cm-warning:    #d97706;
    --cm-info:       #0284c7;
    --cm-success:    #16a34a;

    --radius-sm:     6px;
    --radius:        10px;
    --radius-lg:     14px;
    --shadow-sm:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow:        0 4px 12px rgba(0,0,0,.08);
    --shadow-lg:     0 8px 24px rgba(0,0,0,.10);

    --transition:    .18s ease;
}

/* --- Reset -------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--cm-text);
    background: var(--cm-bg);
    min-height: 100vh;
}

/* --- Layout ------------------------------------------- */
.cm-wrapper { display: flex; min-height: 100vh; }

/* --- Sidebar ------------------------------------------ */
.cm-sidebar {
    width: var(--cm-sidebar-w);
    min-height: 100vh;
    background: var(--cm-sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    z-index: 1040;
    transition: transform var(--transition);
}

.cm-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    text-decoration: none;
}

.cm-sidebar-brand .brand-icon {
    width: 38px; height: 38px;
    background: var(--cm-accent);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.cm-sidebar-brand .brand-text {
    font-weight: 700;
    font-size: 15px;
    color: #fff;
    line-height: 1.2;
}

.cm-sidebar-brand .brand-text small {
    display: block;
    font-size: 10px;
    font-weight: 400;
    color: rgba(255,255,255,.45);
    letter-spacing: .05em;
    text-transform: uppercase;
}

/* Igreja info na sidebar */
.cm-sidebar-church {
    padding: 12px 20px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    font-size: 12px;
    color: rgba(255,255,255,.4);
}

.cm-sidebar-church strong {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: rgba(255,255,255,.7);
    margin-bottom: 2px;
}

/* Nav */
.cm-nav { flex: 1; padding: 12px 0; overflow-y: auto; }

.cm-nav-label {
    padding: 14px 20px 4px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(255,255,255,.3);
}

.cm-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: var(--cm-sidebar-txt);
    text-decoration: none;
    font-size: 13.5px;
    border-radius: 0;
    transition: background var(--transition), color var(--transition);
    position: relative;
}

.cm-nav a i { font-size: 17px; opacity: .75; flex-shrink: 0; }

.cm-nav a:hover {
    background: rgba(255,255,255,.07);
    color: #fff;
}

.cm-nav a:hover i { opacity: 1; }

.cm-nav a.active {
    background: rgba(22,163,74,.18);
    color: #fff;
    font-weight: 500;
}

.cm-nav a.active::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--cm-accent);
    border-radius: 0 2px 2px 0;
}

.cm-nav a.active i { opacity: 1; color: var(--cm-accent); }

/* Sidebar footer */
.cm-sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid rgba(255,255,255,.08);
}

.cm-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.cm-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--cm-accent);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}

.cm-user-name {
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    line-height: 1.2;
}

.cm-user-role {
    font-size: 11px;
    color: rgba(255,255,255,.4);
}

.cm-btn-logout {
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    padding: 7px 12px;
    background: rgba(220,38,38,.15);
    border: 1px solid rgba(220,38,38,.25);
    border-radius: var(--radius-sm);
    color: #fca5a5;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition);
}

.cm-btn-logout:hover { background: rgba(220,38,38,.3); color: #fca5a5; }

/* --- Conteúdo principal -------------------------------- */
.cm-content {
    margin-left: var(--cm-sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- Topbar -------------------------------------------- */
.cm-topbar {
    height: 60px;
    background: var(--cm-card);
    border-bottom: 1px solid var(--cm-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 999;
}

.cm-topbar-left { display: flex; align-items: center; gap: 12px; }

.cm-menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: var(--cm-muted);
    font-size: 22px;
}

.cm-page-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--cm-text);
}

.cm-topbar-right { display: flex; align-items: center; gap: 16px; }

.cm-topbar-date {
    font-size: 12px;
    color: var(--cm-muted);
}

/* --- Main --------------------------------------------- */
.cm-main {
    flex: 1;
    padding: 28px;
}

/* --- Breadcrumb --------------------------------------- */
.cm-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--cm-muted);
    margin-bottom: 20px;
}

.cm-breadcrumb a { color: var(--cm-muted); text-decoration: none; }
.cm-breadcrumb a:hover { color: var(--cm-primary); }
.cm-breadcrumb span { color: var(--cm-text); }

/* --- Cards -------------------------------------------- */
.cm-card {
    background: var(--cm-card);
    border: 1px solid var(--cm-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.cm-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--cm-border);
}

.cm-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--cm-text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.cm-card-title i { color: var(--cm-primary); font-size: 17px; }

.cm-card-body { padding: 22px; }

/* --- Indicadores (stat cards) ------------------------- */
.cm-stat {
    background: var(--cm-card);
    border: 1px solid var(--cm-border);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), transform var(--transition);
}

.cm-stat:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.cm-stat-icon {
    width: 50px; height: 50px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.cm-stat-info { flex: 1; min-width: 0; }

.cm-stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--cm-text);
    line-height: 1.2;
}

.cm-stat-label {
    font-size: 12px;
    color: var(--cm-muted);
    margin-top: 2px;
}

/* Variações de cor dos stat icons */
.si-blue   { background: #dbeafe; color: #1d4ed8; }
.si-green  { background: #dcfce7; color: #15803d; }
.si-orange { background: #ffedd5; color: #c2410c; }
.si-purple { background: #ede9fe; color: #7c3aed; }
.si-teal   { background: #ccfbf1; color: #0f766e; }
.si-red    { background: #fee2e2; color: #dc2626; }
.si-yellow { background: #fef9c3; color: #a16207; }
.si-indigo { background: #e0e7ff; color: #4338ca; }

/* --- Botões ------------------------------------------- */
.cm-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all var(--transition);
    line-height: 1;
    white-space: nowrap;
}

.cm-btn i { font-size: 15px; }

.cm-btn-primary {
    background: var(--cm-primary);
    color: #fff;
}

.cm-btn-primary:hover { background: var(--cm-primary-d); color: #fff; }

.cm-btn-success {
    background: var(--cm-accent);
    color: #fff;
}

.cm-btn-success:hover { background: #15803d; color: #fff; }

.cm-btn-danger {
    background: var(--cm-danger);
    color: #fff;
}

.cm-btn-danger:hover { background: #b91c1c; color: #fff; }

.cm-btn-outline {
    background: transparent;
    border: 1px solid var(--cm-border);
    color: var(--cm-text);
}

.cm-btn-outline:hover { background: var(--cm-bg); color: var(--cm-text); }

.cm-btn-sm { padding: 5px 11px; font-size: 12.5px; }

.cm-btn-icon {
    width: 34px; height: 34px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid var(--cm-border);
    color: var(--cm-muted);
    cursor: pointer;
    transition: all var(--transition);
}

.cm-btn-icon:hover { background: var(--cm-bg); color: var(--cm-text); }
.cm-btn-icon.edit:hover  { background: #dbeafe; color: #1d4ed8; border-color: #bfdbfe; }
.cm-btn-icon.delete:hover { background: #fee2e2; color: var(--cm-danger); border-color: #fecaca; }
.cm-btn-icon.view:hover  { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.cm-btn-icon.pdf:hover   { background: #fef3c7; color: #b45309; border-color: #fde68a; }

/* --- Tabelas ------------------------------------------ */
.cm-table-wrap { overflow-x: auto; border-radius: var(--radius-lg); }

.cm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.cm-table thead th {
    background: #f8fafc;
    color: var(--cm-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 10px 16px;
    text-align: left;
    border-bottom: 2px solid var(--cm-border);
    white-space: nowrap;
}

.cm-table tbody tr {
    border-bottom: 1px solid var(--cm-border);
    transition: background var(--transition);
}

.cm-table tbody tr:last-child { border-bottom: none; }
.cm-table tbody tr:hover { background: #f8fafc; }

.cm-table tbody td { padding: 12px 16px; vertical-align: middle; }

/* --- Formulários -------------------------------------- */
.cm-form-group { margin-bottom: 18px; }

.cm-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--cm-text);
    margin-bottom: 6px;
}

.cm-label.required::after {
    content: ' *';
    color: var(--cm-danger);
}

.cm-input, .cm-select, .cm-textarea {
    width: 100%;
    padding: 9px 13px;
    border: 1.5px solid var(--cm-border);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    color: var(--cm-text);
    background: #fff;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
    font-family: inherit;
}

.cm-input:focus, .cm-select:focus, .cm-textarea:focus {
    border-color: var(--cm-primary);
    box-shadow: 0 0 0 3px rgba(30,58,95,.1);
}

.cm-input.is-invalid, .cm-select.is-invalid { border-color: var(--cm-danger); }

.cm-textarea { resize: vertical; min-height: 90px; }

.cm-input-group {
    display: flex;
    gap: 0;
}

.cm-input-group-text {
    padding: 9px 12px;
    background: #f1f5f9;
    border: 1.5px solid var(--cm-border);
    border-right: none;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    font-size: 13px;
    color: var(--cm-muted);
    display: flex;
    align-items: center;
}

.cm-input-group .cm-input {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* --- Badges ------------------------------------------- */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 11.5px;
    font-weight: 500;
}

.badge-ativo   { background: #dcfce7; color: #15803d; }
.badge-inativo { background: #fee2e2; color: #dc2626; }
.badge-outro   { background: #f1f5f9; color: var(--cm-muted); }

.badge-tipo {
    display: inline-flex;
    padding: 2px 9px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 500;
}

.badge-dizimo  { background: #dbeafe; color: #1e40af; }
.badge-oferta  { background: #dcfce7; color: #15803d; }
.badge-doacao  { background: #ede9fe; color: #6d28d9; }
.badge-missoes { background: #fef9c3; color: #92400e; }
.badge-eventos { background: #ffedd5; color: #c2410c; }
.badge-outros  { background: #f1f5f9; color: var(--cm-muted); }

/* --- Paginação ---------------------------------------- */
.cm-pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 16px 22px;
    border-top: 1px solid var(--cm-border);
    justify-content: center;
}

.cm-pagination a, .cm-pagination span {
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 13px;
    text-decoration: none;
    color: var(--cm-text);
    border: 1px solid var(--cm-border);
    transition: all var(--transition);
}

.cm-pagination a:hover { background: var(--cm-bg); }
.cm-pagination span.active { background: var(--cm-primary); color: #fff; border-color: var(--cm-primary); }

/* --- Filtros / Search bar ----------------------------- */
.cm-filters {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.cm-search-wrap { position: relative; }
.cm-search-wrap i {
    position: absolute;
    left: 11px; top: 50%;
    transform: translateY(-50%);
    color: var(--cm-muted);
    font-size: 15px;
    pointer-events: none;
}

.cm-search-wrap .cm-input { padding-left: 36px; width: 240px; }

/* --- Flash messages ----------------------------------- */
.cm-alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    margin-bottom: 20px;
    border: 1px solid transparent;
}

.cm-alert-success { background: #dcfce7; color: #15803d; border-color: #86efac; }
.cm-alert-danger  { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }
.cm-alert-warning { background: #fef9c3; color: #a16207; border-color: #fde047; }
.cm-alert-info    { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }

/* --- Login -------------------------------------------- */
.cm-login-bg {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--cm-primary) 0%, #1a5276 60%, #16a34a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.cm-login-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 44px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.cm-login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.cm-login-logo .logo-icon {
    width: 60px; height: 60px;
    background: var(--cm-primary);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 28px;
    margin: 0 auto 12px;
}

.cm-login-logo h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--cm-text);
}

.cm-login-logo p {
    font-size: 13px;
    color: var(--cm-muted);
    margin-top: 4px;
}

/* --- Responsivo --------------------------------------- */
@media (max-width: 991px) {
    .cm-sidebar {
        transform: translateX(-100%);
    }

    .cm-sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .cm-content { margin-left: 0; }
    .cm-menu-toggle { display: block; }
    .cm-main { padding: 16px; }
    .cm-topbar { padding: 0 16px; }
}

@media (max-width: 576px) {
    .cm-search-wrap .cm-input { width: 100%; }
    .cm-filters { flex-direction: column; align-items: stretch; }
    .cm-stat-value { font-size: 18px; }
}

/* Overlay para sidebar mobile */
.cm-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 1039;
}

.cm-overlay.show { display: block; }

/* --- Gráficos ----------------------------------------- */
.cm-chart-wrap { position: relative; height: 250px; }

/* --- Aniversariantes ---------------------------------- */
.birthday-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--cm-border);
}

.birthday-item:last-child { border-bottom: none; }

.birthday-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cm-primary), var(--cm-accent));
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}

.birthday-name { font-weight: 500; font-size: 13.5px; }
.birthday-date { font-size: 12px; color: var(--cm-muted); }
.birthday-age  { font-size: 12px; color: var(--cm-accent); font-weight: 600; }

/* --- Valor positivo/negativo no caixa ---------------- */
.valor-positivo { color: var(--cm-success); font-weight: 600; }
.valor-negativo { color: var(--cm-danger);  font-weight: 600; }

/* --- Recibo ------------------------------------------- */
@media print {
    .cm-sidebar, .cm-topbar, .cm-btn, .no-print { display: none !important; }
    .cm-content { margin: 0; }
    body { background: #fff; }
}
