/**
 * GCC Typography Studio — Click-to-Edit UI  v1.6.1
 * Floating toolbar + hover states + preset badge
 *
 * v1.6.1 — Light theme thống nhất toàn hệ thống
 * Color tokens (đồng bộ với form buttons):
 *   var(--gcc-surface) — surfaces (toolbar, menu, button bg)
 *   var(--gcc-surface-1) / var(--gcc-surface-2) — hover surfaces
 *   var(--gcc-ink) — primary text + active state bg
 *   var(--gcc-ink-muted) — secondary text
 *   var(--gcc-line-strong-hover) — tertiary / icon labels
 *   var(--gcc-line) — borders default
 *   var(--gcc-line-light) — dividers
 *   var(--gcc-ink) — destructive only (reset / close hover)
 */

/* ============================================================================
   HOVER STATE — subtle text highlight, zero outline/border
   Khi hover: con trỏ pencil + text sáng nhẹ + underline mờ gợi ý click được.
   Khi selected: text đậm hơn + underline rõ hơn — không có viền nào cả.
   ============================================================================ */
.gcc-typo-hoverable {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23525252' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z'%3E%3C/path%3E%3C/svg%3E") 2 20, text !important;
    transition:
        opacity      0.15s ease,
        filter       0.15s ease,
        text-shadow  0.15s ease;
    outline: none !important;
    text-decoration: none;
}

.gcc-typo-hoverable:hover {
    opacity: 0.75 !important;
    filter: brightness(0.82) !important;
    text-decoration: underline !important;
    text-decoration-color: rgba(82, 82, 82, 0.35) !important;
    text-underline-offset: 4px !important;
    text-decoration-thickness: 1px !important;
    outline: none !important;
}

.gcc-typo-hoverable.gcc-typo-selected {
    opacity: 1 !important;
    filter: brightness(0.7) !important;
    text-decoration: underline !important;
    text-decoration-color: rgba(26, 26, 26, 0.6) !important;
    text-underline-offset: 4px !important;
    text-decoration-thickness: 1.5px !important;
    outline: none !important;
}

/* ============================================================================
   FLOATING TOOLBAR — Light theme, đồng bộ form buttons
   Tất cả children đều cao 30px + display flex để căn giữa tuyệt đối
   
   ⚠️ CRITICAL: Toolbar được inject vào trang có theme (Flatsome, WP block),
   các theme này thường ép font-size, font-family, padding, max-width lên
   input/select/button. Phải dùng !important + reset để giữ widget nguyên trạng.
   ============================================================================ */
.gcc-typo-toolbar {
    position: fixed !important;
    z-index: 999999;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 8px 12px !important;
    background: var(--gcc-surface) !important;
    border: 1px solid var(--gcc-line) !important;
    border-radius: 12px !important;
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.10),
        0 2px 6px rgba(0, 0, 0, 0.05) !important;
    white-space: nowrap !important;
    flex-wrap: nowrap !important;
    pointer-events: auto;
    opacity: 0;
    transform: translateY(4px) scale(0.98);
    transition: opacity 0.15s ease, transform 0.15s ease;
    box-sizing: border-box !important;
    line-height: 1 !important;
    /* Reset font inheritance từ theme — ép cỡ chữ + family chuẩn */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
    font-size: 13px !important;
    color: var(--gcc-ink) !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}

/* Force ALL descendants — không chỉ direct children — dùng font reset
   để text trong select option, button label đều đồng nhất */
.gcc-typo-toolbar,
.gcc-typo-toolbar * {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
    box-sizing: border-box !important;
}

/* Force tất cả con trực tiếp có chiều cao thống nhất 30px
   + chặn flex-grow để input không tự stretch
   + reset margin/padding/min-width có thể bị theme inject */
.gcc-typo-toolbar > * {
    height: 30px !important;
    max-height: 30px !important;
    margin: 0 !important;
    flex: 0 0 auto !important;
    min-width: 0 !important;
    max-width: none;
    vertical-align: middle !important;
}

.gcc-typo-toolbar.gcc-tb-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.gcc-typo-toolbar.gcc-hidden {
    display: none !important;
}

/* ── Caret arrow ── */
.gcc-typo-toolbar::before {
    content: '';
    position: absolute;
    left: var(--caret-x, 50%);
    transform: translateX(-50%);
    border: 7px solid transparent;
    pointer-events: none;
    height: auto; /* override the > * rule */
}

.gcc-typo-toolbar::after {
    content: '';
    position: absolute;
    left: var(--caret-x, 50%);
    transform: translateX(-50%);
    border: 8px solid transparent;
    pointer-events: none;
    z-index: -1;
    height: auto; /* override the > * rule */
}

.gcc-typo-toolbar.gcc-tb-above::before {
    bottom: -13px;
    border-top-color: var(--gcc-surface);
}
.gcc-typo-toolbar.gcc-tb-above::after {
    bottom: -16px;
    border-top-color: var(--gcc-line);
}

.gcc-typo-toolbar.gcc-tb-below::before {
    top: -13px;
    border-bottom-color: var(--gcc-surface);
}
.gcc-typo-toolbar.gcc-tb-below::after {
    top: -16px;
    border-bottom-color: var(--gcc-line);
}

/* ── Section label — inline-flex để text căn giữa theo chiều dọc ── */
.gcc-typo-toolbar .gcc-tb-label {
    display: inline-flex !important;
    align-items: center !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    color: var(--gcc-ink-muted) !important;
    letter-spacing: 0.06em !important;
    text-transform: uppercase !important;
    white-space: nowrap !important;
    padding-right: 2px !important;
    max-width: 80px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 1 !important;
}

/* ── Divider — height riêng, không lấy 30px ── */
.gcc-typo-toolbar .gcc-tb-divider {
    width: 1px !important;
    height: 20px !important;
    background: var(--gcc-line-light) !important;
    margin: 0 2px !important;
    align-self: center !important;
    padding: 0 !important;
    border: none !important;
}

/* ── Font select ── */
.gcc-typo-toolbar .gcc-tb-font {
    width: 155px !important;
    max-width: 155px !important;
    min-width: 115px !important;
    font-size: 12px !important;
    background: var(--gcc-surface) !important;
    color: var(--gcc-ink) !important;
    border: 1px solid var(--gcc-line) !important;
    border-radius: 6px !important;
    padding: 0 6px !important;
    cursor: pointer;
    line-height: 28px !important;
    text-transform: none !important;
    -webkit-appearance: menulist !important;
    appearance: menulist;
}

.gcc-tb-font:hover {
    border-color: var(--gcc-line-strong-hover);
}

.gcc-tb-font:focus {
    outline: none;
    border-color: var(--gcc-ink);
}

.gcc-tb-font option,
.gcc-tb-font optgroup {
    background: var(--gcc-surface);
    color: var(--gcc-ink);
}

/* ── Size input ── */
.gcc-typo-toolbar .gcc-tb-size {
    width: 50px !important;
    min-width: 50px !important;
    max-width: 50px !important;
    font-size: 12px !important;
    background: var(--gcc-surface) !important;
    color: var(--gcc-ink) !important;
    border: 1px solid var(--gcc-line) !important;
    border-radius: 6px !important;
    padding: 0 4px !important;
    text-align: center !important;
    line-height: 28px !important;
    -moz-appearance: textfield !important;
    -webkit-appearance: none !important;
    appearance: none;
}

/* Hide spinner buttons in Webkit/Blink */
.gcc-typo-toolbar .gcc-tb-size::-webkit-outer-spin-button,
.gcc-typo-toolbar .gcc-tb-size::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
}

.gcc-tb-size:hover {
    border-color: var(--gcc-line-strong-hover);
}

.gcc-tb-size:focus {
    outline: none;
    border-color: var(--gcc-ink);
}

.gcc-typo-toolbar .gcc-tb-unit {
    display: inline-flex !important;
    align-items: center !important;
    font-size: 10px !important;
    color: var(--gcc-line-strong-hover) !important;
    margin-left: -2px !important;
    line-height: 1 !important;
    padding: 0 !important;
}

/* ── Icon buttons (B, I, align) ── */
.gcc-typo-toolbar .gcc-tb-btn {
    width: 30px !important;
    min-width: 30px !important;
    max-width: 30px !important;
    padding: 0 !important;
    background: var(--gcc-surface) !important;
    color: var(--gcc-ink) !important;
    border: 1px solid var(--gcc-line) !important;
    border-radius: 6px !important;
    font-size: 12px !important;
    cursor: pointer;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
    line-height: 1 !important;
    text-transform: none !important;
}

.gcc-typo-toolbar .gcc-tb-btn:hover {
    background: var(--gcc-surface-2) !important;
    color: var(--gcc-ink-strong-hover) !important;
    border-color: var(--gcc-line-strong-hover) !important;
}

.gcc-typo-toolbar .gcc-tb-btn.active {
    background: var(--gcc-ink) !important;
    color: var(--gcc-surface) !important;
    border-color: var(--gcc-ink) !important;
}

.gcc-tb-bold   { font-weight: 900; font-style: normal; }
.gcc-tb-italic { font-style: italic; font-weight: 700; }

/* ── Color picker ── */
.gcc-typo-toolbar .gcc-tb-color {
    width: 30px !important;
    min-width: 30px !important;
    max-width: 30px !important;
    border: 1px solid var(--gcc-line) !important;
    border-radius: 6px !important;
    padding: 2px !important;
    cursor: pointer;
    background: var(--gcc-surface) !important;
}

.gcc-typo-toolbar .gcc-tb-color:hover {
    border-color: var(--gcc-line-strong-hover) !important;
}

.gcc-typo-toolbar .gcc-tb-color-reset {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 18px !important;
    min-width: 18px !important;
    max-width: 18px !important;
    font-size: 14px !important;
    color: var(--gcc-line-strong-hover) !important;
    background: none !important;
    border: none !important;
    cursor: pointer;
    padding: 0 !important;
    line-height: 1 !important;
    transition: color 0.12s;
}

.gcc-typo-toolbar .gcc-tb-color-reset:hover {
    color: var(--gcc-ink) !important;
}

/* ── Shared icon label (A↔ and ↕) ── */
.gcc-typo-toolbar .gcc-tb-icon-label {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 11px !important;
    color: var(--gcc-ink-muted) !important;
    line-height: 1 !important;
    padding: 0 2px !important;
}

/* WP tự động replace emoji ↕ ↔ thành <img class="emoji"> — chuẩn hóa size */
.gcc-typo-toolbar .gcc-tb-icon-label img.emoji,
.gcc-typo-toolbar img.emoji {
    width: 12px !important;
    height: 12px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    vertical-align: middle !important;
    display: inline-block !important;
}

/* ── Letter spacing slider ── */
.gcc-typo-toolbar .gcc-tb-spacing {
    width: 60px !important;
    min-width: 60px !important;
    max-width: 60px !important;
    accent-color: var(--gcc-ink);
    cursor: pointer;
    margin: 0 !important;
    padding: 0 !important;
    align-self: center;
    background: transparent !important;
    border: none !important;
}

.gcc-typo-toolbar .gcc-tb-spacing-val {
    display: inline-flex !important;
    align-items: center !important;
    font-size: 10px !important;
    color: var(--gcc-line-strong-hover) !important;
    min-width: 22px !important;
    width: 22px !important;
    text-align: left !important;
    line-height: 1 !important;
    padding: 0 !important;
}

/* ── Line height slider ── */
.gcc-typo-toolbar .gcc-tb-lh {
    width: 60px !important;
    min-width: 60px !important;
    max-width: 60px !important;
    accent-color: var(--gcc-ink);
    cursor: pointer;
    margin: 0 !important;
    padding: 0 !important;
    align-self: center;
    background: transparent !important;
    border: none !important;
}

.gcc-typo-toolbar .gcc-tb-lh-val {
    display: inline-flex !important;
    align-items: center !important;
    font-size: 10px !important;
    color: var(--gcc-line-strong-hover) !important;
    min-width: 30px !important;
    width: 30px !important;
    text-align: left !important;
    line-height: 1 !important;
    padding: 0 !important;
}

/* ── Close button — same 30px height for alignment ── */
.gcc-typo-toolbar .gcc-tb-close {
    width: 30px !important;
    min-width: 30px !important;
    max-width: 30px !important;
    padding: 0 !important;
    background: none !important;
    color: var(--gcc-line-strong-hover) !important;
    border: none !important;
    border-radius: 6px !important;
    font-size: 13px !important;
    cursor: pointer;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: color 0.12s, background 0.12s;
    margin-left: 2px !important;
    line-height: 1 !important;
}

.gcc-typo-toolbar .gcc-tb-close:hover {
    color: var(--gcc-ink) !important;
    background: var(--gcc-surface-2) !important;
}

/* ============================================================================
   PRESET BADGE — floats on the preview card, top-right corner
   Light style — đồng bộ HOÀN TOÀN với toolbar chính:
     • Heights = 30px
     • Padding panel = 8px 12px
     • Gap = 6px
     • Font 12px
     • Áp !important + specificity boost để chống theme override
   ============================================================================ */
.gcc-typo-preset-wrap {
    display: none;
    position: relative;
    z-index: 999;
    text-align: center;
    margin-bottom: 8px;
}

#gccWeddingPreview,
.gcc-col--preview {
    position: relative;
}

/* Reset font + box-model cho cả wrap (giống toolbar chính) */
.gcc-typo-preset-wrap,
.gcc-typo-preset-wrap * {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
    box-sizing: border-box !important;
}

/* ── Trigger badge "✨ Bộ cài sẵn" ── */
.gcc-typo-preset-wrap .gcc-typo-preset-trigger {
    display: inline-flex !important;
    align-items: center !important;
    gap: 5px !important;
    height: 30px !important;
    min-height: 30px !important;
    max-height: 30px !important;
    padding: 0 14px !important;
    margin: 0 !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    background: var(--gcc-surface) !important;
    color: var(--gcc-ink) !important;
    border: 1px solid var(--gcc-line) !important;
    border-radius: 99px !important;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
    white-space: nowrap !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06) !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}

.gcc-typo-preset-wrap .gcc-typo-preset-trigger:hover {
    background: var(--gcc-surface-1) !important;
    border-color: var(--gcc-ink) !important;
    color: var(--gcc-ink) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
}

/* ── Preset menu — xổ LÊN TRÊN trigger, căn giữa theo wrap ── */
.gcc-typo-preset-wrap .gcc-typo-preset-menu {
    position: absolute !important;
    bottom: calc(100% + 8px) !important;
    top: auto !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 8px 12px !important;
    margin: 0 !important;
    background: var(--gcc-surface) !important;
    border: 1px solid var(--gcc-line) !important;
    border-radius: 12px !important;
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.10),
        0 2px 6px rgba(0, 0, 0, 0.05) !important;
    white-space: nowrap !important;
    flex-wrap: nowrap !important;
    animation: gccPresetsIn 0.15s ease;
    line-height: 1 !important;
    font-size: 12px !important;
    color: var(--gcc-ink) !important;
}

/* Force tất cả children có cùng spec với toolbar chính */
.gcc-typo-preset-wrap .gcc-typo-preset-menu > * {
    height: 30px !important;
    max-height: 30px !important;
    margin: 0 !important;
    flex: 0 0 auto !important;
    min-width: 0 !important;
}

@keyframes gccPresetsIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.gcc-typo-preset-wrap .gcc-typo-preset-menu.gcc-hidden {
    display: none !important;
}

/* ── Pill buttons — đồng bộ HEIGHT 30px với toolbar chính ── */
.gcc-typo-preset-wrap .gcc-typo-pm-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 30px !important;
    min-height: 30px !important;
    max-height: 30px !important;
    padding: 0 14px !important;
    margin: 0 !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    line-height: 1 !important;
    color: var(--gcc-ink) !important;
    background: var(--gcc-surface) !important;
    border: 1px solid var(--gcc-line) !important;
    border-radius: 99px !important;
    cursor: pointer;
    white-space: nowrap !important;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
    vertical-align: middle !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}

.gcc-typo-preset-wrap .gcc-typo-pm-btn:hover {
    background: var(--gcc-surface-2) !important;
    color: var(--gcc-ink-strong-hover) !important;
    border-color: var(--gcc-line-strong-hover) !important;
}

.gcc-typo-preset-wrap .gcc-typo-pm-btn.active {
    color: var(--gcc-surface) !important;
    background: var(--gcc-ink) !important;
    border-color: var(--gcc-ink) !important;
    font-weight: 600 !important;
}

.gcc-typo-preset-wrap .gcc-typo-pm-btn.active::before {
    content: '✓';
    margin-right: 5px;
    font-size: 10px;
}

/* ── Reset button — viền đỏ nhạt, tách bằng divider dọc ── */
.gcc-typo-preset-wrap .gcc-typo-pm-btn.gcc-pm-reset {
    margin-left: 4px !important;
    padding-left: 14px !important;
    color: var(--gcc-ink) !important;
    background: var(--gcc-surface) !important;
    border-color: var(--gcc-line) !important;
    position: relative;
}

.gcc-typo-preset-wrap .gcc-typo-pm-btn.gcc-pm-reset::after {
    content: '';
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 20px;
    background: var(--gcc-line-light);
}

.gcc-typo-preset-wrap .gcc-typo-pm-btn.gcc-pm-reset:hover {
    background: var(--gcc-surface-2) !important;
    color: var(--gcc-ink) !important;
    border-color: var(--gcc-ink) !important;
}

.gcc-typo-preset-wrap .gcc-typo-pm-btn.gcc-pm-reset.active::before {
    content: ''; /* reset không hiển thị checkmark */
    margin: 0;
}

/* ============================================================================
   RESPONSIVE — mobile ≤900px: ẩn toolbar desktop, modal mobile thay thế
   ============================================================================ */
@media (max-width: 900px) {
    .gcc-typo-toolbar,
    .gcc-typo-toolbar.gcc-tb-visible {
        display: none !important;
    }
}

/* ============================================================================
   INLINE TEXT EDITOR — v1.0.0 (gcc-typography-inline-edit.js)
   Element nhận class `.gcc-inline-editing` khi đang ở EDIT MODE.
   Visual feedback: dashed cyan border + light highlight + cursor caret.
   ============================================================================ */
.gcc-inline-editing,
[contenteditable="true"][data-gcc-editing="1"] {
    outline: 2px dashed #06b6d4 !important;          /* cyan-500 */
    outline-offset: 4px;
    background: rgba(6, 182, 212, 0.06) !important;   /* very light cyan */
    border-radius: 4px;
    cursor: text !important;
    caret-color: #0891b2;                            /* cyan-600 */
    min-height: 1.2em;
    /* Bỏ pencil cursor hover khi đang edit */
    text-decoration: none !important;
}

/* Khi element đang edit, ẩn typography hover hint (đỡ rối) */
.gcc-inline-editing.gcc-typo-hoverable,
[data-gcc-editing="1"].gcc-typo-hoverable {
    cursor: text !important;
}

/* Nút Edit text trong toolbar */
.gcc-typo-toolbar .gcc-typo-edit-text-btn {
    color: #06b6d4;                                   /* cyan accent — khác các nút khác */
    font-weight: 600;
}
.gcc-typo-toolbar .gcc-typo-edit-text-btn:hover {
    background: rgba(6, 182, 212, 0.12) !important;
    color: #0891b2 !important;
}

/* Hint nhỏ ở hover (chỉ trên desktop, không phải khi đang edit) */
@media (min-width: 901px) {
    .gcc-typo-hoverable:not(.gcc-inline-editing):not([data-gcc-editing])::after {
        /* Không hiển thị thật, chỉ giữ chỗ cho tương lai nếu cần tooltip */
    }
}

/* Animation soft pulse khi enter edit mode */
@keyframes gcc-inline-edit-pulse {
    0%, 100% { outline-color: #06b6d4; }
    50%      { outline-color: #67e8f9; }
}
.gcc-inline-editing {
    animation: gcc-inline-edit-pulse 1.8s ease-in-out 1;
}