/**
 * Code Hike-inspired Syntax Highlighter Styles
 * Beautiful, modern code block styling for Laravel Blog
 */

/* Code Block Wrapper - Force Dark Mode */
.code-block-wrapper {
    margin: 1.5rem 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    background: #1e1e1e !important;
    border: 1px solid #3a3a3a !important;
    transition: all 0.2s ease;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Source Code Pro', monospace;
}

.code-block-wrapper:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
}

/* Code Block Header */
.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: #2d2d2d !important;
    border-bottom: 1px solid #3a3a3a !important;
    font-size: 12px;
    font-weight: 500;
}

.code-language {
    color: #d4d4d4;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.08);
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 10px;
}

/* Copy Button */
.code-copy-btn {
    background: transparent;
    border: 1px solid #4d4d4d;
    color: #d4d4d4;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 500;
    font-family: inherit;
}

.code-copy-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: #5d5d5d;
    transform: translateY(-1px);
}

.code-copy-btn:active {
    transform: translateY(0);
}

.code-copy-btn.copied {
    background: #22c55e;
    border-color: #22c55e;
    color: #ffffff;
}

.code-copy-btn svg {
    transition: all 0.2s ease;
}

.code-copy-btn:hover svg {
    transform: scale(1.1);
}

/* Code Container */
.code-container {
    background: #1e1e1e !important;
    padding: 16px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.5;
    color: #d4d4d4 !important;
    position: relative;
}

/* Code Lines */
.code-line {
    padding: 1px 0;
    position: relative;
    white-space: pre;
    min-height: 1.4em;
    padding-left: 40px; /* Add left padding for line numbers */
}

.code-line:hover {
    background: rgba(255, 255, 255, 0.03);
}

.code-line::before {
    content: attr(data-line);
    position: absolute;
    left: 0;
    top: 1px;
    color: #6a6a6a;
    font-size: 11px;
    font-weight: 400;
    width: 30px;
    text-align: right;
    user-select: none;
    pointer-events: none;
}

/* Syntax Highlighting Colors - VS Code Dark Theme */
.code-comment {
    color: #6a9955 !important;
    font-style: italic;
}

.code-string {
    color: #ce9178 !important;
}

.code-keyword {
    color: #569cd6 !important;
    font-weight: 600;
}

.code-function {
    color: #dcdcaa !important;
}

.code-function-call {
    color: #dcdcaa !important;
    font-weight: 500;
}

.code-number {
    color: #b5cea8 !important;
}

.code-variable {
    color: #9cdcfe !important;
}

.code-tag {
    color: #569cd6 !important;
}

.code-unit {
    color: #4ec9b0 !important;
}

.code-operator {
    color: #d4d4d4 !important;
}

.code-punctuation {
    color: #d4d4d4 !important;
}

.code-class {
    color: #4ec9b0 !important;
}

/* Force Dark Mode - Override Light Theme */
@media (prefers-color-scheme: light) {
    .code-block-wrapper {
        background: #1e1e1e !important;
        border: 1px solid #3a3a3a !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
    }

    .code-block-wrapper:hover {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12) !important;
    }

    .code-block-header {
        background: #2d2d2d !important;
        border-bottom: 1px solid #3a3a3a !important;
    }

    .code-language {
        color: #d4d4d4 !important;
        background: rgba(255, 255, 255, 0.08) !important;
    }

    .code-copy-btn {
        border: 1px solid #4d4d4d !important;
        color: #d4d4d4 !important;
    }

    .code-copy-btn:hover {
        background: rgba(255, 255, 255, 0.08) !important;
        border-color: #5d5d5d !important;
    }

    .code-container {
        background: #1e1e1e !important;
        color: #d4d4d4 !important;
    }

    .code-line:hover {
        background: rgba(255, 255, 255, 0.03) !important;
    }

    .code-line::before {
        color: #6a6a6a !important;
    }

    /* Force Dark Theme Syntax Colors */
    .code-comment {
        color: #6a9955 !important;
    }

    .code-string {
        color: #ce9178 !important;
    }

    .code-keyword {
        color: #569cd6 !important;
    }

    .code-function {
        color: #dcdcaa !important;
    }

    .code-function-call {
        color: #dcdcaa !important;
    }

    .code-number {
        color: #b5cea8 !important;
    }

    .code-variable {
        color: #9cdcfe !important;
    }

    .code-tag {
        color: #569cd6 !important;
    }

    .code-unit {
        color: #4ec9b0 !important;
    }

    .code-operator {
        color: #d4d4d4 !important;
    }

    .code-punctuation {
        color: #d4d4d4 !important;
    }

    .code-class {
        color: #4ec9b0 !important;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .code-block-wrapper {
        margin: 1.5rem 0;
        border-radius: 8px;
    }

    .code-block-header {
        padding: 10px 16px;
        font-size: 12px;
    }

    .code-language {
        font-size: 10px;
        padding: 3px 6px;
    }

    .code-copy-btn {
        padding: 5px 10px;
        font-size: 11px;
    }

    .code-container {
        padding: 16px;
        font-size: 13px;
    }

    .code-line::before {
        left: -35px;
        width: 25px;
        font-size: 11px;
    }
}

/* Scrollbar Styling */
.code-container::-webkit-scrollbar {
    height: 8px;
}

.code-container::-webkit-scrollbar-track {
    background: #2d2d2d;
    border-radius: 4px;
}

.code-container::-webkit-scrollbar-thumb {
    background: #4d4d4d;
    border-radius: 4px;
}

.code-container::-webkit-scrollbar-thumb:hover {
    background: #6d6d6d;
}

/* Light theme scrollbar */
@media (prefers-color-scheme: light) {
    .code-container::-webkit-scrollbar-track {
        background: #f3f4f6;
    }

    .code-container::-webkit-scrollbar-thumb {
        background: #d1d5db;
    }

    .code-container::-webkit-scrollbar-thumb:hover {
        background: #9ca3af;
    }
}

/* Animation for copy success */
@keyframes copySuccess {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.code-copy-btn.copied {
    animation: copySuccess 0.3s ease;
}

/* Focus states for accessibility */
.code-copy-btn:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .code-block-wrapper {
        box-shadow: none;
        border: 1px solid #ccc;
        break-inside: avoid;
    }

    .code-copy-btn {
        display: none;
    }

    .code-container {
        background: #f9f9f9;
        color: #000;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .code-block-wrapper {
        border: 2px solid #000;
    }

    .code-block-header {
        background: #000;
        color: #fff;
    }

    .code-container {
        background: #fff;
        color: #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .code-block-wrapper,
    .code-copy-btn,
    .code-line {
        transition: none;
    }

    .code-copy-btn.copied {
        animation: none;
    }
}

/* Inline Code Styling */
.inline-code {
    background: rgba(0, 0, 0, 0.08);
    color: #d63384;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Source Code Pro', monospace;
    font-size: 0.85em;
    border: 1px solid rgba(0, 0, 0, 0.08);
    font-weight: 500;
}

@media (prefers-color-scheme: light) {
    .inline-code {
        background: rgba(255, 255, 255, 0.1) !important;
        color: #ff6b9d !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
    }
}

/* Blog content specific styling */
.blog-post-content .code-block-wrapper,
.blog-article .code-block-wrapper {
    margin: 2rem 0;
}

.blog-post-content pre,
.blog-article pre {
    margin: 0;
    padding: 0;
    background: none;
    border: none;
    border-radius: 0;
}

.blog-post-content code,
.blog-article code {
    background: none;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
}
