/* Visual Card Share — modal styles, đồng bộ phong cách "peach glassmorphism" của Mèo Béo */
/* Modal người dùng chỉ hiển thị ẢNH do server render (không có preview text trực tiếp) nên
   không cần @font-face ở đây. Preview font ở admin form dùng /api/visual-card/fonts.css. */

.vc-trigger-btn {
    background: linear-gradient(135deg, #ffd6c8 0%, #ffbfae 100%);
    color: #5c4b47;
    border: none;
    border-radius: 18px;
    padding: 7px 14px;
    font-family: 'Quicksand', sans-serif;
    font-weight: 600;
    font-size: 0.8rem;
    line-height: 1.2;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(229, 152, 130, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.vc-trigger-btn:hover { transform: translateY(-1px); box-shadow: 0 5px 12px rgba(229, 152, 130, 0.4); }
.vc-trigger-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.vc-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(92, 75, 71, 0.55);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    z-index: 10000;
    display: flex; justify-content: center; align-items: center;
    opacity: 0; visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 16px;
    box-sizing: border-box;
}
.vc-overlay.active { opacity: 1; visibility: visible; }

.vc-modal {
    background: #fffcfb;
    width: 100%; max-width: 960px;
    max-height: 94vh; overflow-y: auto;
    border-radius: 24px;
    padding: 26px 28px 30px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.18);
    border: 2px solid #ffe6e0;
    position: relative;
    transform: translateY(20px);
    transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-family: 'Quicksand', sans-serif;
    color: #5c4b47;
}
.vc-overlay.active .vc-modal { transform: translateY(0); }

/* === LAYOUT 2 cột (desktop) / 1 cột (mobile, preview trước, controls sau) === */
.vc-layout {
    display: flex;
    flex-direction: column;
    gap: 18px;
}
@media (min-width: 760px) {
    .vc-layout {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
        gap: 28px;
        align-items: start;
    }
    /* Pin preview ở vế trái khi user cuộn controls bên phải */
    .vc-preview-side { position: sticky; top: 0; }
}

.vc-close {
    position: absolute; top: 12px; right: 14px;
    background: #fff5f2; border: 1px solid #fbc1b0; color: #d67d63;
    width: 38px; height: 38px; border-radius: 50%;
    font-size: 1.5rem; line-height: 1; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: 0.25s;
}
.vc-close:hover { background: #fbc1b0; color: #fff; transform: rotate(90deg); }

.vc-title { color: #d67d63; font-size: 1.45rem; margin: 0 30px 6px 0; font-weight: 800; }
.vc-subtitle { color: #8a7772; font-size: 0.92rem; line-height: 1.5; margin: 0 0 18px 0; }

.vc-section { margin-bottom: 18px; }
.vc-section-actions { text-align: center; margin: 20px 0 18px; }
.vc-label { display: block; font-weight: 700; color: #d67d63; font-size: 0.92rem; margin-bottom: 8px; }
.vc-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.vc-row-between { justify-content: space-between; margin-bottom: 6px; }
.vc-row-end { justify-content: flex-end; gap: 12px; margin-top: 6px; }
.vc-lang-row { margin-bottom: 10px; }
.vc-lang-select {
    border: 2px solid #ffe6e0; background: #fffaf9; color: #5c4b47;
    font-family: inherit; font-size: 0.85rem; font-weight: 600;
    padding: 6px 10px; border-radius: 10px; cursor: pointer; outline: none;
    transition: border-color 0.2s;
}
.vc-lang-select:focus { border-color: #fbc1b0; }

.vc-mood-badge {
    background: linear-gradient(135deg, #fff5f2, #ffe6e0);
    color: #b05c45;
    padding: 5px 12px; border-radius: 16px;
    border: 1px solid #fbc1b0;
    display: inline-flex; align-items: center; gap: 5px;
    line-height: 1.2;
}
.vc-mood-badge .vc-mood-label,
.vc-mood-badge .vc-mood-value {
    font-size: 0.82rem;
    font-family: 'Quicksand', sans-serif;
    line-height: 1.2;
}
.vc-mood-badge .vc-mood-label { font-weight: 500; }
.vc-mood-badge .vc-mood-value { font-weight: 700; }

.vc-textarea {
    width: 100%; box-sizing: border-box;
    padding: 12px 14px;
    border: 2px solid #ffe6e0; border-radius: 14px;
    font-family: inherit; font-size: 1rem;
    color: #5c4b47; background: #fffaf9;
    outline: none; resize: vertical;
    min-height: 70px; max-height: 160px;
    transition: border-color 0.25s, box-shadow 0.25s;
}
.vc-textarea:focus { border-color: #fbc1b0; box-shadow: 0 0 0 3px rgba(250, 208, 196, 0.35); background: #fff; }
.vc-textarea[disabled] { opacity: 0.7; background: #f9f6f5; }

/* Overlay loading phủ lên ô quote khi AI đang gen ⇒ làm rõ trạng thái đang chờ. */
.vc-quote-wrap { position: relative; }
.vc-quote-loading {
    position: absolute; inset: 0;
    display: none; align-items: center; justify-content: center; gap: 10px;
    border-radius: 14px;
    background: rgba(255, 250, 249, 0.9); backdrop-filter: blur(2px);
    color: #d67d63; font-weight: 700; font-size: 0.92rem;
}
.vc-quote-loading.active { display: flex; }
.vc-spinner-sm { width: 22px; height: 22px; border-width: 3px; }

.vc-char-count { color: #a8918b; font-size: 0.82rem; margin-right: auto; }

.vc-templates {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
    gap: 8px;
}
.vc-template-card {
    position: relative;
    border: 2px solid #ffe6e0; background: #fffaf9;
    border-radius: 10px; padding: 4px;
    cursor: pointer; transition: all 0.25s;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    text-align: center; font-size: 0.68rem; color: #5c4b47; font-weight: 600;
    overflow: hidden;
}
.vc-template-card:hover { transform: translateY(-2px); border-color: #fbc1b0; }
.vc-template-card.selected { border-color: #e59882; background: #fff5f2; box-shadow: 0 4px 12px rgba(229, 152, 130, 0.3); }
.vc-template-card img {
    width: 100%; aspect-ratio: 9 / 16; object-fit: cover;
    border-radius: 6px; background: #fff;
    pointer-events: none;
}
.vc-template-card .vc-template-label {
    line-height: 1.2;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
}
/* Template bị khoá theo gói: làm mờ ảnh + badge gói tối thiểu, bấm vào sẽ mời nâng cấp. */
.vc-template-card.locked { cursor: not-allowed; }
.vc-template-card.locked:hover { transform: none; border-color: #ffe6e0; }
.vc-template-card.locked img { filter: grayscale(0.65) brightness(0.82); }
.vc-template-card .vc-lock-badge {
    position: absolute; top: 5px; left: 5px; right: 5px;
    background: rgba(201, 168, 76, 0.95); color: #fff;
    font-size: 0.58rem; font-weight: 800; line-height: 1.15;
    padding: 3px 5px; border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    pointer-events: none;
}

.vc-btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 6px;
    font-family: 'Quicksand', sans-serif; font-weight: 700;
    border: none; cursor: pointer;
    padding: 12px 20px; border-radius: 24px;
    font-size: 0.95rem;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    text-decoration: none;
}
.vc-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.vc-btn-primary { background: linear-gradient(135deg, #fad0c4 0%, #fbc1b0 100%); color: #5c4b47; box-shadow: 0 6px 14px rgba(250, 208, 196, 0.55); }
.vc-btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 10px 20px rgba(250, 208, 196, 0.7); }
.vc-btn-outline { background: #fff; border: 2px solid #fbc1b0; color: #d67d63; }
.vc-btn-outline:hover:not(:disabled) { background: #fff5f2; }
.vc-btn-sm { padding: 8px 14px; font-size: 0.85rem; }

/* === PREVIEW SIDE === */
.vc-preview-side { animation: vcFadeIn 0.4s ease; }

.vc-preview-frame {
    position: relative;
    background: #fff5f2;
    border-radius: 16px;
    padding: 8px;
    /* max-width + max-height kết hợp aspect-ratio để frame luôn là box 9:16 LỚN NHẤT vừa cột & vừa vh */
    max-width: 100%;
    aspect-ratio: 9 / 16;
    max-height: 78vh;
    margin: 0 auto;
    display: flex; justify-content: center; align-items: center;
    overflow: hidden;
    box-shadow: 0 10px 28px rgba(250, 208, 196, 0.4);
}
.vc-preview-img {
    width: 100%; height: 100%;
    object-fit: contain;
    border-radius: 10px;
    display: block;
}
.vc-preview-img:not([src]), .vc-preview-img[src=""] { display: none; }

.vc-preview-spinner { display: flex; flex-direction: column; align-items: center; gap: 10px; color: #d67d63; font-weight: 600; }
.vc-spinner { width: 40px; height: 40px; border: 4px solid #fff5f2; border-top-color: #e59882; border-radius: 50%; animation: vcSpin 1s linear infinite; }

.vc-share-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 12px; }
.vc-share-actions .vc-btn-primary { min-width: 200px; }
.vc-error { background: #fff0ec; border: 1.5px dashed #d9534f; color: #b03b3b; padding: 10px 14px; border-radius: 12px; font-size: 0.9rem; margin-top: 14px; }

@keyframes vcSpin { 100% { transform: rotate(360deg); } }
@keyframes vcFadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* === MOBILE === */
@media (max-width: 759px) {
    .vc-overlay { padding: 8px; align-items: flex-start; padding-top: 16px; }
    .vc-modal { padding: 18px 16px 20px; border-radius: 18px; max-height: 96vh; }
    .vc-title { font-size: 1.2rem; margin-right: 36px; }
    .vc-subtitle { font-size: 0.85rem; margin-bottom: 14px; }
    /* Preview chiếm khoảng nửa màn hình, người dùng thấy ngay khi mở modal */
    .vc-preview-frame { aspect-ratio: 9 / 16; max-height: 56vh; }
    .vc-templates { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; }
    .vc-template-card { padding: 3px; font-size: 0.64rem; }
    .vc-btn { padding: 11px 16px; font-size: 0.9rem; }
    .vc-share-actions .vc-btn-primary { min-width: 0; width: 100%; }
    .vc-textarea { font-size: 0.95rem; min-height: 60px; }
    .vc-label { font-size: 0.85rem; }
}

/* === SMALL DESKTOP / TABLET 760-880 — co lại 1 chút === */
@media (min-width: 760px) and (max-width: 880px) {
    .vc-modal { max-width: 92vw; }
    .vc-preview-frame { max-height: 70vh; }
}
