/* HTML Previewer - Professional Code Sandbox */

/* Main Wrapper */
.html-previewer-wrapper {
    margin-bottom: 2rem;
}

/* Toolbar */
.previewer-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px 8px 0 0;
    gap: 12px;
    flex-wrap: wrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

[data-bs-theme="dark"] .previewer-toolbar {
    background: linear-gradient(135deg, #434190 0%, #5a3872 100%);
}

.toolbar-section {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 4px;
}

.previewer-toolbar .btn {
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
    font-weight: 500;
    transition: all 0.2s;
}

.previewer-toolbar .btn .fsvg {
    filter: brightness(0) invert(1);
}

.previewer-toolbar .btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
    color: white;
}

.previewer-toolbar .btn:hover .fsvg {
    filter: brightness(0) invert(1);
}

.previewer-toolbar .btn-success {
    background: rgba(25, 135, 84, 0.9);
    border-color: rgba(25, 135, 84, 0.9);
    color: white;
}

.previewer-toolbar .btn-success:hover {
    background: rgba(25, 135, 84, 1);
    border-color: rgba(25, 135, 84, 1);
    box-shadow: 0 4px 12px rgba(25, 135, 84, 0.4);
    color: white;
}

.previewer-toolbar .btn-outline-danger {
    color: #ff6b6b;
    border-color: rgba(255, 107, 107, 0.5);
}

.previewer-toolbar .btn-outline-danger .fsvg {
    filter: brightness(0) saturate(100%) invert(75%) sepia(47%) saturate(2447%) hue-rotate(316deg) brightness(103%) contrast(101%);
}

.previewer-toolbar .btn-outline-danger:hover {
    background: rgba(255, 107, 107, 0.2);
    border-color: #ff6b6b;
    color: #ff6b6b;
}

.previewer-toolbar .btn-outline-danger:hover .fsvg {
    filter: brightness(0) saturate(100%) invert(75%) sepia(47%) saturate(2447%) hue-rotate(316deg) brightness(103%) contrast(101%);
}

.previewer-toolbar .btn-group .btn.active {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    color: white;
}

.previewer-toolbar .btn-group .btn.active .fsvg {
    filter: brightness(0) invert(1);
}

.previewer-toolbar .form-check-label {
    color: #ffffff !important;
    font-size: 14px;
    font-weight: 600;
    margin-left: 6px;
    user-select: none;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    transition: all 0.2s;
}

.previewer-toolbar .form-check-label:hover {
    background: rgba(255, 255, 255, 0.15);
}

.previewer-toolbar .form-check-input {
    cursor: pointer;
}

/* Main Container */
.previewer-container {
    display: flex;
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-top: none;
    border-radius: 0 0 8px 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    min-height: 600px;
}

[data-bs-theme="dark"] .previewer-container {
    background: #1a1d23;
    border-color: #495057;
}

.previewer-container.layout-vertical {
    flex-direction: column;
}

.previewer-container.layout-horizontal {
    flex-direction: row;
}

/* Editor Side */
.previewer-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    border-right: 1px solid #dee2e6;
}

.previewer-container.layout-vertical .previewer-editor {
    border-right: none;
    border-bottom: 1px solid #dee2e6;
    max-height: 50%;
}

[data-bs-theme="dark"] .previewer-editor {
    border-color: #495057;
}

/* Output Side */
.previewer-output {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Tabs */
.previewer-tabs {
    background: #f8f9fa;
    border: none;
    border-bottom: 1px solid #dee2e6;
    margin: 0;
    padding: 0 8px;
    flex-shrink: 0;
}

[data-bs-theme="dark"] .previewer-tabs {
    background: #212529;
    border-bottom-color: #495057;
}

.previewer-tabs .nav-link {
    border: none;
    color: #6c757d;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    display: flex;
    align-items: center;
}

.previewer-tabs .nav-link:hover {
    color: #052c65;
    background: rgba(5, 44, 101, 0.05);
}

.previewer-tabs .nav-link.active {
    color: #052c65;
    background: transparent;
    border-bottom-color: #052c65;
}

[data-bs-theme="dark"] .previewer-tabs .nav-link {
    color: #9ca3af;
}

[data-bs-theme="dark"] .previewer-tabs .nav-link:hover {
    color: #6ea8fe;
    background: rgba(110, 168, 254, 0.1);
}

[data-bs-theme="dark"] .previewer-tabs .nav-link.active {
    color: #6ea8fe;
    border-bottom-color: #6ea8fe;
}

/* Console Badge */
.console-badge {
    display: inline-block;
    padding: 2px 6px;
    margin-left: 6px;
    background: #0d6efd;
    color: white;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
}

.console-badge-error {
    background: #dc3545;
    animation: pulse-error 2s infinite;
}

@keyframes pulse-error {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Editor Content */
.previewer-editor-content,
.previewer-output-content {
    flex: 1;
    overflow: hidden;
}

.previewer-editor-content .tab-pane,
.previewer-output-content .tab-pane {
    height: 100%;
}

/* Code Editor */
.code-editor {
    width: 100%;
    height: 100%;
    padding: 16px;
    border: none;
    outline: none;
    resize: none;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    background: #ffffff;
    color: #212529;
    tab-size: 4;
}

[data-bs-theme="dark"] .code-editor {
    background: #1e1e1e;
    color: #d4d4d4;
}

.code-editor::placeholder {
    color: #9ca3af;
    font-style: italic;
}

.code-editor:focus {
    outline: none;
    box-shadow: inset 0 0 0 1px rgba(5, 44, 101, 0.2);
}

[data-bs-theme="dark"] .code-editor:focus {
    box-shadow: inset 0 0 0 1px rgba(110, 168, 254, 0.3);
}

/* Preview Frame */
#previewFrame {
    width: 100%;
    height: 100%;
    border: none;
    background: #ffffff;
}

/* Console */
.console-header {
    padding: 8px 12px;
    background: #2d2d2d;
    border-bottom: 1px solid #1e1e1e;
    display: flex;
    justify-content: flex-end;
}

.console-header .btn {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    padding: 4px 10px;
}

.console-header .btn .fsvg {
    filter: brightness(0) invert(1);
    opacity: 0.8;
}

.console-header .btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
    color: white;
}

.console-header .btn:hover .fsvg {
    filter: brightness(0) invert(1);
    opacity: 1;
}

.console-output {
    height: calc(100% - 40px);
    overflow-y: auto;
    padding: 12px;
    background: #1e1e1e;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    color: #d4d4d4;
}

.console-empty {
    color: #6c757d;
    text-align: center;
    padding: 40px 20px;
    font-style: italic;
}

.console-message {
    display: flex;
    gap: 12px;
    padding: 6px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    align-items: flex-start;
    font-size: 13px;
}

.console-message:hover {
    background: rgba(255, 255, 255, 0.03);
}

.console-time {
    color: #858585;
    font-size: 11px;
    flex-shrink: 0;
    min-width: 65px;
}

.console-type {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    min-width: 50px;
}

.console-log .console-type {
    color: #4fc3f7;
}

.console-error .console-type {
    color: #ef5350;
}

.console-warn .console-type {
    color: #ffb74d;
}

.console-info .console-type {
    color: #9575cd;
}

.console-text {
    color: #d4d4d4;
    word-break: break-word;
    flex: 1;
    line-height: 1.5;
}

.console-error .console-text {
    color: #ef9a9a;
}

.console-warn .console-text {
    color: #ffb74d;
}

/* External Resources Modal */
.font-monospace {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace !important;
    font-size: 13px;
}

[data-bs-theme="dark"] .modal-content {
    background: #212529;
    color: #e9ecef;
}

[data-bs-theme="dark"] .modal-header {
    border-bottom-color: #495057;
}

[data-bs-theme="dark"] .modal-footer {
    border-top-color: #495057;
}

[data-bs-theme="dark"] .form-control {
    background: #1a1d23;
    border-color: #495057;
    color: #e9ecef;
}

[data-bs-theme="dark"] .form-control:focus {
    background: #1a1d23;
    border-color: #6ea8fe;
    color: #e9ecef;
}

[data-bs-theme="dark"] .form-text {
    color: #9ca3af;
}

/* Fullscreen Mode */
.html-previewer-wrapper:fullscreen {
    padding: 0;
}

.html-previewer-wrapper:fullscreen .previewer-container {
    height: calc(100vh - 60px);
    border-radius: 0;
    min-height: auto;
}

/* Responsive Design */
@media (max-width: 992px) {
    .previewer-container {
        flex-direction: column !important;
        min-height: 800px;
    }

    .previewer-editor {
        border-right: none !important;
        border-bottom: 1px solid #dee2e6;
        max-height: 400px;
    }

    [data-bs-theme="dark"] .previewer-editor {
        border-bottom-color: #495057;
    }

    .previewer-output {
        min-height: 400px;
    }

    .toolbar-section {
        width: 100%;
    }
}

@media (max-width: 576px) {
    .previewer-toolbar {
        padding: 8px 12px;
    }

    .previewer-toolbar .btn {
        font-size: 12px;
        padding: 4px 8px;
    }

    .toolbar-divider {
        display: none;
    }

    .code-editor {
        font-size: 12px;
        padding: 12px;
    }

    .console-output {
        font-size: 12px;
    }
}

/* Scrollbar Styling */
.code-editor::-webkit-scrollbar,
.console-output::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.code-editor::-webkit-scrollbar-track {
    background: #f1f1f1;
}

[data-bs-theme="dark"] .code-editor::-webkit-scrollbar-track {
    background: #2d2d2d;
}

.code-editor::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 5px;
}

.code-editor::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

[data-bs-theme="dark"] .code-editor::-webkit-scrollbar-thumb {
    background: #4a4a4a;
}

[data-bs-theme="dark"] .code-editor::-webkit-scrollbar-thumb:hover {
    background: #5a5a5a;
}

.console-output::-webkit-scrollbar-track {
    background: #1e1e1e;
}

.console-output::-webkit-scrollbar-thumb {
    background: #4a4a4a;
    border-radius: 5px;
}

.console-output::-webkit-scrollbar-thumb:hover {
    background: #5a5a5a;
}

/* Dropdown Menu */
.dropdown-menu {
    max-height: 300px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

[data-bs-theme="dark"] .dropdown-menu {
    background: #2b3035;
    border-color: #495057;
}

[data-bs-theme="dark"] .dropdown-item {
    color: #e9ecef;
}

[data-bs-theme="dark"] .dropdown-item:hover {
    background: #343a40;
    color: #fff;
}

/* Loading Animation */
.btn.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    top: 50%;
    left: 50%;
    margin-left: -7px;
    margin-top: -7px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Filter White for Icons */
.filter-white {
    filter: brightness(0) invert(1);
}

/* Utility */
.fsvg {
    display: inline-block;
    vertical-align: middle;
}
