/* Mobile optimization styles for Dan Nkansah Ent */

/* Smooth scrolling & touch momentum */
html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

.overflow-x-auto,
.overflow-touch {
    -webkit-overflow-scrolling: touch;
}

/* Page headers stack on small screens */
@media (max-width: 639px) {
    .page-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 1rem;
    }

    .page-header > a,
    .page-header > .btn-group {
        width: 100%;
        text-align: center;
        justify-content: center;
    }

    .page-header h1 {
        font-size: 1.5rem;
        line-height: 2rem;
    }

    .chart-toolbar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem;
    }

    .chart-toolbar select,
    .chart-toolbar input[type="date"] {
        width: 100%;
    }

    .chart-toolbar .flex.gap-2 {
        flex-wrap: wrap;
    }
}

/* Responsive chart containers */
.chart-container {
    width: 100%;
    max-width: 20rem;
    aspect-ratio: 1;
    margin-left: auto;
    margin-right: auto;
    position: relative;
}

@media (min-width: 640px) {
    .chart-container {
        max-width: 24rem;
    }
}

/* Hide table columns on mobile */
@media (max-width: 767px) {
    .col-hide-mobile {
        display: none !important;
    }

    table.table-responsive td,
    table.table-responsive th {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    table.table-responsive .whitespace-nowrap {
        white-space: normal;
    }
}

/* Mobile card list (alternative to wide tables) */
.mobile-card-list {
    display: none;
}

@media (max-width: 767px) {
    .desktop-table-view {
        display: none;
    }

    .mobile-card-list {
        display: block;
    }

    .mobile-card {
        padding: 1rem;
        border-bottom: 1px solid #e5e7eb;
    }

    .mobile-card:last-child {
        border-bottom: none;
    }

    .mobile-card-row {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 0.5rem;
        margin-bottom: 0.375rem;
        font-size: 0.875rem;
    }

    .mobile-card-row:last-child {
        margin-bottom: 0;
    }

    .mobile-card-label {
        color: #6b7280;
        flex-shrink: 0;
    }

    .mobile-card-value {
        text-align: right;
        font-weight: 500;
        color: #111827;
    }

    .mobile-card-actions {
        display: flex;
        gap: 1rem;
        margin-top: 0.75rem;
        padding-top: 0.75rem;
        border-top: 1px solid #f3f4f6;
    }

    .mobile-card-actions a {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* Nav dropdown (click/tap friendly) */
.nav-dropdown-menu {
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 9999 !important;
    box-shadow: 0 10px 40px rgba(15, 23, 42, 0.12);
}

.nav-dropdown-menu.is-open {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

.nav-dropdown {
    position: relative;
    z-index: 9991;
}

/* Mobile nav accordion */
.mobile-nav-section-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 1rem;
    font-weight: 500;
    color: #374151;
    background: transparent;
    border: none;
    cursor: pointer;
    min-height: 44px;
}

.mobile-nav-section-btn:hover {
    background-color: #eff6ff;
    color: #2563eb;
}

.mobile-nav-section-btn .chevron {
    transition: transform 0.2s;
}

.mobile-nav-section-btn[aria-expanded="true"] .chevron {
    transform: rotate(180deg);
}

.mobile-nav-submenu {
    display: none;
    padding-left: 0.5rem;
}

.mobile-nav-submenu.is-open {
    display: block;
}

.mobile-nav-link {
    display: block;
    padding: 0.625rem 0.75rem 0.625rem 1.75rem;
    border-radius: 0.375rem;
    font-size: 0.9375rem;
    color: #374151;
    min-height: 44px;
    line-height: 1.75rem;
}

.mobile-nav-link:hover {
    background-color: #eff6ff;
    color: #2563eb;
}

/* Notifications dropdown on mobile */
@media (max-width: 639px) {
    #notifications-dropdown {
        width: calc(100vw - 2rem) !important;
        max-width: 20rem;
        right: -0.5rem;
    }
}

/* Form filter buttons full width on mobile */
@media (max-width: 639px) {
    .filter-actions {
        flex-direction: column;
        width: 100%;
    }

    .filter-actions button,
    .filter-actions a {
        width: 100%;
        justify-content: center;
        min-height: 44px;
    }
}

/* Touch-friendly minimum tap targets */
@media (max-width: 767px) {
    nav a,
    nav button {
        min-height: 44px;
    }

    .pagination-mobile a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
}

@media (max-width: 639px) {
    .card-compact-mobile {
        padding: 1rem !important;
    }

    .transaction-row {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.5rem;
    }

    .transaction-row > div:last-child {
        align-self: flex-end;
    }
}
