/*
 * ZiOCloud Article Formatting
 * Restore code formatting from ZingServer.
 * Scoped to single blog posts.
 */

/* Inline code */
body.single-post .entry-content :not(pre) > code,
body.single-post .post-content :not(pre) > code,
body.single-post article :not(pre) > code {
    background-color: #FAE9DE;
    color: #BA5114;
    padding: 3px 7px;
    border-radius: 4px;
    font-family: Consolas, Monaco, monospace;
    font-size: 0.92em;
    overflow-wrap: anywhere;
}

/* Code blocks */
body.single-post .entry-content pre,
body.single-post .post-content pre,
body.single-post article pre {
    background: #f3f3f3;
    border: 1px solid #e1e1e1;
    padding: 20px;
    border-radius: 4px;
    overflow-x: auto;
    white-space: pre;
    line-height: 1.7;
    margin: 20px 0;
}

/* Code inside pre */
body.single-post .entry-content pre code,
body.single-post .post-content pre code,
body.single-post article pre code {
    display: block;
    background: #FAE9DE;
    color: #BA5114;
    padding: 15px;
    border-radius: 4px;
    font-family: Consolas, Monaco, monospace;
    font-size: 0.9em;
    white-space: pre;
    overflow-x: auto;
}

/* ===== ZiOCloud: Code formatting compatibility ===== */

/* Inline code */
body.single-post code:not(pre code) {
    background: #FAE9DE !important;
    color: #BA5114 !important;
    padding: 3px 7px !important;
    border-radius: 4px !important;
    font-family: Consolas, Monaco, monospace !important;
    font-size: 0.92em !important;
    overflow-wrap: anywhere;
}

/* Multi-line code container */
body.single-post pre {
    display: block !important;
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin: 20px 0 !important;
    padding: 18px !important;

    background: #FAE9DE !important;
    color: #BA5114 !important;
    border: 1px solid #ead5c7 !important;
    border-radius: 6px !important;

    overflow-x: auto !important;
    overflow-y: hidden;
    white-space: pre !important;
    overflow-wrap: normal !important;

    font-family: Consolas, Monaco, monospace !important;
    font-size: 14px !important;
    line-height: 1.7 !important;
}

/* Code inside pre */
body.single-post pre code {
    display: block !important;
    width: max-content !important;
    min-width: 100% !important;
    box-sizing: border-box !important;

    background: transparent !important;
    color: inherit !important;
    border: 0 !important;
    padding: 0 !important;

    font-family: inherit !important;
    font-size: inherit !important;
    line-height: inherit !important;

    white-space: pre !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
}

/* Prevent article code from overlapping sidebar */
body.single-post article,
body.single-post .entry-content,
body.single-post .post-content {
    min-width: 0;
}


/* ===== ZiOCloud: Click to Copy Code ===== */

body.single-post .ziocloud-copyable {
    cursor: copy !important;
    position: relative;
}

body.single-post .ziocloud-copyable:hover {
    filter: brightness(0.97);
}

body.single-post .ziocloud-copyable:focus-visible {
    outline: 2px solid #BA5114;
    outline-offset: 3px;
}

/* Thông báo copy thành công */
body.single-post .ziocloud-copied::after {
    content: "✓ Đã sao chép";
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;

    background: #198754;
    color: #fff;
    padding: 5px 10px;
    border-radius: 5px;

    font-family: Arial, sans-serif;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}

/* Inline code */
body.single-post code.ziocloud-copied::after {
    top: -34px;
    right: 0;
}

/* Code blocks */
body.single-post pre.ziocloud-copyable {
    transition: background-color 0.15s ease;
}
