/* ============================================
   Payment History 페이지 스타일
   ============================================ */

/* 테마 전환 시 글자·줄 위치가 미세하게 달라 보이는 현상 완화
   - polytalk-dark.css 는 body.dark-mode 에만 폰트 스무딩·text-rendering 을 둠 → 라이트와 달라짐
   - 이 페이지에서는 라이트·다크 모두 body.dark-mode 와 동일한 텍스트 렌더링 규칙 사용
   - 스크롤바 표시/테마에 따른 가로폭 변화 완화 (가능한 브라우저에서) */
html.payment-history-page {
    text-rendering: optimizeLegibility;
}

html.payment-history-page body {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html.payment-history-page {
    scrollbar-gutter: stable;
}

html.payment-history-page:not(.dark-mode) {
    color-scheme: light;
}

html, body {
    height: 100% !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

body:not(.dark-mode) {
    background: #ffffff !important;
}

body.dark-mode, body.dark-mode html {
    background: rgb(32, 33, 37) !important;
}

.lx_app_wrap {
    background: #ffffff !important;
}

body.dark-mode .lx_app_wrap {
    background: rgb(32, 33, 37) !important;
}

.main-container {
    min-height: calc(100vh - 80px);
    padding: 40px 20px;
    padding-top: 24px;
    background: #ffffff;
}

body.dark-mode .main-container {
    background: rgb(32, 33, 37) !important;
}

.history-container {
    max-width: 900px !important;
    width: 900px !important;
    margin: 0 auto;
    padding: 20px 0;
    box-sizing: border-box;
}

.history-title {
    font-size: 42px;
    font-weight: 800;
    text-align: center;
    color: #1a1a2e;
    margin-bottom: 40px;
    letter-spacing: -0.5px;
}

body.dark-mode .history-title {
    color: #f1f5f9 !important;
}

.user-info-banner {
    background: white;
    border-radius: 12px;
    padding: 24px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    margin-bottom: 32px;
}

.user-info-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-plan-badge-large {
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    color: white;
    background: #4f46e5;
}

.user-welcome-text {
    font-size: 16px;
    color: #1a1a2e;
}

.user-welcome-text strong {
    font-weight: 600;
}

.user-info-right {
    display: flex;
    gap: 32px;
}

.user-stat {
    text-align: right;
}

.user-stat-label {
    font-size: 13px;
    color: #666;
}

.user-stat-value {
    font-size: 18px;
    font-weight: 700;
    color: #1a1a2e;
}

body.dark-mode .user-info-banner {
    background: #202020 !important;
    border: 1px solid rgba(148, 163, 184, 0.6) !important;
    box-shadow: none !important;
}

body.dark-mode .user-welcome-text {
    color: #f1f5f9 !important;
}

body.dark-mode .user-stat-label {
    color: #94a3b8 !important;
}

body.dark-mode .user-stat-value {
    color: #f1f5f9 !important;
}

/* 탭 메뉴 */
.history-tabs {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 40px;
    border-bottom: 1px solid #E5E7EB;
    padding-bottom: 0;
}

body.dark-mode .history-tabs {
    border-bottom-color: rgba(148, 163, 184, 0.1) !important;
}

.history-tab {
    font-size: 15px;
    color: #666;
    text-decoration: none;
    padding: 16px 0;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

body.dark-mode .history-tab {
    color: #94a3b8 !important;
}

.history-tab:hover {
    color: #1a1a2e;
}

body.dark-mode .history-tab:hover {
    color: #f1f5f9 !important;
}

.history-tab.active {
    color: #4f46e5;
    font-weight: 600;
    border-bottom-color: #4f46e5;
}

body.dark-mode .history-tab.active {
    color: #3b82f6 !important;
    border-bottom-color: #3b82f6 !important;
}

.history-section {
    background: white;
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

body.dark-mode .history-section {
    background: #202020 !important;
    border: 1px solid rgba(148, 163, 184, 0.6) !important;
    box-shadow: none !important;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    table-layout: fixed;
}

.table-wrapper {
    position: relative;
}

.history-table thead {
    background: #f8f9fa;
}

body.dark-mode .history-table thead {
    background: #1e293b !important;
}

.history-table th {
    padding: 16px;
    text-align: left;
    color: #666;
    font-weight: 600;
    border-bottom: 2px solid #E5E7EB;
    position: sticky;
    top: 0;
    background: #f8f9fa;
    z-index: 10;
}

body.dark-mode .history-table th {
    color: #94a3b8 !important;
    border-bottom-color: rgba(148, 163, 184, 0.1) !important;
    background: #1e293b !important;
}

/* 결제내역 테이블 컬럼 너비 고정 (5개 컬럼) */
#tab-payment .history-table th:nth-child(1),
#tab-payment .history-table td:nth-child(1) {
    width: 20%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#tab-payment .history-table th:nth-child(2),
#tab-payment .history-table td:nth-child(2) {
    width: 18%;
    white-space: nowrap;
}

#tab-payment .history-table th:nth-child(3),
#tab-payment .history-table td:nth-child(3) {
    width: 15%;
}

#tab-payment .history-table th:nth-child(4),
#tab-payment .history-table td:nth-child(4) {
    width: 22%;
}

#tab-payment .history-table th:nth-child(5),
#tab-payment .history-table td:nth-child(5) {
    width: 30%;
}

/* 사용내역 테이블 컬럼 너비 고정 (4개 컬럼) */
#tab-credit .history-table th:nth-child(1),
#tab-credit .history-table td:nth-child(1) {
    width: 15%;
}

#tab-credit .history-table th:nth-child(2),
#tab-credit .history-table td:nth-child(2) {
    width: 20%;
}

#tab-credit .history-table th:nth-child(3),
#tab-credit .history-table td:nth-child(3) {
    width: 40%;
}

#tab-credit .history-table th:nth-child(4),
#tab-credit .history-table td:nth-child(4) {
    width: 25%;
}

.history-table td {
    padding: 16px;
    border-bottom: 1px solid #E5E7EB;
    color: #1a1a2e;
}

body.dark-mode .history-table td {
    color: #f1f5f9 !important;
    border-bottom-color: rgba(148, 163, 184, 0.1) !important;
}

.history-table tbody tr:hover {
    background: #f8f9fa;
}

body.dark-mode .history-table tbody tr:hover {
    background: #1e293b !important;
}

.history-table th.text-center,
.history-table td.text-center {
    text-align: center;
}

.history-table th.text-right,
.history-table td.text-right {
    text-align: right;
}

.no-data {
    text-align: center;
    padding: 60px 20px;
    color: #666;
    font-size: 16px;
}

body.dark-mode .no-data {
    color: #94a3b8 !important;
}

.payment-method {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    background: #e5e7eb;
    color: #374151;
    white-space: nowrap;
}

body.dark-mode .payment-method {
    background: #1e293b !important;
    color: #94a3b8 !important;
}

.payment-method.card {
    background: #dbeafe;
    color: #1e40af;
}

body.dark-mode .payment-method.card {
    background: rgba(59, 130, 246, 0.2) !important;
    color: #60a5fa !important;
}

.payment-method.bank {
    background: #dcfce7;
    color: #166534;
}

body.dark-mode .payment-method.bank {
    background: rgba(34, 197, 94, 0.2) !important;
    color: #4ade80 !important;
}

.point-type {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
}

.point-type.charge {
    background: #dcfce7;
    color: #166534;
}

body.dark-mode .point-type.charge {
    background: rgba(34, 197, 94, 0.2) !important;
    color: #4ade80 !important;
}

.point-type.use {
    background: #fee2e2;
    color: #991b1b;
}

body.dark-mode .point-type.use {
    background: rgba(239, 68, 68, 0.2) !important;
    color: #f87171 !important;
}

.point-amount {
    font-weight: 600;
}

.point-amount.charge {
    color: #166534;
}

body.dark-mode .point-amount.charge {
    color: #4ade80 !important;
}

.point-amount.use {
    color: #991b1b;
}

body.dark-mode .point-amount.use {
    color: #f87171 !important;
}

/* 페이징 스타일 */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 32px;
    padding: 20px 0;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pagination-btn {
    min-width: 36px;
    height: 36px;
    padding: 8px 12px;
    border: 1px solid #E5E7EB;
    border-radius: 6px;
    background: white;
    color: #374151;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pagination-btn:hover:not(.disabled):not(.active) {
    background: #F3F4F6;
    border-color: #D1D5DB;
}

.pagination-btn.active {
    background: #4f46e5;
    color: white;
    border-color: #4f46e5;
    font-weight: 600;
}

.pagination-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

body.dark-mode .pagination-btn {
    background: #1e293b !important;
    border-color: rgba(148, 163, 184, 0.3) !important;
    color: #f1f5f9 !important;
}

body.dark-mode .pagination-btn:hover:not(.disabled):not(.active) {
    background: #334155 !important;
    border-color: rgba(148, 163, 184, 0.5) !important;
}

body.dark-mode .pagination-btn.active {
    background: #3b82f6 !important;
    border-color: #3b82f6 !important;
    color: white !important;
}

.pagination-info {
    font-size: 14px;
    color: #666;
    margin: 0 16px;
}

body.dark-mode .pagination-info {
    color: #94a3b8 !important;
}

/* 모바일 카드 스타일 */
.history-card {
    display: none;
}

.history-card-item {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

body.dark-mode .history-card-item {
    background: #202020 !important;
    border: 1px solid rgba(148, 163, 184, 0.6) !important;
    box-shadow: none !important;
}

.history-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #E5E7EB;
}

body.dark-mode .history-card-row {
    border-bottom-color: rgba(148, 163, 184, 0.1) !important;
}

.history-card-row:last-child {
    border-bottom: none;
}

.history-card-label {
    font-size: 13px;
    color: #666;
    font-weight: 500;
    min-width: 80px;
}

body.dark-mode .history-card-label {
    color: #94a3b8 !important;
}

.history-card-value {
    font-size: 14px;
    color: #1a1a2e;
    text-align: right;
    flex: 1;
    word-break: break-word;
}

body.dark-mode .history-card-value {
    color: #f1f5f9 !important;
}

/* 결제 취소 버튼 — 라이트/다크 동일 스타일
   html.dark-mode 의 color-scheme: dark 때문에 버튼 내부 글자 베이스라인이 라이트와 달라지는 것을 막기 위해
   color-scheme 고정 + inline-block + line-height 로 세로 위치 고정 */
.payment-cancel-btn {
    display: inline-block;
    vertical-align: middle;
    margin-top: 8px;
    height: 32px;
    padding: 0 14px;
    box-sizing: border-box;
    /* border 1px*2 제외한 한 줄 영역에 맞춤 (flex 중앙정렬보다 모드 전환 시 안정적) */
    line-height: 30px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: #ffffff;
    background: #ef4444;
    border: 1px solid #dc2626;
    border-radius: 6px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    white-space: nowrap;
    text-align: center;
    box-shadow: 0 1px 2px rgba(220, 38, 38, 0.22);
    color-scheme: light;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: auto;
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, color 0.2s ease;
}

.payment-cancel-btn:hover:not(:disabled) {
    background: #dc2626;
    border-color: #b91c1c;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.28);
}

.payment-cancel-btn:active:not(:disabled) {
    background: #b91c1c;
    border-color: #991b1b;
    box-shadow: 0 1px 2px rgba(185, 28, 28, 0.35);
}

.payment-cancel-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.28), 0 1px 2px rgba(220, 38, 38, 0.22);
}

.payment-cancel-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

.payment-cancel-status {
    display: inline-block;
    margin-top: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
}

body.dark-mode .payment-cancel-status {
    color: #94a3b8 !important;
}

/* 결제 취소 확인 모달 (showRefundModal) */
.refund-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.refund-modal-box {
    width: 100%;
    max-width: 420px;
    background: #ffffff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.18);
    box-sizing: border-box;
}

.refund-modal-box h3 {
    margin: 0 0 12px 0;
    font-size: 20px;
    font-weight: 700;
    color: #1a1a2e;
    letter-spacing: -0.02em;
}

.refund-modal-desc {
    margin: 0 0 20px 0;
    font-size: 14px;
    line-height: 1.55;
    color: #64748b;
}

.refund-reason-label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.refund-reason-input {
    width: 100%;
    min-height: 88px;
    padding: 12px 14px;
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.5;
    color: #1e293b;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    resize: vertical;
    box-sizing: border-box;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
}

.refund-reason-input::placeholder {
    color: #94a3b8;
}

.refund-reason-input:focus {
    outline: none;
    border-color: #4f46e5;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.refund-modal-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.refund-modal-close-btn,
.refund-modal-submit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
    border: 1px solid transparent;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.refund-modal-close-btn {
    background: #f1f5f9;
    color: #475569;
    border-color: #e2e8f0;
}

.refund-modal-close-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.refund-modal-submit-btn {
    background: #dc2626;
    color: #ffffff;
    border-color: #b91c1c;
}

.refund-modal-submit-btn:hover {
    background: #b91c1c;
    border-color: #991b1b;
}

body.dark-mode .refund-modal-overlay {
    background: rgba(0, 0, 0, 0.65);
}

body.dark-mode .refund-modal-box {
    background: #1e293b;
    border: 1px solid rgba(148, 163, 184, 0.35);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
}

body.dark-mode .refund-modal-box h3 {
    color: #f1f5f9;
}

body.dark-mode .refund-modal-desc {
    color: #94a3b8;
}

body.dark-mode .refund-reason-label {
    color: #e2e8f0;
}

body.dark-mode .refund-reason-input {
    background: #0f172a;
    border-color: rgba(148, 163, 184, 0.35);
    color: #f1f5f9;
}

body.dark-mode .refund-reason-input::placeholder {
    color: #64748b;
}

body.dark-mode .refund-reason-input:focus {
    border-color: #3b82f6;
    background: #1e293b;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

body.dark-mode .refund-modal-close-btn {
    background: #334155;
    color: #e2e8f0;
    border-color: rgba(148, 163, 184, 0.4);
}

body.dark-mode .refund-modal-close-btn:hover {
    background: #475569;
}

body.dark-mode .refund-modal-submit-btn {
    background: #dc2626;
    border-color: #ef4444;
}

body.dark-mode .refund-modal-submit-btn:hover {
    background: #b91c1c;
}

/* 환불/취소 토스트 (showToast) */
.refund-toast {
    position: fixed;
    left: 50%;
    bottom: 32px;
    transform: translateX(-50%);
    z-index: 10001;
    max-width: min(420px, calc(100vw - 32px));
    padding: 14px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.45;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
    box-sizing: border-box;
    text-align: center;
}

.refund-toast.success {
    background: #15803d;
    color: #ffffff;
}

.refund-toast.error {
    background: #b91c1c;
    color: #ffffff;
}

.refund-toast.info {
    background: #1e293b;
    color: #f1f5f9;
    border: 1px solid rgba(148, 163, 184, 0.35);
}

@media (max-width: 768px) {
    .refund-modal-box {
        padding: 20px;
    }

    .refund-modal-actions {
        flex-direction: column-reverse;
    }

    .refund-modal-close-btn,
    .refund-modal-submit-btn {
        width: 100%;
    }
}

/* 모바일: 주문번호 말줄임표 처리 */
@media (max-width: 768px) {
    .history-card-row:first-child .history-card-value {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 100%;
        cursor: pointer;
        position: relative;
    }

    .history-card-row:first-child .history-card-value:hover {
        color: #4f46e5;
    }

    body.dark-mode .history-card-row:first-child .history-card-value:hover {
        color: #60a5fa !important;
    }
}

/* 반응형 */
@media (max-width: 768px) {
    .main-container {
        padding: 20px 16px;
        padding-top: 24px;
    }

    .history-container {
        max-width: 100% !important;
        width: 100% !important;
        padding: 0;
    }

    .history-title {
        font-size: 24px;
        margin-bottom: 24px;
        padding: 0 4px;
    }

    .user-info-banner {
        flex-direction: column;
        gap: 20px;
        text-align: center;
        padding: 20px 16px;
        margin-bottom: 24px;
    }

    .user-info-left {
        flex-direction: column;
    }

    .user-info-right {
        justify-content: center;
        flex-direction: row;
        gap: 24px;
        flex-wrap: wrap;
    }

    .user-stat {
        text-align: center;
    }

    .history-tabs {
        flex-wrap: nowrap;
        gap: 0;
        margin-bottom: 24px;
        padding: 0 4px;
    }

    .history-tab {
        flex: 1;
        padding: 12px 8px;
        font-size: 14px;
        text-align: center;
    }

    .history-section {
        padding: 16px;
        overflow-x: visible;
    }

    /* 모바일: 테이블 숨기고 카드 표시 */
    .table-wrapper {
        display: none;
    }

    .history-card {
        display: block;
    }

    .pagination-container {
        flex-wrap: wrap;
        padding: 16px 0;
        margin-top: 16px;
    }

    .pagination-btn {
        min-width: 32px;
        height: 32px;
        padding: 6px 10px;
        font-size: 13px;
    }

    .no-data {
        padding: 40px 20px;
        font-size: 14px;
    }
}
