/* ==========================================================================
   Associação Mueller — sistema de design
   ========================================================================== */

:root {
    --mu-primary: #0f7a53;
    --mu-primary-dark: #0a5c3e;
    --mu-primary-darker: #073f2b;
    --mu-primary-light: #e6f4ee;
    --mu-primary-text: #0a5c3e;

    --mu-green: #16a34a;
    --mu-green-bg: #eafaf0;
    --mu-red: #e11d48;
    --mu-red-bg: #fdecee;
    --mu-amber: #d97706;
    --mu-amber-bg: #fef3e2;
    --mu-slate: #64748b;
    --mu-slate-bg: #f1f3f5;

    --mu-ink: #1c2b26;
    --mu-muted: #64748b;
    --mu-border: #e7ebe9;
    --mu-bg: #f4f6f5;
    --mu-surface: #ffffff;

    --mu-radius-lg: 1.15rem;
    --mu-radius: 0.85rem;
    --mu-radius-sm: 0.6rem;
    --mu-shadow: 0 1px 2px rgba(16, 24, 20, .04), 0 6px 16px -4px rgba(16, 24, 20, .07);
    --mu-shadow-sm: 0 1px 2px rgba(16, 24, 20, .05);
}

* { -webkit-tap-highlight-color: transparent; }

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    background-color: var(--mu-bg);
    color: var(--mu-ink);
    padding-bottom: env(safe-area-inset-bottom);
    -webkit-font-smoothing: antialiased;
}

body.has-bottom-nav {
    padding-bottom: calc(68px + env(safe-area-inset-bottom));
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--mu-ink);
}

a { color: var(--mu-primary-text); text-decoration: none; }
a:hover { color: var(--mu-primary-darker); }

.text-muted { color: var(--mu-muted) !important; }

/* ---------- Top bar ---------- */
.app-topbar {
    background: linear-gradient(135deg, var(--mu-primary) 0%, var(--mu-primary-dark) 100%);
    padding-top: .65rem;
    padding-bottom: .65rem;
    box-shadow: 0 2px 10px rgba(7, 63, 43, .18);
}
.app-topbar .navbar-brand {
    color: #fff;
    font-size: 1.05rem;
    font-weight: 700;
}
.app-topbar .navbar-brand i {
    color: #fff;
}
.app-topbar .nav-link {
    color: rgba(255,255,255,.82);
    font-weight: 500;
    font-size: .92rem;
    padding: .4rem .7rem;
    border-radius: .5rem;
    transition: background .15s ease, color .15s ease;
}
.app-topbar .nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,.10);
}
.app-topbar .nav-link.active {
    color: #fff;
    background: rgba(255,255,255,.18);
    font-weight: 600;
}

/* ---------- Bottom tab bar (mobile) ---------- */
.bottom-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 1030;
    display: flex;
    background: var(--mu-surface);
    border-top: 1px solid var(--mu-border);
    box-shadow: 0 -4px 16px rgba(16, 24, 20, .06);
    padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .2rem;
    padding: .5rem 0 .4rem;
    color: #9aa5a0;
    text-decoration: none;
    font-size: .66rem;
    font-weight: 600;
    border: none;
    background: none;
}
.bottom-nav-item i {
    font-size: 1.3rem;
}
.bottom-nav-item.active {
    color: var(--mu-primary);
}
.bottom-nav-dot {
    position: absolute;
    top: .35rem;
    right: calc(50% - .85rem);
    width: .5rem;
    height: .5rem;
    border-radius: 50%;
    background: var(--mu-amber);
    border: 1.5px solid #fff;
}

/* ---------- Offcanvas menu ---------- */
.offcanvas-header { border-bottom: 1px solid var(--mu-border); }
.menu-link {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .85rem .25rem;
    color: var(--mu-ink);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid #f2f3f2;
}
.menu-link:hover { color: var(--mu-primary-text); }
.menu-link i {
    font-size: 1.15rem;
    color: var(--mu-primary);
    width: 1.4rem;
    text-align: center;
}

/* ---------- Cards ---------- */
.card-stat {
    border: none;
    border-radius: var(--mu-radius-lg);
    box-shadow: var(--mu-shadow);
    background: var(--mu-surface);
}
.card-stat .card-body {
    padding: 1.15rem 1.25rem;
}
.card-stat.icon-stat {
    position: relative;
    overflow: hidden;
}
.card-stat .stat-icon {
    position: absolute;
    right: .7rem;
    top: .7rem;
    font-size: 1.5rem;
    opacity: .13;
}
.card-stat .stat-label {
    color: var(--mu-muted);
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
    margin-bottom: .2rem;
}
.card-stat .stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.15;
}
.card-stat .stat-help {
    font-size: .78rem;
    color: var(--mu-muted);
    margin-top: .15rem;
}

.section-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: .9rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.section-title i { color: var(--mu-primary); }

/* ---------- Hero saldo card (dashboard) ---------- */
.saldo-hero {
    border-radius: var(--mu-radius-lg);
    background: linear-gradient(135deg, var(--mu-primary) 0%, var(--mu-primary-dark) 100%);
    color: #fff;
    padding: 1.5rem 1.5rem;
    box-shadow: 0 8px 24px -6px rgba(10, 92, 62, .35);
    position: relative;
    overflow: hidden;
}
.saldo-hero.negativo {
    background: linear-gradient(135deg, #b91c3c 0%, #7f1d2e 100%);
    box-shadow: 0 8px 24px -6px rgba(127, 29, 46, .35);
}
.saldo-hero .saldo-label {
    color: rgba(255,255,255,.8);
    font-size: .85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.saldo-hero .saldo-valor {
    font-size: 2.4rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: .1rem 0 .3rem;
}
.saldo-hero .saldo-icon {
    position: absolute;
    right: -.5rem;
    bottom: -1rem;
    font-size: 6.5rem;
    opacity: .12;
}

/* ---------- Quick actions (admin) ---------- */
.quick-actions {
    display: flex;
    gap: .6rem;
    flex-wrap: wrap;
}
.quick-actions .btn {
    border-radius: var(--mu-radius-sm);
    font-weight: 600;
    font-size: .88rem;
}

/* ---------- Buttons ---------- */
.btn {
    border-radius: var(--mu-radius-sm);
    font-weight: 600;
    letter-spacing: -0.005em;
}
.btn-success {
    background: var(--mu-primary);
    border-color: var(--mu-primary);
}
.btn-success:hover, .btn-success:focus {
    background: var(--mu-primary-dark);
    border-color: var(--mu-primary-dark);
}
.btn-outline-success {
    color: var(--mu-primary-text);
    border-color: var(--mu-primary);
}
.btn-outline-success:hover {
    background: var(--mu-primary);
    border-color: var(--mu-primary);
}

/* ---------- Badges (soft/pill style) ---------- */
.badge {
    font-weight: 600;
    font-size: .74rem;
    padding: .4em .7em;
    border-radius: 50rem;
    letter-spacing: 0;
}
.badge.text-bg-success { background-color: var(--mu-green-bg) !important; color: var(--mu-green) !important; }
.badge.text-bg-danger  { background-color: var(--mu-red-bg) !important; color: var(--mu-red) !important; }
.badge.text-bg-warning { background-color: var(--mu-amber-bg) !important; color: var(--mu-amber) !important; }
.badge.text-bg-secondary { background-color: var(--mu-slate-bg) !important; color: var(--mu-slate) !important; }

/* ---------- Tables ---------- */
table.table td, table.table th {
    vertical-align: middle;
    padding-top: .7rem;
    padding-bottom: .7rem;
}
table.table th {
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--mu-muted);
    font-weight: 700;
    border-bottom: 2px solid var(--mu-border);
}
.card-stat .table {
    margin-bottom: 0;
}
.card-stat table.table > tbody > tr {
    border-bottom: 1px solid #dde3e0;
}
.card-stat table.table > tbody > tr:last-child {
    border-bottom: none;
}
.card-stat table.table > tbody > tr:nth-child(even) {
    background-color: #f8faf9;
}
.card-stat table.table-hover > tbody > tr:hover {
    background-color: var(--mu-primary-light);
}

/* Convert tables into stacked cards on small screens */
@media (max-width: 767.98px) {
    .table-cards thead {
        display: none;
    }
    .table-cards, .table-cards tbody, .table-cards tr, .table-cards td {
        display: block;
        width: 100%;
    }
    .table-cards {
        background: transparent;
    }
    .table-cards tr {
        background: var(--mu-surface);
        border-radius: var(--mu-radius);
        box-shadow: var(--mu-shadow-sm);
        margin-bottom: .6rem;
        padding: .6rem .85rem;
    }
    .table-cards tr:last-child {
        margin-bottom: 0;
    }
    .table-cards tr.table-warning {
        background: var(--mu-amber-bg);
    }
    .table-cards td {
        border: none !important;
        padding: .3rem 0 !important;
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
    }
    .table-cards td[data-label]::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--mu-muted);
        font-size: .72rem;
        text-align: left;
        margin-right: .5rem;
        white-space: nowrap;
    }
    .table-cards td:empty {
        display: none;
    }
    .table-cards td:not([data-label]) {
        justify-content: flex-end;
        border-top: 1px dashed #eee !important;
        padding-top: .5rem !important;
        margin-top: .2rem;
    }
    .card-stat .table-responsive {
        margin: -1.15rem;
        padding: 1.15rem;
        width: auto;
    }
}

/* ---------- Forms ---------- */
.form-label {
    font-weight: 600;
    font-size: .85rem;
    color: var(--mu-ink);
}
.form-control, .form-select {
    border-radius: var(--mu-radius-sm);
    border-color: var(--mu-border);
}
.form-control:focus, .form-select:focus {
    border-color: var(--mu-primary);
    box-shadow: 0 0 0 .2rem var(--mu-primary-light);
}

/* ---------- Nav pills (filters, login tabs) ---------- */
.nav-pills .nav-link {
    color: var(--mu-muted);
    font-weight: 600;
    border-radius: var(--mu-radius-sm);
}
.nav-pills .nav-link.active {
    background-color: var(--mu-primary);
    color: #fff;
}

/* ---------- Alerts ---------- */
.alert {
    border-radius: var(--mu-radius);
    border: none;
}

/* ---------- Empty states ---------- */
.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--mu-muted);
}
.empty-state i {
    font-size: 2.2rem;
    color: #cbd3d0;
    margin-bottom: .6rem;
    display: block;
}

/* ---------- Buttons & forms: bigger touch targets on mobile ---------- */
@media (max-width: 767.98px) {
    .btn {
        min-height: 42px;
    }
    .form-control, .form-select {
        min-height: 44px;
    }
    h1.h4 {
        font-size: 1.25rem;
    }
    .saldo-hero .saldo-valor {
        font-size: 2rem;
    }
}
