/* --- GLOBAL STYLES & SHARED CONTAINERS --- */
.apdf-credit-page, .apdf-form-wrap {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    background-color: #f8f9fa;
    padding: 24px;
    border-radius: 12px;
    border: 1px solid #e9ecef;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}
#apdf-result-wrapper {
    margin-top: 24px;
}
.apdf-error {
    color: #dc3545;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    padding: 16px;
    border-radius: 8px;
}
.apdf-result-table {
    width: 100%;
    border-collapse: collapse;
    background-color: #fff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    overflow: hidden;
}
.apdf-result-table th, .apdf-result-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
    vertical-align: top;
}
.apdf-result-table tr:last-child th, .apdf-result-table tr:last-child td {
    border-bottom: none;
}
.apdf-result-table th {
    font-weight: 600;
    color: #495057;
    background-color: #f8f9fa;
    width: 150px;
}

/* --- TABS (Credit Page) --- */
.apdf-sub-tabs-front {
    border-bottom: 2px solid #dee2e6;
    margin-bottom: 24px;
}
.apdf-sub-tabs-front a {
    display: inline-block;
    padding: 12px 20px;
    text-decoration: none;
    color: #495057;
    border: 2px solid transparent;
    margin-bottom: -2px;
    font-weight: 600;
    transition: all 0.2s ease-in-out;
}
.apdf-sub-tabs-front a:hover {
    color: #0056b3;
}
.apdf-sub-tabs-front a.active {
    border-color: #007bff #007bff #fff;
    border-radius: 8px 8px 0 0;
    color: #007bff;
    background-color: #fff;
}

/* --- FETCHER FORM STYLES --- */
.apdf-form-wrap {
    background-color: #ffffff;
}
.apdf-form-wrap .apdf-form-row {
    margin-bottom: 20px;
}
.apdf-form-wrap label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #343a40;
}
.apdf-form-wrap .apdf-input {
    width: 100%;
    padding: 9px 16px;
    border: 1px solid #ced4da;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.apdf-form-wrap .apdf-input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
    outline: none;
}
.apdf-form-actions {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 24px;
}
.apdf-form-actions label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 0; /* Override default */
}
#apdf-submit-btn, #apdf-rewrite-btn {
    padding: 12px 28px;
    font-size: 1em;
    font-weight: 600;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
}
#apdf-submit-btn {
    background-color: #007bff;
}
#apdf-submit-btn:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
}
#apdf-rewrite-btn {
    background-color: #28a745;
}
#apdf-rewrite-btn:hover {
    background-color: #218838;
    transform: translateY(-2px);
}
#apdf-rewrite-btn:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
    transform: none;
}
.apdf-loading {
    font-style: italic;
    color: #6c757d;
}

/* --- NEW: COMPARISON LAYOUT --- */
#apdf-rewrite-result-container {
    margin-bottom: 24px;
    padding: 20px;
    background-color: #f2faf5;
    border: 1px solid #c3e6cb;
    border-radius: 8px;
}
#apdf-rewrite-result-container h3 {
    margin-top: 0;
    color: #155724;
}
#apdf-rewrite-result {
    line-height: 1.6;
    white-space: pre-wrap;
    max-height: 500px; /* Giới hạn chiều cao tối đa là 500px, bạn có thể thay đổi số này */
    overflow-y: auto; /* Tự động thêm thanh trượt dọc khi nội dung dài hơn max-height */
    padding: 15px;    /* Thêm khoảng đệm bên trong để dễ nhìn hơn */
    border-radius: 8px;
    border: 1px solid #dce6df;
    background-color: #ffffff;
}

.apdf-ai-row {
    margin-bottom: 24px;
    padding: 20px;
    background-color: #fdfdff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}
.apdf-ai-row h3 {
    margin-top: 0;
    color: #004085;
}
.apdf-ai-content {
    line-height: 1.6;
}

.apdf-compare-results {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}
.apdf-result-col h3 {
    margin-top: 0;
    border-bottom: 2px solid #dee2e6;
    padding-bottom: 8px;
    margin-bottom: 16px;
    font-size: 1.2em;
}


/* --- RECHARGE CREDIT TAB --- */
.apdf-current-balance {
    background-color: #ffffff;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #dee2e6;
    margin-bottom: 24px;
    font-size: 1.1em;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}
.apdf-current-balance span {
    font-weight: 700;
    color: #007bff;
    font-size: 1.2em;
}
.apdf-pack-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 24px;
}
.apdf-pack {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
}
.apdf-pack:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}
.apdf-pack h4 {
    margin: 0 0 8px 0;
    font-size: 1.5em;
    color: #343a40;
    flex-grow: 1;
}
.apdf-pack p:first-of-type {
    font-size: 1.1em;
    color: #6c757d;
    margin: 0 0 16px 0;
}
.apdf-pack p:nth-of-type(2) {
    font-size: 2em;
    font-weight: 700;
    color: #28a745;
    margin: 0 0 24px 0;
}
.apdf-pack .apdf-buy-vietqr {
    width: 100%;
    padding: 12px;
    font-size: 1em;
    font-weight: 600;
    color: #fff;
    background-color: #007bff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-top: auto;
    transition: background-color 0.2s ease;
}
.apdf-pack .apdf-buy-vietqr:hover {
    background-color: #0056b3;
}

/* --- TRANSACTION HISTORY TAB --- */
.apdf-history-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
    margin-bottom: 24px;
    padding: 20px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
}
.apdf-history-filters .filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.apdf-history-filters label {
    font-size: 14px;
    font-weight: 600;
    color: #495057;
}
.apdf-history-filters input[type="date"] {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    background-color: #fff;
    color: #495057;
}
.apdf-history-filters .filter-actions {
    display: flex;
    gap: 10px;
}
.apdf-history-filters .button, .apdf-history-filters .button-reset {
    padding: 9px 16px;
    text-decoration: none;
    cursor: pointer;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid;
    transition: all 0.2s ease;
}
.apdf-history-filters .button {
    background: #28a745;
    border-color: #28a745;
    color: #fff;
}
.apdf-history-filters .button:hover {
    background: #218838;
}
.apdf-history-filters .button-reset {
    background: transparent;
    border-color: #6c757d;
    color: #6c757d;
}
.apdf-history-filters .button-reset:hover {
    background: #6c757d;
    color: #fff;
}
.apdf-credit-history-table {
    width: 100%;
    border-collapse: collapse;
}
.apdf-credit-history-table th, .apdf-credit-history-table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}
.apdf-credit-history-table thead th {
    background-color: #e9ecef;
    font-weight: 600;
    color: #495057;
}
.apdf-credit-history-table tbody tr:last-child td {
    border-bottom: none;
}
.apdf-credit-history-table tbody tr:hover {
    background-color: #f8f9fa;
}
.apdf-credit-change-plus { color: #28a745; font-weight: 700; }
.apdf-credit-change-minus { color: #dc3545; font-weight: 700; }

/* --- PAGINATION & DELETE --- */
.apdf-pagination {
    margin-top: 24px;
    text-align: center;
}
.apdf-pagination .page-numbers {
    padding: 8px 14px;
    margin: 0 4px;
    border: 1px solid #dee2e6;
    text-decoration: none;
    border-radius: 6px;
    color: #007bff;
    transition: all 0.2s ease;
}
.apdf-pagination .page-numbers:hover { background: #e9ecef; }
.apdf-pagination .page-numbers.current {
    background: #007bff;
    color: #fff;
    border-color: #007bff;
}
.apdf-delete-history-wrap {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px dashed #ced4da;
    text-align: right;
}
.apdf-delete-history-wrap .button-delete {
    background: #dc3545;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s ease;
}
.apdf-delete-history-wrap .button-delete:hover { background: #c82333; }

/* --- VietQR MODAL --- */
#apdf-qr-modal{position:fixed;inset:0;background:rgba(0,0,0,.6);display:flex;align-items:center;justify-content:center;z-index:99999; backdrop-filter:blur(5px); opacity: 0; visibility: hidden; transition: opacity 0.2s ease, visibility 0.2s ease;}
#apdf-qr-modal.apdf-modal-show { opacity: 1; visibility: visible; }
#apdf-qr-modal .apdf-qr-card{background:#fff;max-width:460px;width:90%;margin:5% auto;padding:24px;border-radius:12px;position:relative; box-shadow: 0 10px 30px rgba(0,0,0,0.1);}
#apdf-qr-modal .apdf-close{position:absolute;right:12px;top:12px;font-size:24px;background:transparent;border:none;cursor:pointer;color:#6c757d;}
#apdf-qr-img{width:100%;height:auto;display:block;border:1px solid #e5e7eb;border-radius:8px; margin-bottom: 16px;}
.apdf-qr-info p{margin:10px 0; font-size: 1.1em;}
.apdf-qr-info strong { color: #343a40; }
.apdf-qr-info .apdf-copy{margin-left:8px; padding: 4px 8px; border-radius: 4px; background: #e9ecef; border: 1px solid #dee2e6; cursor: pointer;}
.apdf-qr-info .apdf-paid-btn { width: 100%; margin-top: 10px; padding: 12px; font-size: 1em; font-weight: 600; color: #fff; background-color: #28a745; border: none; border-radius: 8px; cursor: pointer; }

/* --- RESPONSIVE DESIGN --- */
@media (max-width: 992px) {
    .apdf-pack-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 768px) {
    .apdf-credit-page, .apdf-form-wrap { padding: 16px; }
    .apdf-pack-grid {
        grid-template-columns: 1fr;
    }
    .apdf-compare-results {
        grid-template-columns: 1fr; /* Stack columns on smaller screens */
    }
    .apdf-history-filters { flex-direction: column; align-items: stretch; }
    .apdf-history-filters .filter-actions { justify-content: flex-end; }
    
    .apdf-credit-history-table thead { display: none; }
    .apdf-credit-history-table tr {
        display: block;
        margin-bottom: 16px;
        padding: 16px;
        border: 1px solid #dee2e6;
        border-radius: 8px;
        background: #fff;
    }
    .apdf-credit-history-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
        border-bottom: 1px dotted #e9ecef;
    }
    .apdf-credit-history-table td:last-child { border-bottom: none; }
    .apdf-credit-history-table td::before {
        content: attr(data-label);
        font-weight: 600;
        margin-right: 16px;
        color: #495057;
    }
}