/* ============================================
   PowerGen CRM - Mobile Responsiveness
   ============================================ */

/* ---- Login Page ---- */
@media only screen and (max-width: 767px) {
    .auth-wrapper .authentication-form {
        width: 90%;
        padding: 40px 0;
        margin: 0 auto;
    }
    .auth-wrapper .authentication-form .logo-centered {
        margin-bottom: 24px;
    }
    .auth-wrapper .authentication-form h3 {
        font-size: 18px;
        text-align: center;
    }
    .auth-wrapper .authentication-form p {
        text-align: center;
    }
    .auth-wrapper .authentication-form .sign-btn {
        margin-top: 20px;
    }
    .auth-wrapper .authentication-form .sign-btn .btn {
        width: 100%;
    }
    .auth-wrapper .authentication-form .register {
        margin-top: 20px;
    }
}

/* ---- Top Navigation ---- */
@media only screen and (max-width: 1023px) {
    .header-top .container-fluid {
        padding: 0 10px;
    }
    .header-top .top-menu .dropdown-menu {
        right: -10px !important;
    }
    .header-top .nav-link {
        padding: 8px 6px;
    }
    #navbar-fullscreen {
        display: none;
    }
    /* Ensure hamburger menu button is visible and tappable */
    .mobile-nav-toggle.btn-icon {
        display: inline-block !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: 44px !important;
        height: 44px !important;
        min-width: 44px;
        min-height: 44px;
        position: relative;
        background: transparent;
        border: none !important;
        cursor: pointer;
        z-index: 10;
        padding: 0 !important;
        -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    }
    .mobile-nav-toggle span {
        display: block !important;
        top: 21px !important;
        left: 12px !important;
    }
    .mobile-nav-toggle span,
    .mobile-nav-toggle span::before,
    .mobile-nav-toggle span::after {
        background-color: #4a5361 !important;
    }
}

/* ---- Sidebar Mobile Overlay ---- */
@media only screen and (max-width: 1023px) {
    .wrapper .page-wrap .app-sidebar {
        z-index: 1050 !important;
    }
    /* When sidebar is visible (not hidden), show overlay */
    .wrapper .page-wrap .app-sidebar:not(.hide-sidebar) ~ .main-content::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.4);
        z-index: 1040;
    }
}

/* ---- Main Content Mobile Spacing ---- */
@media only screen and (max-width: 767px) {
    .main-content {
        padding-top: 10px !important;
    }
    .main-content .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }
    .page-header {
        padding: 10px 0 !important;
    }
    .page-header .page-header-title {
        display: flex;
        align-items: center;
    }
    .page-header .page-header-title i {
        margin-right: 8px;
        font-size: 20px;
        min-width: 36px;
        height: 36px;
        line-height: 36px;
    }
    .page-header .page-header-title h5 {
        font-size: 16px;
        margin-bottom: 2px;
    }
    .page-header .breadcrumb-container {
        display: none;
    }
}

/* ---- Dashboard Widgets ---- */
@media only screen and (max-width: 575px) {
    .widget .widget-body {
        padding: 12px 12px;
    }
    .widget .widget-body h6 {
        font-size: 11px;
        margin-bottom: 2px;
    }
    .widget .widget-body h2 {
        font-size: 18px;
        margin-bottom: 0;
    }
    .widget .widget-body .icon {
        font-size: 24px;
    }
    .widget .widget-body .icon i {
        font-size: 24px;
    }
    .widget .widget-body small {
        font-size: 10px;
    }
    .widget .progress {
        height: 3px;
    }
}
/* ---- Dashboard Outstanding/Generator side-by-side tables ---- */
@media only screen and (max-width: 767px) {
    .row > .col-xl-6.col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ---- Cards ---- */
@media only screen and (max-width: 767px) {
    .card {
        margin-bottom: 15px;
    }
    .card .card-header {
        padding: 12px 14px;
        flex-wrap: wrap;
    }
    .card .card-header h3 {
        font-size: 15px;
    }
    .card .card-header .card-options {
        margin-top: 0;
    }
    .card .card-body {
        padding: 14px;
    }
    .card .card-block {
        padding: 0;
    }
}


/* ---- Dashboard Card Header with Search ---- */
@media only screen and (max-width: 767px) {
    .card-header.row {
        flex-direction: column;
    }
    .card-header.row > .col,
    .card-header.row > [class*="col-sm"] {
        max-width: 100%;
        flex: 0 0 100%;
        margin-bottom: 8px;
    }
    .card-search .form-control {
        font-size: 14px;
    }
    .adv-search-wrap .row .col-md-4,
    .adv-search-wrap .row .col-md-6,
    .adv-search-wrap .row .col-md-12 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ---- Modals ---- */
@media only screen and (max-width: 575px) {
    .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
    .modal-body {
        padding: 14px;
    }
    .modal-body .row > [class*="col-md"] {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 0;
    }
    .modal-footer {
        padding: 10px 14px;
        flex-wrap: wrap;
        gap: 8px;
    }
    .modal-footer .btn {
        flex: 1;
        min-width: 0;
    }
}

/* ---- Form Elements ---- */
@media only screen and (max-width: 575px) {
    .form-control {
        font-size: 14px;
        padding: 6px 10px;
    }
    .form-group label {
        font-size: 13px;
    }
    select.form-control {
        height: auto;
        padding: 8px 10px;
    }
}

/* ---- Buttons ---- */
@media only screen and (max-width: 575px) {
    .btn {
        padding: 6px 12px;
        font-size: 13px;
    }
    .btn-block {
        margin-bottom: 6px;
    }
}

/* ---- Client Detail Page ---- */
@media only screen and (max-width: 767px) {
    .col-lg-3.col-md-4 .card .text-center img.rounded-circle {
        width: 100px !important;
    }
    .col-lg-3.col-md-4 .card .row.text-center {
        flex-direction: column;
        gap: 8px;
    }
    .col-lg-3.col-md-4 .card .row.text-center .btn {
        margin-left: 0 !important;
        width: 100%;
    }
}

/* ---- Invoice List Page ---- */
@media only screen and (max-width: 767px) {
    /* Stats row */
    .row .col-md-3 .widget,
    .row .col-sm-6 .widget {
        margin-bottom: 10px;
    }
}

/* ---- Invoice View Page ---- */
@media only screen and (max-width: 767px) {
    /* Stack sidebar and content */
    .col-lg-4.col-md-5,
    .col-lg-8.col-md-7 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    /* Summary table values */
    .table-borderless.table-sm td {
        padding: 6px 4px;
        font-size: 13px;
    }
}

/* ---- Invoice Download Page ---- */
@media only screen and (max-width: 600px) {
    .invoice-container {
        margin: 10px !important;
    }
    .invoice-header {
        flex-direction: column;
        padding: 24px 20px !important;
        gap: 16px;
    }
    .invoice-title {
        text-align: left !important;
    }
    .invoice-title h2 {
        font-size: 24px !important;
    }
    .invoice-meta {
        flex-direction: column;
        padding: 20px !important;
        gap: 20px;
    }
    .invoice-meta .meta-block:last-child {
        text-align: left !important;
    }
    .invoice-table th,
    .invoice-table td {
        padding: 10px 12px !important;
        font-size: 12px !important;
    }
    .invoice-table th:first-child,
    .invoice-table td:first-child {
        padding-left: 16px !important;
    }
    .invoice-table th:last-child,
    .invoice-table td:last-child {
        padding-right: 16px !important;
    }
    .invoice-totals {
        padding: 0 20px 20px !important;
    }
    .totals-table {
        width: 100% !important;
    }
    .payments-section {
        padding: 0 20px 20px !important;
    }
    .invoice-notes {
        padding: 16px 20px !important;
    }
    .print-actions {
        margin: 10px !important;
        justify-content: center !important;
    }
    .btn-action {
        padding: 8px 16px !important;
        font-size: 13px !important;
    }
}

/* ---- Teams Page ---- */
@media only screen and (max-width: 767px) {
    .col-lg-4.col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ---- Badge sizes on mobile ---- */
@media only screen and (max-width: 575px) {
    .badge {
        font-size: 11px;
        padding: 3px 6px;
    }
}

/* ---- Floating Action for Mobile ---- */
@media only screen and (max-width: 575px) {
    .d-flex.justify-content-between.align-items-center {
        flex-wrap: wrap;
        gap: 8px;
    }
}

/* ---- Touch-friendly tap targets ---- */
@media only screen and (max-width: 767px) {
    .clickable-row td {
        cursor: pointer;
        padding-top: 12px !important;
        padding-bottom: 12px !important;
    }
    .nav-item a {
        padding: 10px 15px;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}

/* ---- Utility: Hide on small screens ---- */
@media only screen and (max-width: 575px) {
    .d-xs-none {
        display: none !important;
    }
}
