* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: Arial, sans-serif; background: #f5f5f5; padding: 16px; }
.container { max-width: 800px; margin: 0 auto; background: #fff; border-radius: 8px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
h1 { color: #ee4d2d; font-size: 22px; margin-bottom: 24px; }

/* ── Thông báo ── */
.flash { padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 12px; overflow-wrap: anywhere; }
.flash.ok { background: #f0f9f4; border: 1px solid #b7e4c7; color: #1a7a45; }
.flash.error { background: #fdf0ee; border: 1px solid #f5c6c0; color: #c0392b; }
.error { color: #c0392b; background: #fdf0ee; border: 1px solid #f5c6c0; border-radius: 4px; padding: 12px; overflow-wrap: anywhere; }
.error-action { display: inline-block; margin-top: 10px; background: #ee4d2d; color: #fff; border-radius: 4px; padding: 7px 14px; font-size: 13px; text-decoration: none; }
.error-action:hover { background: #d73211; }
.redirect-note { background: #f0f9f4; border: 1px solid #b7e4c7; border-radius: 6px; padding: 10px 14px; margin-bottom: 12px; font-size: 13px; color: #1a7a45; overflow-wrap: anywhere; }
.cache-note { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; background: #fff8e6; border: 1px solid #ffe0a3; border-radius: 6px; padding: 8px 12px; margin-top: 12px; font-size: 13px; color: #8a6100; }
.empty-note { color: #999; font-size: 13px; padding: 14px; border: 1px dashed #ddd; border-radius: 6px; text-align: center; }

/* ── Form ── */
.form-group { display: flex; gap: 10px; margin-bottom: 20px; }
input[type="text"] { flex: 1; padding: 10px 14px; border: 1px solid #ddd; border-radius: 4px; font-size: 16px; }
input[type="text"]:focus { outline: none; border-color: #ee4d2d; }
button { padding: 10px 24px; background: #ee4d2d; color: #fff; border: none; border-radius: 4px; font-size: 14px; cursor: pointer; white-space: nowrap; }
button:hover { background: #d73211; }
.search-form { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.search-form input { flex: 1; padding: 8px 12px; border: 1px solid #ddd; border-radius: 4px; font-size: 14px; }
.search-form input:focus { outline: none; border-color: #ee4d2d; }

/* ── Nút phụ ── */
.copy-btn { padding: 5px 14px; background: #ee4d2d; color: #fff; border: none; border-radius: 4px; font-size: 13px; cursor: pointer; white-space: nowrap; flex-shrink: 0; }
.copy-btn:hover { background: #d73211; }
.copy-btn.copied { background: #27ae60; }
.open-btn { padding: 5px 14px; background: #fff; color: #ee4d2d; border: 1px solid #ee4d2d; border-radius: 4px; font-size: 13px; text-decoration: none; white-space: nowrap; flex-shrink: 0; line-height: 1.5; }
.open-btn:hover { background: #fff1ee; }
.link-btn { background: none; border: none; color: #ee4d2d; font-size: 13px; cursor: pointer; padding: 4px 6px; text-decoration: underline; }
.link-btn.danger { color: #c0392b; }

/* ── Kết quả ── */
.section-title { font-size: 13px; font-weight: 600; color: #555; margin-bottom: 8px; margin-top: 20px; text-transform: uppercase; letter-spacing: 0.5px; }
.info-card { border: 1px solid #e0e0e0; border-radius: 8px; overflow: hidden; margin-top: 4px; }
.info-row { display: flex; align-items: flex-start; padding: 10px 14px; border-bottom: 1px solid #f0f0f0; gap: 10px; flex-wrap: wrap; }
.info-row:last-child { border-bottom: none; }
.info-label { font-size: 13px; color: #888; min-width: 140px; }
.info-value { font-size: 14px; color: #222; font-weight: 500; flex: 1; overflow-wrap: anywhere; min-width: 0; }
.share-url-row { background: #fff8f6; }
.share-url-row .info-value { color: #ee4d2d; font-weight: 600; }

/* ── Sản phẩm ── */
.product-card { display: flex; gap: 14px; align-items: center; border: 1px solid #e0e0e0; border-radius: 8px; padding: 12px; }
.product-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; flex-shrink: 0; background: #f5f5f5; }
.product-meta { min-width: 0; }
.product-title { font-size: 14px; font-weight: 600; color: #222; line-height: 1.4; overflow-wrap: anywhere; }
.product-ids { font-size: 12px; color: #999; margin-top: 4px; }

/* ── Danh sách đã lưu ── */
.saved-list { display: flex; flex-direction: column; gap: 8px; }
.saved-item { display: flex; gap: 12px; align-items: center; border: 1px solid #eee; border-radius: 8px; padding: 10px; }
.saved-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; flex-shrink: 0; background: #f5f5f5; }
.saved-meta { flex: 1; min-width: 0; }
.saved-title { font-size: 13px; font-weight: 600; color: #333; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-title.missing { color: #aaa; font-weight: 400; font-style: italic; }
.saved-link { font-size: 13px; color: #ee4d2d; overflow-wrap: anywhere; }
.saved-sub { font-size: 11px; color: #aaa; margin-top: 2px; }
.saved-actions { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; flex-shrink: 0; }
.saved-buttons { display: flex; gap: 4px; }

/* ── Toast ── */
.toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); background: #27ae60; color: #fff; padding: 10px 24px; border-radius: 24px; font-size: 14px; opacity: 0; transition: opacity 0.3s; pointer-events: none; z-index: 999; }
.toast.show { opacity: 1; }

@media (max-width: 480px) {
    .form-group { flex-direction: column; }
    .info-label { min-width: 100%; color: #aaa; font-size: 12px; }
    .share-url-row { flex-direction: column; align-items: stretch; }
    .share-url-row .info-value { min-width: 100%; }
    .copy-btn { width: 100%; text-align: center; padding: 8px; }
    .share-url-row .open-btn { width: 100%; text-align: center; padding: 8px; }
    .saved-item { flex-wrap: wrap; }
    .saved-actions { flex-direction: row; width: 100%; justify-content: flex-end; }
    .saved-actions .copy-btn { width: auto; }
}

/* ── Trạng thái đang xử lý ── */
@keyframes spin { to { transform: rotate(360deg); } }

/* Nút đang chờ server: chèn vòng xoay trước nhãn, khoá tương tác */
button.is-loading { position: relative; opacity: 0.85; cursor: progress; pointer-events: none; }
button.is-loading::before {
    content: ''; display: inline-block; width: 13px; height: 13px; margin-right: 8px;
    vertical-align: -2px; border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff;
    border-radius: 50%; animation: spin 0.7s linear infinite;
}
/* Nút dạng text (Tải lại / Tạo link mới) dùng vòng xoay màu cam */
.link-btn.is-loading::before { border-color: rgba(238,77,45,0.3); border-top-color: #ee4d2d; }
button:disabled { opacity: 0.6; cursor: not-allowed; }

/* Lớp phủ toàn trang khi đang tạo link */
.loading-overlay {
    position: fixed; inset: 0; z-index: 998; display: none;
    align-items: center; justify-content: center; flex-direction: column; gap: 14px;
    background: rgba(255,255,255,0.82); backdrop-filter: blur(2px);
}
.loading-overlay.show { display: flex; animation: fade-in 0.2s ease-out; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.loading-spinner {
    width: 42px; height: 42px; border: 4px solid #ffd9d0; border-top-color: #ee4d2d;
    border-radius: 50%; animation: spin 0.8s linear infinite;
}
.loading-text { font-size: 14px; color: #ee4d2d; font-weight: 600; }
.loading-hint { font-size: 12px; color: #999; }
