/* ============================================================
   ABJIKDATA - Comprehensive Responsive CSS
   Covers: phones (320-576px), tablets (577-768px), desktops (769px+)
   ============================================================ */

/* ---- GLOBAL RESPONSIVE RESETS ---- */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    overflow-x: hidden;
}

body {
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Prevent ANY element from causing horizontal scroll */
img:not(.svc-card-logo), video, iframe, table, canvas, svg {
    max-width: 100%;
}

img:not([height]) {
    height: auto;
}

/* ---- BOTTOM NAV FAB BUTTON (replaces inline styles) ---- */
.bottom-nav-menu {
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0;
    justify-content: space-between;
    align-items: flex-end;
    padding-bottom: 10px;
}

.bottom-nav-item {
    flex: 1;
    text-align: center;
}

.bottom-nav-link span {
    font-size: 0.75rem;
    display: block;
}

.bottom-nav-item.fab-container {
    display: flex;
    justify-content: center;
    position: relative;
}

.fab-wrapper {
    position: absolute;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
}

.fab-button {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color, #4e73df), #224abe);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 4px solid #fff;
    box-shadow: 0 5px 15px rgba(78, 115, 223, 0.4);
    text-decoration: none;
    transition: transform 0.2s;
}

.fab-button:hover,
.fab-button:active {
    color: white;
    transform: scale(0.95);
}

.fab-spacer {
    height: 40px;
}

/* ---- TOUCH-FRIENDLY INPUTS (all devices) ---- */
input, select, textarea, button, .btn {
    font-size: 16px !important; /* Prevents iOS zoom on focus */
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
select.form-select,
textarea.form-control {
    min-height: 44px; /* Apple HIG minimum touch target */
}

/* ---- RESPONSIVE TABLES ---- */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100% !important;
    table-layout: auto;
}

/* ==================================================================
   EXTRA SMALL DEVICES (phones < 375px — iPhone SE, very small phones)
   ================================================================== */
@media (max-width: 374px) {
    html {
        font-size: 13px;
    }

    .navbar-brand {
        font-size: 1.1rem !important;
    }

    .navbar-brand img {
        width: 28px !important;
        height: 28px !important;
    }

    .container-fluid {
        padding-left: 6px !important;
        padding-right: 6px !important;
    }

    .card {
        border-radius: 12px !important;
        margin-bottom: 0.75rem !important;
    }

    .card-body {
        padding: 0.75rem !important;
    }

    /* Balance card */
    .balance-card {
        border-radius: 16px !important;
        padding: 6px !important;
    }

    .balance-card .card-body {
        padding: 1rem !important;
    }

    .balance-card h2,
    .balance-card .h2 {
        font-size: 1.5rem !important;
    }

    /* Quick actions */
    .quick-action-icon {
        width: 38px !important;
        height: 38px !important;
        font-size: 1.1rem !important;
        border-radius: 10px !important;
        margin-bottom: 6px !important;
    }

    .quick-action-item {
        padding: 10px !important;
        border-radius: 14px !important;
    }

    .quick-action-item .small {
        font-size: 0.7rem !important;
    }

    /* Network cards */
    .network-card {
        height: 70px !important;
        padding: 10px !important;
        border-radius: 10px !important;
    }

    .network-card img {
        max-height: 35px !important;
    }

    /* Bottom nav */
    .bottom-nav-link i {
        font-size: 1rem !important;
    }

    .bottom-nav-link span {
        font-size: 0.6rem !important;
    }

    /* FAB button */
    .fab-wrapper {
        top: -40px !important;
    }

    .fab-button {
        width: 58px !important;
        height: 58px !important;
    }

    .fab-button i {
        font-size: 1.3rem !important;
    }

    .fab-spacer {
        height: 30px !important;
    }

    /* Services bottom sheet */
    .action-icon-circle {
        width: 45px !important;
        height: 45px !important;
        border-radius: 14px !important;
        font-size: 1.1rem !important;
    }

    /* Tables on very small screens */
    .table td, .table th {
        padding: 0.4rem 0.3rem !important;
        font-size: 0.75rem !important;
    }

    /* Buttons */
    .btn {
        padding: 0.4rem 0.75rem !important;
        font-size: 0.8rem !important;
    }

    .btn-sm {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.7rem !important;
    }

    /* Col padding */
    [class*="col-"]:not(.col-6) {
        padding-left: 4px !important;
        padding-right: 4px !important;
    }

    .col-6 {
        padding-left: 4px !important;
        padding-right: 4px !important;
        flex: 0 0 50% !important;
        max-width: 50% !important;
        width: 50% !important;
    }

    .row {
        margin-left: -4px !important;
        margin-right: -4px !important;
    }

    /* Profile image */
    .profile-img,
    img[width="100"][height="100"] {
        width: 70px !important;
        height: 70px !important;
    }

    /* Login card */
    .login-card {
        padding: 1.25rem !important;
        margin: 0 0.5rem !important;
    }

    /* Card counter (admin/portal) */
    .card-counter {
        height: auto !important;
        min-height: 90px !important;
        padding: 12px !important;
    }

    .card-counter i {
        font-size: 3em !important;
    }

    .card-counter .count-numbers {
        font-size: 20px !important;
        right: 12px !important;
        top: 12px !important;
    }

    .card-counter .count-name {
        font-size: 12px !important;
        right: 12px !important;
        top: 45px !important;
    }

    /* Modal adjustments */
    .modal-body {
        padding: 0.75rem !important;
    }

    .modal-header {
        padding: 0.75rem !important;
    }

    /* Form labels */
    .form-label, label {
        font-size: 0.8rem !important;
    }

    /* Headings */
    h1, .h1 { font-size: 1.4rem !important; }
    h2, .h2 { font-size: 1.2rem !important; }
    h3, .h3 { font-size: 1.1rem !important; }
    h4, .h4 { font-size: 1rem !important; }
    h5, .h5 { font-size: 0.9rem !important; }
}


/* ==================================================================
   SMALL PHONES (375px - 576px — iPhone, most Android phones)
   ================================================================== */
@media (min-width: 375px) and (max-width: 576px) {
    html {
        font-size: 14px;
    }

    .container-fluid {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    .card {
        border-radius: 14px !important;
        margin-bottom: 0.85rem !important;
    }

    .card-body {
        padding: 1rem !important;
    }

    /* Balance card */
    .balance-card {
        border-radius: 18px !important;
    }

    .balance-card h2,
    .balance-card .h2 {
        font-size: 1.6rem !important;
    }

    /* Quick actions */
    .quick-action-icon {
        width: 45px !important;
        height: 45px !important;
        font-size: 1.3rem !important;
        border-radius: 12px !important;
    }

    .quick-action-item {
        padding: 14px !important;
        border-radius: 16px !important;
    }

    .quick-action-item .small {
        font-size: 0.78rem !important;
    }

    /* Network cards */
    .network-card {
        height: 80px !important;
        padding: 14px !important;
    }

    .network-card img {
        max-height: 45px !important;
    }

    /* Column spacing */
    [class*="col-"]:not(.col-6) {
        padding-left: 6px !important;
        padding-right: 6px !important;
    }

    .col-6 {
        padding-left: 6px !important;
        padding-right: 6px !important;
        flex: 0 0 50% !important;
        max-width: 50% !important;
        width: 50% !important;
    }

    .row {
        margin-left: -6px !important;
        margin-right: -6px !important;
    }

    /* Tables */
    .table td, .table th {
        padding: 0.5rem 0.4rem !important;
        font-size: 0.8rem !important;
    }

    /* Card counter (admin/portal) */
    .card-counter {
        height: auto !important;
        min-height: 100px !important;
        padding: 15px !important;
    }

    .card-counter i {
        font-size: 3.5em !important;
    }

    .card-counter .count-numbers {
        font-size: 22px !important;
    }

    .card-counter .count-name {
        font-size: 13px !important;
    }

    /* Login/Register */
    .login-card {
        padding: 1.5rem !important;
        margin: 0 0.75rem !important;
    }

    /* Services bottom sheet icons */
    .action-icon-circle {
        width: 50px !important;
        height: 50px !important;
        border-radius: 16px !important;
        font-size: 1.2rem !important;
    }

    /* Profile page */
    .profile-img,
    img[width="100"][height="100"] {
        width: 80px !important;
        height: 80px !important;
    }
}


/* ==================================================================
   ALL MOBILE (up to 768px) — shared rules
   ================================================================== */
@media (max-width: 768px) {
    /* Ensure bottom nav shows and body has space */
    .bottom-nav {
        display: block !important;
    }

    body {
        padding-bottom: 85px !important;
    }

    /* Navbar compact */
    .navbar {
        padding: 0.4rem 0.5rem !important;
    }

    .navbar-brand {
        font-size: 1.2rem !important;
    }

    /* Make sure dropdowns don't overflow */
    .dropdown-menu {
        max-width: calc(100vw - 20px) !important;
    }

    /* Offcanvas sidebar */
    .offcanvas.sidebar {
        width: 260px !important;
    }

    /* Portal/Admin sidebar */
    .sidebar {
        width: 260px !important;
    }

    /* Main content when sidebar is present */
    .flex-grow-1 {
        width: 100% !important;
        padding: 0.75rem !important;
    }

    /* Cards: prevent overflow */
    .card {
        overflow: hidden;
    }

    /* Forms: full width */
    .form-control, .form-select, .input-group {
        width: 100% !important;
    }

    /* Responsive images in cards */
    .card img:not(.svc-card-logo) {
        max-width: 100%;
        height: auto;
    }

    /* Fix any absolutely positioned elements that overflow */
    .position-absolute {
        max-width: 100%;
    }

    /* Transaction/pricing filter pills - scrollable row */
    .d-flex.flex-wrap.gap-2 {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap !important;
        padding-bottom: 8px;
    }

    /* SweetAlert mobile fix */
    .swal2-popup {
        width: 90vw !important;
        max-width: 340px !important;
        font-size: 0.9rem !important;
    }

    /* Receipt page adjustments */
    .receipt-container,
    [class*="receipt"] {
        width: 100% !important;
        max-width: 100% !important;
        padding: 10px !important;
    }

    /* Chart.js canvas responsive */
    canvas {
        max-width: 100% !important;
        height: auto !important;
    }

    /* Hide large screen elements */
    .d-lg-block {
        display: none !important;
    }

    /* Text adjustments */
    .fs-4 {
        font-size: 1.1rem !important;
    }

    .fs-5 {
        font-size: 1rem !important;
    }

    /* Badge adjustments */
    .badge {
        font-size: 0.7rem !important;
        padding: 0.3em 0.5em !important;
    }

    /* Prevent text overflow */
    td, th, p, span, div, a {
        word-break: break-word;
        overflow-wrap: break-word;
    }

    /* Fix pagination */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }

    .page-link {
        padding: 0.35rem 0.6rem !important;
        font-size: 0.8rem !important;
    }

    /* Scrollable tabs */
    .nav-tabs, .nav-pills {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .nav-tabs .nav-link, .nav-pills .nav-link {
        white-space: nowrap;
    }
}


/* ==================================================================
   TABLETS (577px - 768px)
   ================================================================== */
@media (min-width: 577px) and (max-width: 768px) {
    .container-fluid {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }

    /* Quick actions: 3 columns instead of 2 */
    .quick-action-item {
        padding: 18px !important;
    }

    .quick-action-icon {
        width: 55px !important;
        height: 55px !important;
        font-size: 1.5rem !important;
    }

    /* Network cards */
    .network-card {
        height: 90px !important;
    }

    /* Balance card */
    .balance-card h2,
    .balance-card .h2 {
        font-size: 1.8rem !important;
    }

    /* Card counter (admin/portal) */
    .card-counter {
        height: 110px !important;
    }
}


/* ==================================================================
   TABLETS & SMALL DESKTOPS (769px - 992px)
   ================================================================== */
@media (min-width: 769px) and (max-width: 992px) {
    /* Hide bottom nav on tablet landscape and up */
    .bottom-nav {
        display: none !important;
    }

    body {
        padding-bottom: 0 !important;
    }

    .container-fluid {
        padding-left: 20px;
        padding-right: 20px;
    }

    /* Portal/Admin sidebar - show fixed */
    .sidebar {
        left: 0 !important;
        width: 220px !important;
    }

    .flex-grow-1 {
        margin-left: 220px !important;
    }
}


/* ==================================================================
   LARGE SCREENS (993px+)
   ================================================================== */
@media (min-width: 993px) {
    .bottom-nav {
        display: none !important;
    }

    body {
        padding-bottom: 0 !important;
    }

    /* Portal/Admin sidebar */
    .sidebar {
        left: 0 !important;
        width: 280px !important;
    }

    .flex-grow-1 {
        margin-left: 280px !important;
    }
}


/* ==================================================================
   LANDSCAPE ORIENTATION FIXES
   ================================================================== */
@media (max-height: 500px) and (orientation: landscape) {
    /* Reduce bottom nav height in landscape */
    .bottom-nav {
        padding-bottom: 0 !important;
    }

    .bottom-nav-menu {
        padding: 5px 0 !important;
    }

    .bottom-nav-link i {
        font-size: 1rem !important;
    }

    .bottom-nav-link span {
        font-size: 0.6rem !important;
    }

    /* FAB smaller in landscape */
    .fab-container > div > a {
        width: 50px !important;
        height: 50px !important;
    }

    body {
        padding-bottom: 60px !important;
    }

    /* Reduce card padding */
    .card-body {
        padding: 0.5rem !important;
    }

    .balance-card .card-body {
        padding: 0.75rem !important;
    }
}


/* ==================================================================
   SAFE AREA (notch phones — iPhone X+, etc.)
   ================================================================== */
@supports (padding: env(safe-area-inset-bottom)) {
    .bottom-nav {
        padding-bottom: calc(env(safe-area-inset-bottom) + 5px) !important;
    }

    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}


/* ==================================================================
   PRINT STYLES (receipts, transactions)
   ================================================================== */
@media print {
    .bottom-nav,
    .navbar,
    .offcanvas,
    .sidebar,
    .sidebar-overlay,
    #sidebarToggle,
    .btn,
    .fab-container {
        display: none !important;
    }

    body {
        padding: 0 !important;
        margin: 0 !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }

    .container-fluid {
        padding: 0 !important;
    }
}


/* ==================================================================
   UTILITY CLASSES FOR RESPONSIVE VISIBILITY
   ================================================================== */
.mobile-only {
    display: none !important;
}

.desktop-only {
    display: block !important;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block !important;
    }

    .desktop-only {
        display: none !important;
    }
}

/* Responsive text utilities */
.text-truncate-mobile {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (min-width: 769px) {
    .text-truncate-mobile {
        overflow: visible;
        text-overflow: unset;
        white-space: normal;
    }
}

/* Touch-friendly spacing on mobile */
@media (max-width: 768px) {
    .list-group-item {
        padding: 0.75rem 1rem !important;
    }

    .nav-link {
        padding: 0.75rem 1rem !important;
    }
}


/* ==================================================================
   FIX: Duplicated styles in style.css that conflict
   These ensure the proper cascade order
   ================================================================== */

/* Ensure FAB center button is properly positioned across all sizes */
@media (max-width: 768px) {
    .bottom-nav-item.fab-container {
        position: relative;
        top: 0 !important;
    }

    .bottom-nav-item.fab-container > div:first-child {
        position: absolute !important;
        top: -38px !important;
    }
}

/* Fix the main wrapper to not exceed viewport */
.main-wrapper {
    max-width: 100vw;
    overflow-x: hidden;
}

/* Fix form groups on mobile */
@media (max-width: 576px) {
    .input-group {
        flex-wrap: nowrap !important;
    }

    .input-group .form-control {
        min-width: 0;
    }

    .input-group-text {
        padding: 0.375rem 0.5rem !important;
        font-size: 0.85rem !important;
    }

    /* Stack form rows on mobile */
    .row.g-3 > [class*="col-md-"]:not(.col-6),
    .row.g-3 > [class*="col-lg-"]:not(.col-6) {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Alert text size */
    .alert {
        font-size: 0.85rem !important;
        padding: 0.6rem 0.8rem !important;
    }

    /* Modal full-width on small screens */
    .modal-dialog {
        margin: 0.5rem !important;
        max-width: calc(100vw - 1rem) !important;
    }
}
