/*
 * HTML Book Module - Code Display & Examples
 * Styles for code blocks, examples, and live previews
 */

/* Code Example Container */
.examples-section {
    margin-top: 20px;
    margin-bottom: 20px;
}

.examples-section h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 15px;
}

.example-item {
    margin-bottom: 25px;
}

.example-item h5 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.example-description {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

/* Code Example Block */
.code-example {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 15px;
}

/* Code Tabs */
.code-tabs {
    display: flex;
    background-color: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    padding: 8px 10px;
    gap: 8px;
}

.code-tab {
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    background-color: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-speed);
    font-family: 'Sylfaen', 'Arial', sans-serif;
}

.code-tab:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.code-tab.active {
    background-color: var(--accent);
    color: white;
}

/* Copy Button in Tabs */
.btn-copy {
    margin-left: auto;
    padding: 6px 12px;
    font-size: 16px;
    background-color: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition-speed);
    color: var(--text-secondary);
}

.btn-copy:hover {
    background-color: var(--bg-secondary);
    transform: scale(1.1);
}

.btn-copy.copied {
    color: var(--success);
    transform: scale(1.2);
}

.btn-copy.copy-error {
    color: var(--error);
}

/* Code Content Area */
.code-content {
    display: none;
    padding: 15px;
    background-color: var(--bg-primary);
}

.code-content.active {
    display: block;
}

/* Pre and Code Styles */
.code-content pre {
    margin: 0;
    padding: 0;
    background-color: transparent;
    border: none;
}

.code-content code {
    display: block;
    padding: 0;
    background-color: transparent;
    color: var(--code-text);
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 13px;
    line-height: 1.6;
}

/* Live Preview */
.live-preview {
    min-height: 100px;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 10px;
}

.preview-iframe {
    width: 100%;
    min-height: 100px;
    border: none;
    background-color: white;
    display: block;
}

/* Attributes Section */
.attributes-section {
    margin-top: 20px;
    margin-bottom: 20px;
}

.attributes-section h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.attributes-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.attributes-table thead {
    background-color: var(--bg-tertiary);
}

.attributes-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
}

.attributes-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.attributes-table tbody tr:last-child td {
    border-bottom: none;
}

.attributes-table tbody tr:hover {
    background-color: var(--bg-secondary);
}

.attributes-table code {
    background-color: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
}

/* Best Practices */
.best-practices {
    margin-top: 20px;
    padding: 15px;
    background-color: rgba(40, 167, 69, 0.05);
    border-left: 4px solid var(--success);
    border-radius: 6px;
}

.best-practices h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--success);
    margin-bottom: 10px;
}

.best-practices ul {
    margin: 0;
    padding-left: 20px;
}

.best-practices li {
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 5px;
    line-height: 1.5;
}

/* Common Mistakes */
.common-mistakes {
    margin-top: 20px;
    padding: 15px;
    background-color: rgba(220, 53, 69, 0.05);
    border-left: 4px solid var(--error);
    border-radius: 6px;
}

.common-mistakes h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--error);
    margin-bottom: 10px;
}

.common-mistakes ul {
    margin: 0;
    padding-left: 20px;
}

.common-mistakes li {
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 5px;
    line-height: 1.5;
}

/* Related Tags */
.related-tags {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.related-tags h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
    margin-right: 8px;
    margin-bottom: 8px;
    display: inline-block;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
    margin-left: 8px;
    vertical-align: middle;
}

.badge-version {
    background-color: var(--accent);
    color: white;
}

.badge-type {
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

/* Browser Support Badges */
.browser-support {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.browser-badge {
    font-size: 11px;
    padding: 3px 8px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Tag Header */
.tag-header {
    margin-bottom: 15px;
}

/* Highlight Animation for Tags */
.tag-card.highlight {
    animation: highlightPulse 2s ease-out;
}

@keyframes highlightPulse {
    0% {
        background-color: var(--bg-primary);
        box-shadow: var(--shadow-sm);
    }
    50% {
        background-color: var(--accent-light);
        box-shadow: 0 0 0 4px var(--accent-light);
    }
    100% {
        background-color: var(--bg-primary);
        box-shadow: var(--shadow-sm);
    }
}

/* Table of Contents Sidebar */
.toc-sidebar h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}

#table-of-contents {
    font-size: 13px;
}

#table-of-contents a {
    display: block;
    padding: 6px 10px;
    color: var(--text-secondary);
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: all var(--transition-speed);
}

#table-of-contents a:hover {
    color: var(--accent);
    background-color: var(--bg-tertiary);
    border-left-color: var(--accent);
    padding-left: 15px;
}

#table-of-contents a.active {
    color: var(--accent);
    font-weight: 600;
    border-left-color: var(--accent);
}

/* Responsive Code Examples */
@media (max-width: 767px) {
    .code-content code {
        font-size: 12px;
    }

    .code-tabs {
        flex-wrap: wrap;
    }

    .btn-copy {
        margin-left: 0;
        width: 100%;
        margin-top: 5px;
    }

    .attributes-table {
        font-size: 12px;
    }

    .attributes-table th,
    .attributes-table td {
        padding: 8px;
    }
}
