/* Custom pagination styles to prevent overflow */
.pagination-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.pagination-wrapper .pagination {
    margin-bottom: 0;
    white-space: nowrap;
    flex-wrap: nowrap;
}

.pagination-wrapper .page-link {
    min-width: 40px;
    text-align: center;
    font-size: 0.875rem;
}

/* Responsive pagination */
@media (max-width: 576px) {
    .pagination-wrapper .page-item:not(.active):not(:first-child):not(:last-child):not(.disabled) {
        display: none;
    }
    
    .pagination-wrapper .page-item.active ~ .page-item:nth-child(n+3):not(:last-child) {
        display: none;
    }
    
    .pagination-wrapper .page-item:first-child ~ .page-item:nth-child(-n+3):not(.active) {
        display: inline-block;
    }
}

/* Page headers — stack on mobile, row on md+ */
.page-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.page-header-back {
    order: 1;
    align-self: flex-start;
}

.page-header-title {
    order: 2;
    margin: 0;
    text-align: center;
    color: #33aa93;
    font-size: 1.25rem;
    line-height: 1.3;
}

.page-header-actions {
    order: 3;
}

.page-header-actions > .btn,
.page-header-actions > .dropdown,
.page-header-actions > .dropdown > .btn {
    width: 100%;
}

.page-header-actions .dropdown-menu {
    width: 100%;
}

@media (min-width: 768px) {
    .page-header {
        display: grid;
        grid-template-columns: auto 1fr auto;
        align-items: center;
        gap: 1rem;
    }

    .page-header-back,
    .page-header-title,
    .page-header-actions {
        order: unset;
    }

    .page-header-title {
        font-size: 1.5rem;
    }

    .page-header-actions > .btn,
    .page-header-actions > .dropdown,
    .page-header-actions > .dropdown > .btn {
        width: auto;
    }

    .page-header-actions .dropdown-menu {
        width: auto;
    }

    /* Back + title only: keep title centered */
    .page-header--simple {
        grid-template-columns: 1fr auto 1fr;
    }

    .page-header--simple .page-header-back {
        justify-self: start;
    }

    .page-header--simple .page-header-title {
        grid-column: 2;
    }
}

/* Wallet specific styles */
.wallet-table-container {
    min-height: 400px;
}

.wallet-card {
    transition: all 0.2s ease-in-out;
}

.wallet-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1) !important;
}

.transaction-type-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

.amount-positive {
    color: #198754 !important;
}

.amount-negative {
    color: #dc3545 !important;
}

.quick-actions {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 10px;
    padding: 1rem;
}

.dashboard-header {
    background: linear-gradient(135deg, #33aa93 0%, #2c8a7a 100%);
    color: white;
    border-radius: 10px;
    padding: 2rem 1rem;
    margin-bottom: 2rem;
}

/* Table improvements */
.table-hover tbody tr:hover {
    background-color: rgba(51, 170, 147, 0.05);
}

/* Form improvements */
.form-control:focus, .form-select:focus {
    border-color: #33aa93;
    box-shadow: 0 0 0 0.2rem rgba(51, 170, 147, 0.25);
}

/* Button improvements */
.btn-success {
    background-color: #33aa93;
    border-color: #33aa93;
}

.btn-success:hover {
    background-color: #2c8a7a;
    border-color: #2c8a7a;
}

.btn-outline-success {
    color: #33aa93;
    border-color: #33aa93;
}

.btn-outline-success:hover {
    background-color: #33aa93;
    border-color: #33aa93;
    color: white;
}

/* Clickable filter elements */
.clickable-filter {
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    position: relative;
}

.clickable-filter:hover {
    transform: scale(1.05);
    filter: brightness(1.1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.clickable-filter:after {
    content: "🔍";
    position: absolute;
    top: -8px;
    right: -8px;
    font-size: 0.6rem;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.clickable-filter:hover:after {
    opacity: 1;
}

/* Filter section improvements */
.filter-section {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
}

.active-filters .badge {
    border: 1px solid #dee2e6;
}

/* Sticky first column for horizontally scrollable summary tables */
.table-responsive:has(.table-sticky-first) {
    -webkit-overflow-scrolling: touch;
}

.table-sticky-first {
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 0;
}

.table-sticky-first > :not(caption) > * > * {
    border-width: 1px;
}

.table-sticky-first th:first-child,
.table-sticky-first td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background-color: #fff;
    min-width: 4.5rem;
    box-shadow: 4px 0 6px -4px rgba(0, 0, 0, 0.12);
}

.table-sticky-first thead th:first-child {
    z-index: 3;
    background-color: #f8f9fa;
}

.table-sticky-first tbody tr.bg-light td:first-child,
.table-sticky-first tbody tr.fw-bold.bg-light td:first-child {
    background-color: #f8f9fa;
}

.table-sticky-first tbody tr:hover td:first-child {
    background-color: #f8f9fa;
}

/* Safe areas (iPhone notch / home indicator) */
body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

.navbar {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
}

footer {
    position: relative;
    width: 100%;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

/* Larger touch targets + tighter vertical spacing on phones */
@media (max-width: 767.98px) {
    main.py-4 {
        padding-top: 0.75rem !important;
        padding-bottom: max(1.25rem, env(safe-area-inset-bottom)) !important;
    }

    .container.py-4,
    .container-fluid.py-4 {
        padding-top: 0.5rem !important;
        padding-bottom: 0.75rem !important;
    }

    .navbar.mb-4 {
        margin-bottom: 0.75rem !important;
        padding-top: max(0.35rem, env(safe-area-inset-top));
    }

    .navbar-toggler {
        min-width: 44px;
        min-height: 44px;
        padding: 0.5rem 0.65rem;
    }

    .navbar .nav-link,
    .navbar .btn.nav-link {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        padding-top: 0.65rem;
        padding-bottom: 0.65rem;
    }

    .btn {
        min-height: 44px;
        padding-top: 0.55rem;
        padding-bottom: 0.55rem;
    }

    .btn-sm {
        min-height: 40px;
        min-width: 40px;
        height: auto !important;
        padding: 0.45rem 0.7rem;
    }

    .btn-group-sm > .btn {
        min-height: 40px;
        min-width: 40px;
        padding: 0.45rem 0.65rem;
    }

    .form-control,
    .form-select {
        min-height: 44px;
        font-size: 16px; /* avoid iOS zoom on focus */
    }

    .form-control-sm,
    .form-select-sm {
        min-height: 44px;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
        font-size: 16px;
    }

    .form-select-rounded {
        height: auto !important;
        line-height: 1.5 !important;
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }

    .pagination-wrapper .page-link {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 1rem;
    }

    .clickable-filter,
    a.badge {
        display: inline-flex;
        align-items: center;
        min-height: 32px;
        padding: 0.35rem 0.65rem;
    }

    .clickable-filter:hover,
    .clickable-filter:hover:after {
        transform: none;
        filter: none;
        box-shadow: none;
        opacity: 0;
    }

    .table a.text-decoration-underline {
        display: inline-block;
        padding: 0.4rem 0.35rem;
        min-height: 36px;
        line-height: 1.35;
    }

    .page-header {
        gap: 0.85rem;
        margin-bottom: 1.25rem;
    }

    .dropdown-item {
        min-height: 44px;
        display: flex;
        align-items: center;
        padding-top: 0.65rem;
        padding-bottom: 0.65rem;
    }
}


