.tdb-download-box {
    box-sizing: border-box;
    width: 100%;
    margin: 38px 0 24px;
    color: #142b45;
    font-family: inherit;
}

.tdb-download-box *,
.tdb-download-box *::before,
.tdb-download-box *::after {
    box-sizing: border-box;
}

.tdb-download-inner {
    position: relative;
    overflow: hidden;
    width: 100%;
    padding: 34px 28px 58px;
    border: 1px solid #acd9ff;
    border-radius: 20px;
    background:
        radial-gradient(circle at 52% 12%, rgba(255, 233, 214, .72), transparent 28%),
        linear-gradient(120deg, #f8fcff 0%, #eef8ff 55%, #f5fbff 100%);
    text-align: center;
}

.tdb-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 31px;
    padding: 6px 15px;
    border-radius: 999px;
    background: #e6f3ff;
    color: #0066b3;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
}

.tdb-heading {
    margin: 10px 0 15px !important;
    color: #172e49;
    font-size: clamp(27px, 4vw, 36px) !important;
    font-weight: 800 !important;
    line-height: 1.2 !important;
    letter-spacing: -.5px;
}

.tdb-file-card {
    display: flex;
    align-items: center;
    width: min(560px, 100%);
    min-height: 88px;
    margin: 0 auto;
    padding: 14px;
    border: 1px solid #c3e2fb;
    border-radius: 17px;
    background: rgba(255, 255, 255, .92);
    box-shadow: 0 8px 24px rgba(40, 118, 174, .06);
    text-align: left;
}

.tdb-file-icon {
    position: relative;
    display: flex;
    flex: 0 0 48px;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 58px;
    margin-right: 13px;
    overflow: hidden;
    border-radius: 10px;
    background: #e83232;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
}

.tdb-file-icon::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 15px;
    height: 15px;
    border-bottom-left-radius: 5px;
    background: #ff8d8d;
}

.tdb-file-icon span {
    position: relative;
    z-index: 1;
    max-width: 42px;
    padding-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tdb-file-info {
    display: block;
    min-width: 0;
}

.tdb-file-type {
    display: block;
    margin-bottom: 5px;
    color: #66748b;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.2;
}

.tdb-file-name {
    display: block;
    overflow: hidden;
    color: #0057a8;
    font-size: 16px;
    font-weight: 800;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.tdb-status {
    min-height: 24px;
    margin: 4px 0 7px !important;
    color: #71839b;
    font-size: 14px;
    line-height: 1.55;
}

.tdb-status.tdb-error {
    color: #b42318;
}

.tdb-action-wrap {
    position: relative;
    display: inline-flex;
    min-width: min(260px, 100%);
    min-height: 70px;
    align-items: center;
    justify-content: center;
    padding: 10px 17px;
    border: 2px solid rgba(255, 126, 31, .09);
    border-radius: 22px;
    background: rgba(255, 255, 255, .34);
    box-shadow: 0 13px 30px rgba(255, 115, 24, .15);
}

.tdb-download-button {
    display: inline-flex;
    width: 100%;
    min-height: 53px;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 28px;
    border: 0;
    border-radius: 13px;
    background: linear-gradient(135deg, #ff8b1a 0%, #ff6e16 100%);
    box-shadow: 0 10px 24px rgba(255, 112, 22, .24);
    color: #fff !important;
    font-size: 16px;
    font-weight: 800;
    line-height: 1.2;
    text-decoration: none !important;
    transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
}

.tdb-download-button[hidden] {
    display: none !important;
}

.tdb-download-button.tdb-is-waiting {
    pointer-events: none;
    cursor: wait;
    opacity: .88;
    filter: saturate(.9);
}

.tdb-download-button:hover,
.tdb-download-button:focus {
    color: #fff !important;
    filter: brightness(1.035);
    transform: translateY(-1px);
    box-shadow: 0 13px 28px rgba(255, 112, 22, .3);
}

.tdb-download-button:focus-visible {
    outline: 3px solid rgba(0, 102, 179, .3);
    outline-offset: 3px;
}

.tdb-download-icon {
    display: inline-flex;
    width: 22px;
    height: 22px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, .18);
}

.tdb-download-icon svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.tdb-loader {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(0, 102, 179, .18);
    border-top-color: #0877c8;
    border-radius: 50%;
    animation: tdb-spin .75s linear infinite;
}

.tdb-loader[hidden] {
    display: none !important;
}

.tdb-noscript {
    margin: 10px 0 0;
    color: #b42318;
    font-size: 14px;
}

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

@media (max-width: 640px) {
    .tdb-download-inner {
        padding: 28px 15px 38px;
        border-radius: 16px;
    }

    .tdb-heading {
        margin-top: 8px !important;
        font-size: 28px !important;
    }

    .tdb-file-card {
        min-height: 82px;
        padding: 12px;
        border-radius: 14px;
    }

    .tdb-file-icon {
        flex-basis: 44px;
        width: 44px;
        height: 54px;
        margin-right: 11px;
    }

    .tdb-file-name {
        font-size: 14px;
    }

    .tdb-action-wrap {
        width: 100%;
        min-width: 0;
    }
}

/* Trạng thái khởi đầu: nút mời người dùng bấm để bắt đầu đếm ngược. */
.tdb-download-button:not(.tdb-is-ready):not(.tdb-is-counting) {
    position: relative;
    overflow: hidden;
    animation: tdb-button-pulse 2.2s ease-in-out infinite;
}

.tdb-download-button:not(.tdb-is-ready):not(.tdb-is-counting)::before {
    content: "";
    position: absolute;
    top: -45%;
    left: -55%;
    width: 38%;
    height: 190%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .42), transparent);
    transform: rotate(18deg);
    animation: tdb-button-shine 2.8s ease-in-out infinite;
    pointer-events: none;
}

.tdb-download-button:not(.tdb-is-ready):not(.tdb-is-counting) .tdb-download-icon {
    animation: tdb-icon-bounce 1.7s ease-in-out infinite;
}

.tdb-download-button.tdb-is-ready {
    animation: tdb-ready-pop .45s ease-out both;
}

.tdb-action-wrap.tdb-is-counting {
    min-height: 70px;
}

.tdb-action-wrap.tdb-is-counting .tdb-loader {
    width: 34px;
    height: 34px;
    border-width: 4px;
    box-shadow: 0 0 0 7px rgba(255, 126, 31, .08);
}

.tdb-status[hidden] {
    display: none !important;
}

@keyframes tdb-button-pulse {
    0%, 100% {
        transform: translateY(0) scale(1);
        box-shadow: 0 10px 24px rgba(255, 112, 22, .24);
    }
    50% {
        transform: translateY(-2px) scale(1.012);
        box-shadow: 0 15px 34px rgba(255, 112, 22, .36);
    }
}

@keyframes tdb-button-shine {
    0%, 35% { left: -55%; }
    62%, 100% { left: 125%; }
}

@keyframes tdb-icon-bounce {
    0%, 100% { transform: translateY(0); }
    45% { transform: translateY(2px); }
    65% { transform: translateY(-2px); }
}

@keyframes tdb-ready-pop {
    0% { opacity: .35; transform: scale(.92); }
    70% { opacity: 1; transform: scale(1.035); }
    100% { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .tdb-download-button,
    .tdb-download-button::before,
    .tdb-download-icon,
    .tdb-loader {
        animation: none !important;
        transition: none !important;
    }
}


/* 1.3.0: chỉ tính thời gian khi tab hoạt động và khu vực tải đang nằm trong màn hình. */
.tdb-action-wrap.tdb-is-paused .tdb-loader {
    opacity: .48;
    animation-play-state: paused;
}

.tdb-download-box.tdb-is-paused .tdb-action-wrap {
    box-shadow: 0 9px 22px rgba(20, 43, 69, .1);
}

.tdb-download-box.tdb-is-paused .tdb-status {
    color: #a15c00;
    font-weight: 700;
}
