/**
 * Elementor Finance Widgets — MN PB Management
 * Simple Report + Full Report
 */

/* ============================================================
   SHARED BASE
   ============================================================ */

.mnpbman-simple-report,
.mnpbman-full-report {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: #333;
}

/* ============================================================
   SIMPLE REPORT — Header
   ============================================================ */

.mnpbman-sr-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.sr-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sr-header-left .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

.sr-title {
    font-size: 16px;
    font-weight: 600;
}

.sr-period-badge {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

/* ============================================================
   SIMPLE REPORT — Summary Cards
   ============================================================ */

.mnpbman-sr-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    border-bottom: 1px solid #f0f0f0;
}

.mnpbman-sr-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-left: 3px solid transparent;
    border-right: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.mnpbman-sr-card:last-child {
    border-right: none;
}

.mnpbman-sr-card.income  { border-left-color: #28a745; }
.mnpbman-sr-card.expense { border-left-color: #dc3545; }
.mnpbman-sr-card.balance.positive { border-left-color: #17a2b8; }
.mnpbman-sr-card.balance.negative { border-left-color: #fd7e14; }
.mnpbman-sr-card.total-saldo.positive { border-left-color: #6f42c1; }
.mnpbman-sr-card.total-saldo.negative { border-left-color: #e83e8c; }

.mnpbman-sr-card .card-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f4f4f4;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mnpbman-sr-card.income  .card-icon { background: #e8f5e9; color: #28a745; }
.mnpbman-sr-card.expense .card-icon { background: #fdecea; color: #dc3545; }
.mnpbman-sr-card.balance.positive .card-icon { background: #e0f7fa; color: #17a2b8; }
.mnpbman-sr-card.balance.negative .card-icon { background: #fff3e0; color: #fd7e14; }
.mnpbman-sr-card.total-saldo.positive .card-icon { background: #f3e8ff; color: #6f42c1; }
.mnpbman-sr-card.total-saldo.negative .card-icon { background: #fde8f0; color: #e83e8c; }

.mnpbman-sr-card .card-icon .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.card-body {
    min-width: 0;
}

.card-label {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.card-value {
    font-size: 13px;
    font-weight: 700;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================================
   SIMPLE REPORT — Section Lists
   ============================================================ */

.mnpbman-sr-section {
    padding: 0 20px 4px;
    border-bottom: 1px solid #f5f5f5;
}

.mnpbman-sr-section:last-of-type {
    border-bottom: none;
}

.mnpbman-sr-section-title {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 0 8px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mnpbman-sr-section-title.income-title  { color: #28a745; }
.mnpbman-sr-section-title.expense-title { color: #dc3545; }

.mnpbman-sr-section-title .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

.more-badge {
    margin-left: auto;
    background: #f0f0f0;
    color: #666;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 500;
}

.mnpbman-sr-list {
    list-style: none;
    margin: 0;
    padding: 0 0 8px;
}

.mnpbman-sr-list .list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px dashed #f0f0f0;
    gap: 10px;
}

.mnpbman-sr-list .list-item:last-child {
    border-bottom: none;
}

.item-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.item-date {
    font-size: 11px;
    color: #aaa;
    white-space: nowrap;
    flex-shrink: 0;
    background: #f5f5f5;
    border-radius: 4px;
    padding: 2px 6px;
}

.item-desc {
    font-size: 13px;
    color: #555;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-amount {
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}

.item-amount.income  { color: #28a745; }
.item-amount.expense { color: #dc3545; }

.mnpbman-sr-no-data {
    color: #aaa;
    font-size: 12px;
    padding: 8px 0;
    margin: 0;
}

/* ============================================================
   SIMPLE REPORT — Empty state & Footer
   ============================================================ */

.mnpbman-sr-empty {
    text-align: center;
    padding: 30px 20px;
    color: #bbb;
}

.mnpbman-sr-empty .dashicons {
    font-size: 36px;
    width: 36px;
    height: 36px;
    display: block;
    margin: 0 auto 8px;
}

.mnpbman-sr-empty p {
    margin: 0;
    font-size: 13px;
}

.mnpbman-sr-footer {
    padding: 14px 20px;
    background: #f8f9fa;
    border-top: 1px solid #f0f0f0;
    text-align: center;
}

.mnpbman-btn-full-report {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 20px;
    background: #667eea;
    color: #fff !important;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none !important;
    transition: background 0.2s, transform 0.1s;
}

.mnpbman-btn-full-report:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

.mnpbman-btn-full-report .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* ============================================================
   FULL REPORT — Header
   ============================================================ */

.mnpbman-fr-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.fr-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fr-header-left .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

.fr-title {
    font-size: 16px;
    font-weight: 600;
}

.mnpbman-btn-export {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.mnpbman-btn-export:hover {
    background: rgba(255, 255, 255, 0.35);
}

.mnpbman-btn-export .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* ============================================================
   FULL REPORT — Filter Panel
   ============================================================ */

.mnpbman-fr-filters {
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    padding: 14px 20px;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 120px;
}

.filter-group label {
    font-size: 11px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.filter-select,
.filter-input {
    padding: 7px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    color: #333;
    background: #fff;
    transition: border-color 0.2s;
    line-height: 1.4;
}

.filter-select:focus,
.filter-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
}

.mnpbman-btn-filter {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 16px;
    background: #667eea;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.mnpbman-btn-filter:hover {
    background: #5a67d8;
}

.mnpbman-btn-filter .dashicons {
    font-size: 15px;
    width: 15px;
    height: 15px;
}

/* ============================================================
   FULL REPORT — Summary Cards
   ============================================================ */

.mnpbman-fr-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border-bottom: 1px solid #f0f0f0;
}

.summary-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-left: 3px solid transparent;
    border-right: 1px solid #f0f0f0;
}

.summary-card:last-child { border-right: none; }

.summary-card.income   { border-left-color: #28a745; }
.summary-card.expense  { border-left-color: #dc3545; }
.summary-card.balance.positive { border-left-color: #17a2b8; }
.summary-card.balance.negative { border-left-color: #fd7e14; }
.summary-card.count    { border-left-color: #6c757d; }

.summary-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.summary-card.income   .summary-icon { background: #e8f5e9; color: #28a745; }
.summary-card.expense  .summary-icon { background: #fdecea; color: #dc3545; }
.summary-card.balance.positive .summary-icon { background: #e0f7fa; color: #17a2b8; }
.summary-card.balance.negative .summary-icon { background: #fff3e0; color: #fd7e14; }
.summary-card.count    .summary-icon { background: #f0f0f0; color: #6c757d; }

.summary-icon .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

.summary-body {
    min-width: 0;
}

.summary-label {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 2px;
}

.summary-value {
    font-size: 13px;
    font-weight: 700;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.summary-value.income-val  { color: #28a745; }
.summary-value.expense-val { color: #dc3545; }
.summary-value.balance-val { color: inherit; }

/* ============================================================
   FULL REPORT — Table
   ============================================================ */

.mnpbman-fr-content {
    position: relative;
    transition: opacity 0.2s;
}

.mnpbman-fr-content.loading {
    opacity: 0.5;
    pointer-events: none;
}

.mnpbman-fr-content.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.6) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 38 38' stroke='%23667eea'%3E%3Cg fill='none' stroke-width='2'%3E%3Ccircle stroke-opacity='.25' cx='19' cy='19' r='17'/%3E%3Cpath d='M36 19c0-9.4-7.6-17-17-17'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 19 19' to='360 19 19' dur='0.8s' repeatCount='indefinite'/%3E%3C/path%3E%3C/g%3E%3C/svg%3E") center 60px no-repeat;
    background-size: 36px;
    border-radius: 0 0 10px 10px;
}

.mnpbman-fr-table-wrap {
    overflow-x: auto;
    padding: 0;
}

.mnpbman-fr-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.mnpbman-fr-table thead th {
    background: #f8f9fa;
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 2px solid #e9ecef;
    white-space: nowrap;
    user-select: none;
}

.mnpbman-fr-table thead th.sortable {
    cursor: pointer;
}

.mnpbman-fr-table thead th.sortable:hover {
    background: #eef0f7;
    color: #667eea;
}

.mnpbman-fr-table thead th.sortable .sort-icon::after {
    content: '⇅';
    margin-left: 4px;
    opacity: 0.4;
    font-size: 10px;
}

.mnpbman-fr-table thead th.sortable.active.asc  .sort-icon::after { content: '↑'; opacity: 1; color: #667eea; }
.mnpbman-fr-table thead th.sortable.active.desc .sort-icon::after { content: '↓'; opacity: 1; color: #667eea; }

.mnpbman-fr-table tbody tr {
    border-bottom: 1px solid #f5f5f5;
    transition: background 0.15s;
}

.mnpbman-fr-table tbody tr:hover {
    background: #f0f4ff !important;
}

.mnpbman-fr-table tbody tr:nth-child(odd) {
    background: #f8f9fa;
}

.mnpbman-fr-table tbody td {
    padding: 10px 14px;
    vertical-align: middle;
    color: #444;
}

.mnpbman-fr-table .col-amount {
    font-weight: 700;
    white-space: nowrap;
    text-align: right;
}

.mnpbman-fr-table .col-desc {
    max-width: 240px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.amount-income  { color: #28a745; }
.amount-expense { color: #dc3545; }

/* Type badge */
.type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.type-badge.type-income  { background: #e8f5e9; color: #28a745; }
.type-badge.type-expense { background: #fdecea; color: #dc3545; }

/* ============================================================
   FULL REPORT — Pagination
   ============================================================ */

.mnpbman-fr-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-top: 1px solid #f0f0f0;
    background: #fafafa;
    flex-wrap: wrap;
    gap: 8px;
}

.pagination-info {
    font-size: 12px;
    color: #888;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    color: #555;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1;
}

.page-btn:hover {
    border-color: #667eea;
    color: #667eea;
    background: #f0f4ff;
}

.page-btn.active {
    background: #667eea;
    border-color: #667eea;
    color: #fff;
    font-weight: 700;
}

.page-btn .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

.page-ellipsis {
    padding: 0 4px;
    color: #aaa;
}

/* ============================================================
   FULL REPORT — Empty state
   ============================================================ */

.mnpbman-fr-empty {
    text-align: center;
    padding: 40px 20px;
    color: #bbb;
}

.mnpbman-fr-empty .dashicons {
    font-size: 40px;
    width: 40px;
    height: 40px;
    display: block;
    margin: 0 auto 10px;
}

.mnpbman-fr-empty p {
    margin: 0;
    font-size: 14px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
    .mnpbman-sr-cards {
        grid-template-columns: 1fr 1fr;
    }

    .mnpbman-sr-card:nth-child(even) {
        border-right: none;
    }

    .mnpbman-sr-card:nth-child(3),
    .mnpbman-sr-card:nth-child(4) {
        border-top: 1px solid #f0f0f0;
    }

    .mnpbman-fr-summary {
        grid-template-columns: 1fr 1fr;
    }

    .summary-card:nth-child(even) {
        border-right: none;
    }

    .summary-card:nth-child(3),
    .summary-card:nth-child(4) {
        border-top: 1px solid #f0f0f0;
    }

    .filter-group {
        min-width: 0;
        flex: 1 1 calc(50% - 5px);
    }

    .filter-group.filter-action {
        flex: 0 0 auto;
    }

    .mnpbman-fr-table .col-desc { max-width: 140px; }

    .mnpbman-fr-pagination {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .mnpbman-sr-cards {
        grid-template-columns: 1fr 1fr;
    }

    .mnpbman-sr-card:nth-child(odd)  { border-right: 1px solid #f0f0f0; }
    .mnpbman-sr-card:nth-child(even) { border-right: none; }

    .mnpbman-sr-card:nth-child(3),
    .mnpbman-sr-card:nth-child(4) {
        border-top: 1px solid #f0f0f0;
    }

    .mnpbman-fr-summary {
        grid-template-columns: 1fr 1fr;
    }

    .filter-group {
        flex: 1 1 100%;
    }
}

/* ============================================================
   BALANCE WIDGET (Total Kas All Time)
   ============================================================ */

.mnpbman-balance-widget {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: #333;
}

/* Header */
.mnpbman-bal-header {
    background: #6f42c1;
    color: #fff;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.mnpbman-bal-header-icon {
    font-size: 20px;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.mnpbman-bal-header-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
}

/* Body */
.mnpbman-bal-body {
    padding: 20px;
}

/* Minimal layout title */
.mnpbman-bal-minimal-title {
    font-size: 13px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

/* Main value block */
.mnpbman-bal-main {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.mnpbman-bal-main-icon {
    font-size: 36px;
    width: 36px;
    height: 36px;
    color: #6f42c1;
    flex-shrink: 0;
}

.mnpbman-bal-main-inner {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mnpbman-bal-value {
    font-size: 32px;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.5px;
}

.mnpbman-bal-value.positive { color: #6f42c1; }
.mnpbman-bal-value.negative { color: #dc3545; }

.mnpbman-bal-sublabel {
    font-size: 12px;
    color: #888;
    font-weight: 400;
}

/* Breakdown rows */
.mnpbman-bal-breakdown {
    border-top: 1px solid #f0f0f0;
    padding-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mnpbman-bal-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mnpbman-bal-row-icon {
    font-size: 14px;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.mnpbman-bal-row-label {
    flex: 1;
    font-size: 13px;
    color: #555;
}

.mnpbman-bal-row-value {
    font-size: 13px;
    font-weight: 600;
}

.mnpbman-bal-row.income .mnpbman-bal-row-icon,
.mnpbman-bal-row.income .mnpbman-bal-row-value { color: #28a745; }

.mnpbman-bal-row.expense .mnpbman-bal-row-icon,
.mnpbman-bal-row.expense .mnpbman-bal-row-value { color: #dc3545; }

/* Banner layout */
.mnpbman-balance-widget.layout-banner .mnpbman-bal-header {
    padding: 20px 24px;
}

.mnpbman-balance-widget.layout-banner .mnpbman-bal-header-title {
    font-size: 17px;
}

.mnpbman-balance-widget.layout-banner .mnpbman-bal-body {
    padding: 24px;
}

.mnpbman-balance-widget.layout-banner .mnpbman-bal-value {
    font-size: 40px;
}

/* Minimal layout — no card chrome */
.mnpbman-balance-widget.layout-minimal {
    box-shadow: none;
    background: transparent;
    border-radius: 0;
}

.mnpbman-balance-widget.layout-minimal .mnpbman-bal-body {
    padding: 0;
}

.mnpbman-balance-widget.layout-minimal .mnpbman-bal-main {
    margin-bottom: 12px;
}

/* Responsive */
@media (max-width: 480px) {
    .mnpbman-bal-value { font-size: 24px; }
    .mnpbman-balance-widget.layout-banner .mnpbman-bal-value { font-size: 28px; }
}
