/**
 * Trang trả góp /tra-gop/{slug}/
 */

:root {
    --dsi-primary: #e8590c;
    --dsi-primary-dark: #d9480f;
    --dsi-primary-bg: #fff5f0;
    --dsi-text: #212529;
    --dsi-text-muted: #868e96;
    --dsi-border: #dee2e6;
    --dsi-bg: #f8f9fa;
    --dsi-white: #fff;
    --dsi-success: #2b8a3e;
    --dsi-radius: 8px;
}

/* ===== Page Layout ===== */
.dsi-installment-page {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 16px 60px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    color: var(--dsi-text);
}

/* ===== Header ===== */
.dsi-header {
    text-align: center;
    margin-bottom: 28px;
    padding-bottom: 16px;
    border-bottom: 3px solid var(--dsi-primary);
}

.dsi-header__title {
    font-size: 26px;
    font-weight: 700;
    color: var(--dsi-primary);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== Product Info ===== */
.dsi-product-info {
    background: var(--dsi-white);
    border: 1px solid var(--dsi-border);
    border-radius: var(--dsi-radius);
    margin-bottom: 32px;
    overflow: hidden;
}

.dsi-product-info__label {
    background: var(--dsi-bg);
    padding: 12px 20px;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    color: var(--dsi-text-muted);
    border-bottom: 1px solid var(--dsi-border);
}

.dsi-product-info__content {
    display: flex;
    gap: 24px;
    padding: 20px;
}

.dsi-product-info__image {
    flex: 0 0 200px;
}

.dsi-product-info__image img {
    width: 100%;
    height: auto;
    border-radius: 6px;
    border: 1px solid var(--dsi-border);
}

.dsi-product-info__details {
    flex: 1;
}

.dsi-product-info__name {
    font-size: 17px;
    font-weight: 700;
    margin: 0 0 8px;
    line-height: 1.4;
    text-transform: uppercase;
}

.dsi-product-info__price {
    font-size: 22px;
    font-weight: 700;
    color: var(--dsi-primary);
    margin-bottom: 16px;
}

.dsi-product-info__price del {
    color: var(--dsi-text-muted);
    font-size: 16px;
    font-weight: 400;
}

/* ===== Variations ===== */
.dsi-variation-group {
    margin-bottom: 12px;
}

.dsi-variation-group__label {
    font-weight: 600;
    font-size: 14px;
    display: block;
    margin-bottom: 6px;
}

.dsi-variation-group__options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.dsi-variation-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 16px;
    border: 2px solid var(--dsi-border);
    border-radius: 6px;
    background: var(--dsi-white);
    cursor: pointer;
    transition: all 0.15s ease;
    min-width: 100px;
    font-family: inherit;
    font-size: 13px;
}

.dsi-variation-option:hover {
    border-color: var(--dsi-primary);
}

.dsi-variation-option--active {
    border-color: var(--dsi-primary);
    background: var(--dsi-primary-bg);
    box-shadow: 0 0 0 1px var(--dsi-primary);
}

.dsi-variation-option__name {
    font-weight: 600;
}

.dsi-variation-option__price {
    font-size: 12px;
    color: var(--dsi-text-muted);
}

/* ===== Quantity ===== */
.dsi-product-info__quantity {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
}

.dsi-product-info__quantity label {
    font-weight: 600;
    font-size: 14px;
}

.dsi-qty-control {
    display: flex;
    align-items: center;
    border: 1px solid var(--dsi-border);
    border-radius: 6px;
    overflow: hidden;
}

.dsi-qty-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--dsi-bg);
    font-size: 18px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}

.dsi-qty-btn:hover {
    background: var(--dsi-border);
}

.dsi-qty-input {
    width: 50px;
    height: 36px;
    text-align: center;
    border: none;
    border-left: 1px solid var(--dsi-border);
    border-right: 1px solid var(--dsi-border);
    font-size: 14px;
    font-weight: 600;
    -moz-appearance: textfield;
}

.dsi-qty-input::-webkit-outer-spin-button,
.dsi-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ===== Section Title ===== */
.dsi-section-title {
    text-align: center;
    font-size: 20px;
    font-weight: 700;
    color: var(--dsi-primary);
    margin: 0 0 24px;
    text-transform: uppercase;
}

/* ===== Steps ===== */
.dsi-step {
    background: var(--dsi-white);
    border: 1px solid var(--dsi-border);
    border-radius: var(--dsi-radius);
    margin-bottom: 20px;
    overflow: hidden;
}

.dsi-step__header {
    background: var(--dsi-bg);
    padding: 12px 20px;
    font-weight: 700;
    font-size: 14px;
    text-transform: uppercase;
    color: var(--dsi-text);
    border-bottom: 1px solid var(--dsi-border);
}

/* ===== Bank Grid ===== */
.dsi-bank-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    padding: 16px;
}

.dsi-bank-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 8px;
    border: 2px solid var(--dsi-border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    background: var(--dsi-white);
    min-height: 56px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
}

.dsi-bank-item:hover {
    border-color: var(--dsi-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.dsi-bank-item--active {
    border-color: var(--dsi-primary);
    background: var(--dsi-primary-bg);
    box-shadow: 0 0 0 1px var(--dsi-primary);
}

.dsi-bank-item img {
    max-width: 100%;
    max-height: 32px;
    object-fit: contain;
}

/* ===== Card Grid ===== */
.dsi-card-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px;
}

.dsi-card-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: 2px solid var(--dsi-border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    background: var(--dsi-white);
    min-width: 120px;
    min-height: 52px;
    font-weight: 700;
    font-size: 14px;
}

.dsi-card-item:hover {
    border-color: var(--dsi-primary);
}

.dsi-card-item--active {
    border-color: var(--dsi-primary);
    background: var(--dsi-primary-bg);
    box-shadow: 0 0 0 1px var(--dsi-primary);
}

.dsi-card-item img {
    max-height: 28px;
    object-fit: contain;
}

/* ===== Period Table ===== */
.dsi-period-table-wrap {
    padding: 16px;
    overflow-x: auto;
}

.dsi-period-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.dsi-period-table th {
    background: var(--dsi-bg);
    padding: 10px 12px;
    text-align: left;
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    color: var(--dsi-text-muted);
    border-bottom: 2px solid var(--dsi-border);
}

.dsi-period-table td {
    padding: 12px;
    border-bottom: 1px solid var(--dsi-border);
}

.dsi-period-table tr:hover td {
    background: var(--dsi-primary-bg);
}

.dsi-period-table tr.dsi-period-row--active td {
    background: var(--dsi-primary-bg);
    font-weight: 600;
}

.dsi-period-select-btn {
    padding: 6px 16px;
    border: 2px solid var(--dsi-primary);
    border-radius: 4px;
    background: transparent;
    color: var(--dsi-primary);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.dsi-period-select-btn:hover,
.dsi-period-select-btn--active {
    background: var(--dsi-primary);
    color: var(--dsi-white);
}

/* ===== Buyer Form ===== */
.dsi-buyer-form {
    padding: 20px;
}

.dsi-form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.dsi-form-group {
    flex: 1;
}

.dsi-form-group--full {
    flex: 0 0 100%;
}

.dsi-form-group label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 4px;
    color: var(--dsi-text);
}

.dsi-form-group label .required {
    color: #e03131;
}

.dsi-form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--dsi-border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s;
    box-sizing: border-box;
}

.dsi-form-group input:focus {
    outline: none;
    border-color: var(--dsi-primary);
    box-shadow: 0 0 0 3px rgba(232, 89, 12, 0.1);
}

/* ===== Summary ===== */
.dsi-summary {
    background: var(--dsi-white);
    border: 2px solid var(--dsi-primary);
    border-radius: var(--dsi-radius);
    padding: 24px;
    margin-top: 24px;
}

.dsi-summary__row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 14px;
}

.dsi-summary__row--highlight {
    margin-top: 8px;
    padding-top: 12px;
    border-top: 2px solid var(--dsi-border);
    font-size: 18px;
    color: var(--dsi-primary);
}

/* ===== Buttons ===== */
.dsi-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 6px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.dsi-btn--primary {
    background: linear-gradient(135deg, var(--dsi-primary), var(--dsi-primary-dark));
    color: var(--dsi-white);
    font-size: 16px;
    padding: 14px 32px;
}

.dsi-btn--primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(232, 89, 12, 0.4);
}

.dsi-btn--primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.dsi-btn--secondary {
    background: var(--dsi-bg);
    color: var(--dsi-text);
    border: 1px solid var(--dsi-border);
    padding: 10px 20px;
    font-size: 14px;
}

.dsi-btn--lg {
    width: 100%;
    margin-top: 20px;
    font-size: 18px;
    padding: 16px;
}

/* ===== Loading ===== */
.dsi-loading {
    text-align: center;
    padding: 48px 16px;
}

.dsi-loading__spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--dsi-border);
    border-top-color: var(--dsi-primary);
    border-radius: 50%;
    animation: dsi-spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes dsi-spin {
    to { transform: rotate(360deg); }
}

.dsi-loading p {
    color: var(--dsi-text-muted);
    font-size: 14px;
}

/* ===== Error ===== */
.dsi-error {
    text-align: center;
    padding: 32px 16px;
    background: #fff5f5;
    border: 1px solid #ffc9c9;
    border-radius: var(--dsi-radius);
}

.dsi-error p {
    color: #c92a2a;
    margin-bottom: 12px;
}

/* ===== Note ===== */
.dsi-note {
    margin-top: 16px;
    padding: 12px 16px;
    background: #fff3bf;
    border: 1px solid #ffd43b;
    border-radius: 6px;
    font-size: 13px;
    text-align: center;
    line-height: 1.5;
}

.dsi-note a {
    color: var(--dsi-primary);
    font-weight: 700;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .dsi-product-info__content {
        flex-direction: column;
    }

    .dsi-product-info__image {
        flex: 0 0 auto;
        max-width: 200px;
        margin: 0 auto;
    }

    .dsi-bank-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .dsi-form-row {
        flex-direction: column;
        gap: 12px;
    }

    .dsi-period-table th:nth-child(3),
    .dsi-period-table td:nth-child(3) {
        display: none; /* Ẩn cột "Tổng thanh toán" trên mobile */
    }
}

@media (max-width: 480px) {
    .dsi-bank-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dsi-header__title {
        font-size: 20px;
    }
}
