:root {
    --primary: #e85d04;
    --primary-dark: #dc2f02;
    --bg: #fafaf9;
    --bg-card: #fff;
    --text: #1c1917;
    --text-secondary: #57534e;
    --text-muted: #78716c;
    --border: rgba(0,0,0,.06);
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 4px 24px rgba(0,0,0,.06);
    --ease-out: cubic-bezier(.33,1,.68,1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter',sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 1rem;
    line-height: 1.6;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px)
    }
    to {
        opacity: 1;
        transform: translateY(0)
    }
}

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

.header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--text);
}

.logo-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.logo-icon img {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

.apma-title {
    font-size: 1.1rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .02em;
    color: var(--primary);
}

.main {
    flex: 1;
    padding: 0 1.5rem 2rem;
    max-width: 560px;
    margin: 0 auto;
    width: 100%;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    border: 1px solid var(--border);
    animation: fadeInUp .5s var(--ease-out) both;
}

.link-input-wrap {
    position: relative;
    margin-bottom: 1rem;
}

.link-input-wrap input {
    width: 100%;
    padding: 1rem 1.1rem;
    padding-right: 48px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .95rem;
    font-family: inherit;
    background: var(--bg-card);
}

.link-input-wrap input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(232,93,4,.12);
}

.btn-paste-inside {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-paste-inside:hover {
    color: var(--primary);
    background: rgba(232,93,4,.08);
}

.btn-paste-inside svg {
    width: 20px;
    height: 20px;
}

.btn-convert-main {
    position: relative;
    width: 100%;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg,var(--primary),var(--primary-dark));
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    cursor: pointer;
    margin-top: .5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    transition: opacity .2s ease;
}

.btn-convert-main:hover:not(:disabled) {
    transform: translateY(-2px);
}

.btn-convert-main:disabled {
    opacity: .7;
    cursor: not-allowed;
}

.btn-convert-main .btn-spinner {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    margin: auto;
    width: 22px;
    height: 22px;
    border: 2px solid rgba(255,255,255,.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

.btn-convert-main .btn-convert-text {
    transition: visibility .15s ease;
}

.btn-convert-main.is-loading .btn-convert-text {
    visibility: hidden;
}

.btn-convert-main.is-loading .btn-spinner {
    display: block;
}

.result-card {
    margin-top: 1.5rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    border-top: 4px solid var(--primary);
    overflow: hidden;
    animation: fadeInUp .5s var(--ease-out) both;
}

.result-card.hidden {
    display: none;
}

.result-product {
    display: flex;
    gap: 1.25rem;
    padding: 1.5rem 1.5rem;
    min-height: 120px;
    align-items: flex-start;
    background: linear-gradient(180deg,rgba(250,250,249,.6) 0%,transparent 100%);
    border-bottom: 1px solid var(--border);
}

.result-product-img {
    width: 96px;
    height: 96px;
    min-width: 96px;
    position: relative;
    background: linear-gradient(145deg,#f5f5f4,#eae8e6);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
    flex-shrink: 0;
}

.result-product-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.result-product-img.is-loading::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg,#f0f0ef 25%,#e7e5e4 50%,#f0f0ef 75%);
    background-size: 200% 100%;
    animation: shimmer .8s ease-in-out infinite;
}

@keyframes shimmer {
    to {
        background-position: -200% 0
    }
}

.result-product-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.result-product-desc {
    font-size: .9375rem;
    font-weight: 500;
    color: var(--text);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3; /* Bổ sung thêm dòng này */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.result-done {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-size: .8125rem;
    font-weight: 600;
    color: #166534;
    background: rgba(34,197,94,.12);
    padding: .35rem .65rem;
    border-radius: 999px;
    width: fit-content;
}

.result-done.hidden {
    display: none;
}

.result-error {
    margin: 0;
    font-size: .875rem;
    font-weight: 500;
    color: #b91c1c;
    padding: .4rem 0;
    line-height: 1.4;
}

.result-card.has-error {
    border-top-color: #ef4444;
}

.result-card.has-error .result-product {
    border-bottom-color: rgba(239,68,68,.2);
    background: linear-gradient(180deg,rgba(254,226,226,.15) 0%,transparent 100%);
}

.btn-copy-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    width: calc(100% - 3rem);
    margin: 0 1.5rem 1.25rem;
    padding: .85rem 1.5rem;
    background: #f5f5f4;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--primary);
    cursor: pointer;
}

.btn-copy-link:hover {
    background: #fef3c7;
}

.btn-copy-link.has-link {
    background: linear-gradient(135deg,var(--primary),var(--primary-dark));
    color: #fff;
    border-color: transparent;
}

.btn-copy-link.has-link:hover {
    opacity: .95;
}

.btn-copy-link.copied {
    background: #15803d;
    color: #fff;
    border-color: transparent;
}

.btn-copy-link:disabled {
    opacity: .6;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-copy-link .copy-icon {
    font-size: 1.1em;
    opacity: .95;
}

.tip-box {
    margin: 12px 1.5rem 1rem;
    padding: 12px 1.25rem;
    background: #fff9f0;
    border: 1px dashed #ffab91;
    border-radius: 12px;
    font-size: 13px;
    color: #444;
    line-height: 1.6;
}

.tip-box .tip-icon {
    vertical-align: middle;
    margin-right: 2px;
}

.tip-box .tip-copy-trigger {
    color: #ee4d2d;
    cursor: pointer;
    text-decoration: none;
    font-weight: 700;
}

.tip-box .tip-copy-trigger:hover {
    text-decoration: underline;
}

.tip-box .tip-fb-link {
    color: #007bff;
    text-decoration: none;
    word-break: break-all;
    display: inline-block;
    margin: 4px 0;
}

.tip-box .tip-fb-link:hover {
    text-decoration: underline;
}

.tip-box .voucher-img {
    width: 100%;
    margin-top: 10px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,.1);
    border: 1px solid #eee;
    display: block;
}

.contact-section {
    padding: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    justify-content: center;
}

.btn-zalo {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .75rem 1.5rem;
    background: #0068ff;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: .95rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.btn-help {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .75rem 1.5rem;
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: .95rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.toast-wrap {
    position: fixed;
    top: 1rem;
    right: 1rem;
    left: auto;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    max-width: calc(100vw - 2rem);
}

.toast {
    padding: .75rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-weight: 500;
    box-shadow: 0 10px 40px rgba(0,0,0,.12);
    opacity: 0;
    transform: translateX(100%);
    transition: opacity .3s,transform .3s;
    max-width: 100%;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.45;
}

.toast.show {
    opacity: 1;
    transform: translateX(0)
}

.toast.success {
    background: #fff;
    color: #15803d;
    border-left: 4px solid #22c55e;
}

.toast.error {
    background: #fff;
    color: #b91c1c;
    border-left: 4px solid #ef4444;
}

.footer {
    text-align: center;
    padding: 1.25rem;
    font-size: .85rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    background: var(--bg-card);
}

.guide-section {
    margin-top: 1rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

.guide-section.hidden {
    display: none !important;
}

.guide-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: 1rem 1.25rem;
    background: transparent;
    border: none;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    text-align: left;
    transition: background .2s ease;
}

.guide-toggle:hover {
    background: rgba(232,93,4,.06);
}

.guide-toggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.guide-toggle .guide-heading-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .15rem;
}

.guide-toggle .guide-heading-sub {
    font-size: .8rem;
    font-weight: 500;
    color: var(--text-muted);
}

.guide-toggle .guide-chevron {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    transition: transform .3s var(--ease-out);
    border-radius: 8px;
    background: rgba(232,93,4,.08);
}

.guide-section.is-open .guide-chevron {
    transform: rotate(180deg);
}

.guide-content {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height .35s var(--ease-out),opacity .25s ease,padding .25s ease;
}

.guide-section.is-open .guide-content {
    overflow-y: auto;
}

.guide-content-inner {
    padding: 0 1.25rem 1.25rem;
}

.guide-step {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
    padding: .75rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--bg);
    border: 1px solid var(--border);
    transition: background .2s ease;
}

.guide-step:last-child {
    margin-bottom: 0;
}

.guide-step:hover {
    background: rgba(232,93,4,.04);
}

.guide-step-num {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg,var(--primary),var(--primary-dark));
    color: #fff;
    font-size: .9rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}

.guide-step-text {
    flex: 1;
    font-size: .9375rem;
    color: var(--text-secondary);
    line-height: 1.65;
}

.guide-step-text strong {
    color: var(--text);
}

.guide-step-text a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

.guide-step-text a:hover {
    text-decoration: underline;
}

.guide-note {
    margin-top: 1rem;
    padding: .85rem 1rem;
    background: rgba(234,179,8,.1);
    border: 1px solid rgba(234,179,8,.35);
    border-radius: var(--radius-sm);
    font-size: .875rem;
    color: var(--text-secondary);
    line-height: 1.6;
    display: flex;
    gap: .5rem;
    align-items: flex-start;
}

.guide-note-icon {
    flex-shrink: 0;
    font-size: 1.1rem;
}

.guide-note strong {
    color: var(--text);
}

.guide-section.is-open .guide-content {
    max-height: min(560px,85vh);
    opacity: 1;
}

.copy-fallback {
    margin: 0 1.5rem 1rem;
    padding: .75rem;
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: var(--radius-sm);
}

.copy-fallback.hidden {
    display: none;
}

.copy-fallback-hint {
    font-size: .8125rem;
    color: #92400e;
    margin: 0 0 .5rem;
    line-height: 1.4;
}

.copy-fallback-input {
    width: 100%;
    padding: .6rem .75rem;
    font-size: .875rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    -webkit-user-select: text;
    user-select: text;
}

@media(max-width: 480px) {
    .link-input-wrap input {
        padding-right:48px
    }
    .btn-paste-inside {
        right: 4px
    }
    .btn-copy-link {
        width: calc(100% - 2rem);
        margin-left: 1rem;
        margin-right: 1rem
    }
    .result-product {
        flex-direction: row;
        gap: 1rem;
        padding: 1.25rem 1.25rem;
        min-height: 100px
    }
    .result-product-img {
        width: 80px;
        height: 80px;
        min-width: 80px;
        border-radius: 10px
    }
    .result-product-desc {
    font-size: .9rem;
    -webkit-line-clamp: 2;
    line-clamp: 2; /* Bổ sung thêm dòng này */
}
    .toast-wrap {
        left: 1rem;
        right: 1rem;
        max-width: none
    }
    .toast {
        max-width: 100%;
        min-width: 0
    }
}