
/* =========================================================
   Client Responsive Stage 2
   Tối ưu riêng các trang user chính trên tablet/mobile.
   Chỉ CSS + một số class đã có, không đụng logic backend.
   ========================================================= */

:root {
    --client-stage2-radius: 16px;
    --client-stage2-border: #e6edf7;
    --client-stage2-soft: #f7faff;
    --client-stage2-text: #101828;
    --client-stage2-muted: #667085;
    --client-stage2-primary: #187de4;
    --client-stage2-shadow: 0 10px 28px rgba(15, 23, 42, .06);
}

/* Tiêu đề/hành động đầu trang gọn hơn */
.order-history-head,
.support-header,
.service-catalog .card-body > .d-flex:first-child,
.account-head,
.api-doc-card .card-body > .d-flex:first-child {
    min-width: 0;
}

.order-history-head h3,
.support-header h4,
.service-catalog h3,
.wallet-title,
.account-head h3,
.api-doc-card h3,
.api-doc-card h4 {
    letter-spacing: -.02em;
}

/* Trang đặt hàng: thông tin dịch vụ dễ đọc hơn */
.order-card .card-body {
    position: relative;
}

.order-card .div-description {
    scrollbar-width: thin;
}

.order-card .div-description table {
    width: 100% !important;
    max-width: 100%;
}

/* Trang bảng giá: card dịch vụ trên mobile */
.service-mobile-tools {
    margin-bottom: 12px;
}

.service-mobile-tools .input-icon {
    position: relative;
}

.service-mobile-tools .input-icon > span {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

.service-mobile-search {
    border-radius: 12px !important;
    min-height: 46px !important;
    padding-right: 42px !important;
}

.service-mobile-list {
    display: grid;
    gap: 12px;
}

.service-mobile-card {
    background: #ffffff;
    border: 1px solid var(--client-stage2-border);
    border-radius: 15px;
    box-shadow: var(--client-stage2-shadow);
    padding: 14px;
}

.service-mobile-title {
    color: var(--client-stage2-text);
    font-weight: 800;
    line-height: 1.4;
    margin-bottom: 10px;
    word-break: break-word;
}

.service-mobile-meta,
.service-mobile-specs,
.service-mobile-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.service-mobile-meta {
    justify-content: space-between;
    color: var(--client-stage2-muted);
    margin-bottom: 10px;
}

.service-mobile-meta strong {
    color: var(--client-stage2-primary);
    font-size: 15px;
}

.service-mobile-specs {
    margin-bottom: 12px;
}

.service-mobile-specs span {
    background: #f2f6fc;
    border-radius: 999px;
    color: #475467;
    font-size: 12px;
    padding: 5px 9px;
}

.service-mobile-actions .btn {
    flex: 1 1 120px;
}

.client-mobile-empty {
    background: #fff8e6;
    border: 1px solid #fde5a7;
    border-radius: 14px;
    color: #92400e;
    padding: 14px;
    text-align: center;
}

/* Lịch sử đơn: card hóa table trên mobile */
.order-history-wrap,
.support-wrap,
.wallet-card,
.account-card,
.account-stat,
.api-doc-card,
.service-catalog {
    border-radius: var(--client-stage2-radius) !important;
}

.order-bulk-toolbar .btn,
.order-history-head .btn,
.support-actions .btn {
    white-space: normal;
}

/* Ví */
.wallet-info-row strong,
.api-key-input,
.api-code {
    overflow-wrap: anywhere;
}

.wallet-info-row .btn {
    white-space: nowrap;
}

.wallet-history-table td {
    word-break: break-word;
}

/* API */
.api-doc-card .input-group {
    min-width: 0;
}

.api-code {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.api-table th,
.api-table td {
    vertical-align: top !important;
}

/* Account */
.account-actions .account-action-btn {
    justify-content: center;
    text-align: center;
}

@media (max-width: 991.98px) {
    .service-catalog .card-body > .d-flex:first-child,
    .order-history-head,
    .support-header,
    .account-head {
        align-items: flex-start !important;
        gap: 12px;
    }

    .order-card .row > .col-lg-5,
    .order-card .row > .col-lg-7 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .order-card .div-description {
        margin-top: 8px;
        max-height: 440px;
    }

    .wallet-page > .row > [class*='col-'] + [class*='col-'] {
        margin-top: 14px;
    }

    .api-doc-card .card-header,
    .api-doc-card .card-body {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }
}

@media (max-width: 767.98px) {
    /* Header hành động của từng trang */
    .service-catalog .card-body > .d-flex:first-child,
    .order-history-head,
    .support-header,
    .account-head,
    .api-doc-card .card-body > .d-flex:first-child {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .service-catalog .card-body > .d-flex:first-child .btn,
    .order-history-head .btn,
    .support-actions,
    .support-actions .btn,
    .account-actions,
    .account-actions .account-action-btn {
        width: 100%;
    }

    .support-actions,
    .account-actions {
        margin-left: 0 !important;
    }

    /* Trang đặt hàng */
    .order-card h3 {
        font-size: 20px !important;
    }

    .order-card .card-body > .d-flex:first-child {
        gap: 12px;
    }

    .order-card .card-body > .d-flex:first-child a {
        width: 100%;
    }

    .link-mode-group {
        background: #f6f9fd;
        border: 1px solid #e6edf7;
        border-radius: 14px;
        justify-content: space-between;
        gap: 8px;
        padding: 9px;
    }

    .link-mode-option {
        flex: 1 1 0;
        justify-content: center;
        min-height: 38px;
    }

    .coin-amount {
        padding: 6px 9px;
    }

    .order-card .btn-primary.w-100 {
        min-height: 48px;
        font-size: 16px;
    }

    .order-card .div-description {
        max-height: 360px;
        padding: 13px;
    }

    /* Bảng giá: mobile dùng card, ẩn table để khỏi kéo ngang */
    .service-catalog .table-services,
    .service-catalog .dataTables_wrapper {
        display: none !important;
    }

    .service-mobile-tools,
    .service-mobile-list {
        display: block !important;
    }

    .service-mobile-list {
        display: grid !important;
    }

    /* Lịch sử đơn hàng: table thành card */
    .order-history-wrap {
        padding: 13px !important;
    }

    .order-bulk-toolbar {
        align-items: stretch !important;
        flex-direction: column;
    }

    .order-bulk-toolbar .order-bulk-count,
    .order-bulk-toolbar .btn {
        width: 100%;
        margin-right: 0 !important;
    }

    .order-history-table,
    .order-history-table thead,
    .order-history-table tbody,
    .order-history-table tr,
    .order-history-table td {
        display: block !important;
        width: 100% !important;
    }

    .order-history-table thead {
        display: none !important;
    }

    .order-history-table {
        min-width: 0 !important;
        border-spacing: 0 !important;
    }

    .order-history-table tbody tr {
        border: 1px solid #d7deeb;
        border-radius: 15px;
        box-shadow: var(--client-stage2-shadow);
        margin-bottom: 12px;
        overflow: hidden;
    }

    .order-history-table tbody td {
        border: 0 !important;
        border-bottom: 1px solid #eef2f7 !important;
        border-radius: 0 !important;
        display: grid !important;
        grid-template-columns: 112px minmax(0, 1fr);
        gap: 10px;
        padding: 10px 12px !important;
        white-space: normal !important;
        word-break: break-word;
    }

    .order-history-table tbody td:last-child {
        border-bottom: 0 !important;
    }

    .order-history-table tbody td::before {
        content: attr(data-label);
        color: #667085;
        font-size: 12px;
        font-weight: 800;
        text-transform: uppercase;
    }

    .order-link {
        word-break: break-all;
    }

    .order-status-badge {
        min-width: 0;
        width: fit-content;
    }

    /* Hỗ trợ: table thành card */
    .support-wrap {
        padding: 13px !important;
    }

    .support-table,
    .support-table thead,
    .support-table tbody,
    .support-table tr,
    .support-table td {
        display: block !important;
        width: 100% !important;
    }

    .support-table thead {
        display: none !important;
    }

    .support-table {
        min-width: 0 !important;
    }

    .support-table tbody tr {
        background: #fff;
        border: 1px solid #e6edf7;
        border-radius: 15px;
        box-shadow: var(--client-stage2-shadow);
        margin-bottom: 12px;
        overflow: hidden;
    }

    .support-table tbody td {
        border: 0 !important;
        border-bottom: 1px solid #eef2f7 !important;
        display: grid;
        grid-template-columns: 98px minmax(0, 1fr);
        gap: 10px;
        padding: 10px 12px !important;
        white-space: normal !important;
        word-break: break-word;
    }

    .support-table tbody td:last-child {
        border-bottom: 0 !important;
    }

    .support-table tbody td::before {
        content: attr(data-label);
        color: #667085;
        font-size: 12px;
        font-weight: 800;
        text-transform: uppercase;
    }

    /* Ví */
    .wallet-page .card-header {
        padding-top: 16px !important;
    }

    .wallet-balance {
        font-size: 23px !important;
    }

    .wallet-card .d-flex.align-items-center.justify-content-between {
        align-items: flex-start !important;
        flex-direction: column;
        gap: 10px;
    }

    .wallet-card .badge {
        white-space: normal;
    }

    .wallet-info-list {
        border-radius: 14px !important;
    }

    .wallet-info-row {
        grid-template-columns: 1fr !important;
        gap: 6px !important;
        padding: 12px !important;
    }

    .wallet-info-row .btn {
        width: 100%;
    }

    .wallet-qr-box img {
        max-width: min(100%, 320px) !important;
    }

    .wallet-history-table,
    .wallet-history-table thead,
    .wallet-history-table tbody,
    .wallet-history-table tr,
    .wallet-history-table td {
        display: block !important;
        width: 100% !important;
    }

    .wallet-history-table thead {
        display: none !important;
    }

    .wallet-history-table {
        min-width: 0 !important;
    }

    .wallet-history-table tbody tr {
        background: #fff;
        border: 1px solid #e6edf7;
        border-radius: 15px;
        box-shadow: var(--client-stage2-shadow);
        margin-bottom: 12px;
        overflow: hidden;
    }

    .wallet-history-table tbody td {
        border: 0 !important;
        border-bottom: 1px solid #eef2f7 !important;
        display: grid;
        grid-template-columns: 92px minmax(0, 1fr);
        gap: 10px;
        padding: 10px 12px !important;
        text-align: left !important;
        white-space: normal !important;
    }

    .wallet-history-table tbody td:last-child {
        border-bottom: 0 !important;
    }

    .wallet-history-table tbody td::before {
        content: attr(data-label);
        color: #667085;
        font-size: 12px;
        font-weight: 800;
        text-transform: uppercase;
    }

    /* Tài khoản */
    .account-avatar {
        width: 64px !important;
        height: 64px !important;
    }

    .account-stat .card-body {
        min-height: 92px !important;
    }

    .account-stats-row .col-md-4 {
        margin-bottom: 12px !important;
    }

    .account-stat-value {
        font-size: 19px !important;
        word-break: break-word;
    }

    /* API */
    .api-doc-card .input-group {
        display: block;
    }

    .api-doc-card .input-group .form-control,
    .api-doc-card .input-group-append,
    .api-doc-card .input-group-append .btn {
        width: 100%;
    }

    .api-doc-card .input-group-append {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
        gap: 8px;
        margin-left: 0 !important;
        margin-top: 8px;
    }

    .api-table,
    .api-table tbody,
    .api-table tr,
    .api-table th,
    .api-table td {
        display: block;
        width: 100% !important;
    }

    .api-table tr {
        border-bottom: 1px solid #eef2f7;
        padding: 8px 0;
    }

    .api-table th,
    .api-table td {
        border: 0 !important;
        padding: 4px 0 !important;
    }

    .api-code {
        font-size: 12px !important;
        padding: 13px !important;
    }
}

@media (max-width: 575.98px) {
    .service-mobile-card,
    .order-history-table tbody tr,
    .support-table tbody tr,
    .wallet-history-table tbody tr {
        border-radius: 13px;
    }

    .order-history-table tbody td,
    .support-table tbody td,
    .wallet-history-table tbody td {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .service-mobile-actions .btn {
        flex-basis: 100%;
    }

    .api-doc-card .badge {
        display: inline-flex;
        margin-top: 6px;
        margin-left: 0 !important;
    }
}

/* Dark mode */
body.theme-dark .service-mobile-card,
body.theme-dark .order-history-table tbody tr,
body.theme-dark .support-table tbody tr,
body.theme-dark .wallet-history-table tbody tr {
    background: #1b232d;
    border-color: #2d3948;
}

body.theme-dark .service-mobile-title,
body.theme-dark .service-mobile-meta strong,
body.theme-dark .wallet-info-row strong {
    color: #f5f8ff;
}

body.theme-dark .service-mobile-specs span,
body.theme-dark .link-mode-group {
    background: #243041;
    color: #d9e2f1;
    border-color: #2d3948;
}

body.theme-dark .order-history-table tbody td,
body.theme-dark .support-table tbody td,
body.theme-dark .wallet-history-table tbody td {
    border-bottom-color: #2d3948 !important;
}

body.theme-dark .order-history-table tbody td::before,
body.theme-dark .support-table tbody td::before,
body.theme-dark .wallet-history-table tbody td::before {
    color: #bfdbfe !important;
}

body.theme-dark .order-summary-label {
    color: #cbd5e1 !important;
}

body.theme-dark .order-summary-value {
    color: #f8fafc !important;
}

