/* Custom CSS for Partial Payment plugin */
#pp-payment-modal,
#pp-history-modal,
#pp-order-details-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    overflow-y: auto;
    padding: 20px 0;
}

.modal-content {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 60%;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 10000;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    color: #888;
}

.modal-close:hover {
    color: #000;
}

label {
    display: block;
    margin-top: 10px;
}

input,
select {
    /* width: 100%; */
    padding: 8px;
    margin-top: 5px;
}

button {
    margin-top: 15px;
    padding: 10px;
    background: #2271b1;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

body.modal-open {
    overflow: hidden;
}

#pp-history-modal .history-table,
#pp-order-details-modal .history-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

#pp-history-modal .history-table th,
#pp-history-modal .history-table td,
#pp-order-details-modal .history-table th,
#pp-order-details-modal .history-table td {
    border: 1px solid #ddd;
    padding: 8px;
    font-size: 14px;
}

#pp-history-modal .history-table th,
#pp-order-details-modal .history-table th {
    background-color: #f4f4f4;
    text-align: left;
}

/* Table styling for admin and shortcodes */
.history-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.history-table th,
.history-table td {
    border: 1px solid #ddd;
    padding: 8px;
    font-size: 14px;
}

.history-table th {
    background-color: #f4f4f4;
    text-align: left;
}

.pp-total-info span.woocommerce-Price-amount.amount,
.modal-content span.woocommerce-Price-amount.amount {
    color: #000;
}

.pp-total-item {
    display: inline-block;
    margin-right: 12px;
    margin-bottom: 0;
}

.pp-order-status-container {
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: center;
}

div#pp-tab-content .pp-order-status-container .elementor-button {
    margin-top: 0px;
}

@media (max-width: 600px) {
    .pp-total-item {
        display: block;
        margin-right: 0;
        margin-bottom: 2px;
    }

    .modal-content {
        max-width: 98vw;
        font-size: 15px;
    }

    #pp-payment-modal,
    #pp-history-modal,
    #pp-order-details-modal {
        padding: 5px 0;
    }

    .pp-order-details-flex {
        flex-direction: column;
    }
    .pp-order-status-container {
        text-align: left;
    }
}

/* --- MOBILE RESPONSIVE ENHANCEMENTS FOR WC PARTIAL PAYMENTS PLUGIN --- */
@media (max-width: 900px) {
    #pp-tabs {
        flex-wrap: wrap;
        overflow-x: auto;
        gap: 6px;
    }

    #pp-tabs li {
        flex: 1 0 120px;
        min-width: 120px;
        max-width: 100%;
    }

    #pp-tab-content {
        padding: 10px;
    }
}

@media (max-width: 700px) {

    .pp-plugin-wrapper,
    #pp-tab-content,
    .modal-content,
    #pp-add-store-user-form {
        padding: 6px !important;
        font-size: 15px;
    }

    #pp-tabs {
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 4px;
        margin-bottom: 10px !important;
    }

    #pp-tabs li {
        min-width: 110px;
        flex: 0 0 auto;
    }

    .modal-content {
        max-width: 99vw;
        min-width: 0;
        padding: 10px;
    }
}

@media (max-width: 600px) {

    /* Tabs stack vertically */
    #pp-tabs {
        flex-direction: column !important;
        flex-wrap: nowrap !important;
        gap: 0 !important;
        overflow-x: visible !important;
    }

    #pp-tabs li {
        min-width: 0 !important;
        width: 100% !important;
        margin-bottom: 6px !important;
    }

    #pp-tabs .pp-tab-link {
        width: 100%;
        display: block;
        border-radius: 4px !important;
        border-bottom: 1px solid #ccc !important;
        margin: 0 !important;
        text-align: left;
    }

    /* Table as cards, no horizontal scroll */
    table#pp-orders-table,
    table#pp_store_user_list_table,
    .history-table {
        display: block;
        width: 100%;
        border: 0;
        background: none;
        box-shadow: none;
        overflow-x: visible;
    }

    table#pp-orders-table thead,
    table#pp_store_user_list_table thead,
    .history-table thead {
        display: none;
    }

    table#pp-orders-table tbody,
    table#pp_store_user_list_table tbody,
    .history-table tbody {
        display: block;
        width: 100%;
    }

    table#pp-orders-table tbody tr,
    table#pp_store_user_list_table tbody tr,
    .history-table tbody tr {
        display: block;
        margin-bottom: 18px;
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
        background: #fff;
        padding: 12px 10px 8px 10px;
        border: 1px solid #e5e5e5;
        position: relative;
    }

    table#pp-orders-table td,
    table#pp_store_user_list_table td,
    .history-table td {
        display: flex;
        width: 100%;
        justify-content: flex-start;
        align-items: flex-start;
        padding: 7px 0;
        font-size: 15px;
        border: none;
        border-bottom: none;
        background: none;
        position: relative;
    }

    table#pp-orders-table td:before,
    table#pp_store_user_list_table td:before,
    .history-table td:before {
        content: attr(data-label);
        font-weight: 600;
        color: #2271b1;
        min-width: 110px;
        margin-right: 10px;
        display: inline-block;
        font-size: 14px;
        flex: 0 0 110px;
        text-align: left;
        letter-spacing: 0.01em;
    }

    table#pp-orders-table td:last-child,
    table#pp_store_user_list_table td:last-child,
    .history-table td:last-child {
        border-bottom: none;
    }

    /* Add spacing between label and value */
    table#pp-orders-table td,
    table#pp_store_user_list_table td,
    .history-table td {
        gap: 8px;
    }

    /* Card shadow and spacing for last row */
    table#pp-orders-table tbody tr:last-child,
    table#pp_store_user_list_table tbody tr:last-child,
    .history-table tbody tr:last-child {
        margin-bottom: 0;
    }

    /* Hide DataTables paging/filter on mobile */
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        font-size: 14px;
        padding: 2px 0;
        text-align: center;
        float: none !important;
        width: 100%;
        margin: 0 !important;
    }
}

@media (max-width: 480px) {

    .modal-content,
    #pp-tab-content,
    .pp-plugin-wrapper {
        font-size: 14px;
    }

    #pp-tabs li {
        min-width: 90px;
        font-size: 13px;
    }

    button,
    .elementor-button {
        font-size: 14px;
        padding: 7px 10px;
    }
}

/* Utility: Make modals always fit viewport */
@media (max-width: 600px) {

    #pp-payment-modal,
    #pp-history-modal,
    #pp-order-details-modal {
        align-items: center;
        padding: 0;
    }

    .modal-content {
        max-width: 100vw;
        min-width: 0;
        border-radius: 0 0 8px 8px;
    }
}

/* Utility: Fix select2 and form fields on mobile */
@media (max-width: 600px) {

    .select2-container,
    .select2-selection,
    .select2-selection__rendered {
        font-size: 15px !important;
        min-width: 0 !important;
        width: 100% !important;
    }

    /* input,
    select,
    textarea {
        font-size: 15px !important;
        min-width: 0 !important;
        width: 100% !important;
    } */
}

/* Utility: Hide horizontal scroll on body when modal open */
body.modal-open {
    overflow-x: hidden;
}

.pp-customer-info,
.pp-total-info {
    display: flex;
    flex-direction: column;
    text-align: left;
}

@media (max-width: 600px) {

    table#pp-orders-table,
    table#pp_store_user_list_table,
    .history-table {
        box-sizing: border-box;
        max-width: 100vw;
        width: 100% !important;
        overflow-x: visible;
    }

    table#pp-orders-table td,
    table#pp_store_user_list_table td,
    .history-table td {
        word-break: break-word !important;
        white-space: normal !important;
        overflow-wrap: anywhere !important;
        box-sizing: border-box;
        max-width: 100%;
    }

    table#pp-orders-table td *,
    table#pp_store_user_list_table td *,
    .history-table td * {
        word-break: break-word !important;
        white-space: normal !important;
        overflow-wrap: anywhere !important;
        box-sizing: border-box;
        max-width: 100%;
    }

    table#pp-orders-table td,
    table#pp_store_user_list_table td,
    .history-table td {
        flex-direction: row !important;
        align-items: flex-start !important;
        gap: 2px !important;
    }

    table#pp-orders-table td:before,
    table#pp_store_user_list_table td:before,
    .history-table td:before {
        margin-bottom: 2px;
    }

    .dataTables_filter>label,
    .dataTables_length>label {
        display: flex;
        align-items: center;
        gap: 10px;
    }
}