/* CSS Variables */
:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    --border-color: #dee2e6;
    --font-family-mono: Consolas, Monaco, 'Courier New', monospace;
    --font-family-sans: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
}

/* Global Styles */
* {
    box-sizing: border-box;
}

html, body {
    height: 100vh;
    margin: 0;
    padding: 0;
    font-family: var(--font-family-sans);
    overflow: hidden;
}

body {
    display: flex;
    flex-direction: column;
}

/* Header Styles */
.navbar {
    flex-shrink: 0;
    min-height: 3.5rem;
}

.navbar-brand {
    font-size: 1.25rem;
}

/* Main Content */
main {
    flex: 1;
    overflow: hidden;
    padding: 0;
    display: flex;
    flex-direction: row;
    position: relative;
}

@media (max-width: 768px) {
    main {
        flex-direction: column;
    }
}

/* Editors Container */
.editors-container {
    width: 50%;
    flex: 0 0 50%;
    display: flex;
    flex-direction: column;
    min-width: 200px;
    max-width: 80%;
    background: #f8f9fa;
    border-right: 1px solid var(--border-color);
    transition: none;
}

/* Code Panel Options */
.code-panel-options .form-check-input {
    background-color: transparent;
    border-color: rgba(255, 255, 255, 0.5);
}

.code-panel-options .form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.code-panel-options .form-check-input:disabled {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    opacity: 0.7;
}

.code-panel-options .form-check-label {
    font-size: 0.875rem;
    user-select: none;
}

/* Editor Panel */
.editor-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid var(--border-color);
    min-width: 0;
    min-height: 200px;
}

.editor-panel:last-child {
    border-bottom: none;
}

.editor-header {
    flex-shrink: 0;
    min-height: 3rem;
    background-color: var(--light-color);
    border-bottom: 1px solid var(--border-color);
}

.editor-container {
    flex: 1;
    display: flex;
    position: relative;
    background-color: var(--editor-bg);
    overflow: hidden;
    min-height: 0;
}

/* Ace Editor Styles */
.ace-editor {
    width: 100%;
    height: 100%;
    font-family: var(--font-family-mono);
    font-size: 14px;
}

/* Resizer */
.resizer {
    width: 8px;
    min-width: 8px;
    background-color: #dee2e6;
    cursor: col-resize;
    flex-shrink: 0;
    user-select: none;
    position: relative;
    z-index: 100;
    transition: background-color 0.2s ease;
    touch-action: none;
}

.resizer:hover {
    background-color: #007bff;
}

.resizer:active {
    background-color: #0056b3;
}

/* Estado durante redimensionamento */
body.resizing {
    cursor: col-resize !important;
    user-select: none !important;
}

body.resizing * {
    cursor: col-resize !important;
    user-select: none !important;
}

/* Preview Panel */
.preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 200px;
}

.preview-header {
    flex-shrink: 0;
    min-height: 3rem;
    background-color: var(--light-color);
    border-bottom: 1px solid var(--border-color);
}

.view-mode-buttons .btn {
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    border: 1px solid #6c757d;
    background-color: #ffffff;
    color: #212529;
}

.view-mode-buttons .btn:hover {
    background-color: #e9ecef;
    border-color: #495057;
}

.view-mode-buttons .btn.active {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: #ffffff;
}

.view-mode-buttons .btn.active:hover {
    background-color: #0b5ed7;
    border-color: #0a58ca;
}

.view-mode-buttons .btn svg {
    display: block;
}

.preview-container {
    flex: 1;
    background-color: #e9ecef;
    position: relative;
    overflow: auto;
    min-height: 0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 1rem;
}

.preview-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background-color: white;
    transition: all 0.3s ease;
}

.preview-iframe.desktop-view {
    width: 100%;
    height: 100%;
    max-width: none;
    box-shadow: none;
}

.preview-iframe.mobile-view {
    width: 375px;
    height: 667px;
    max-width: 100%;
    border: 1px solid #333;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    background-color: white;
}

/* Status Bar */
.status-bar {
    flex-shrink: 0;
    min-height: 2.5rem;
    font-size: 0.75rem;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
}

/* Custom Scrollbar para Ace Editor */
.ace_scrollbar::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.ace_scrollbar::-webkit-scrollbar-track {
    background: #2d2d30;
}

.ace_scrollbar::-webkit-scrollbar-thumb {
    background: #424242;
    border-radius: 4px;
}

.ace_scrollbar::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Responsive Design */
@media (max-width: 768px) {
    main {
        flex-direction: column;
    }
    
    .editors-container {
        width: 100%;
        flex: 0 0 auto;
        max-width: none;
        min-width: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        order: 1;
    }
    
    .preview-panel {
        flex: 1;
        min-height: 300px;
        order: 2;
    }
    
    .resizer {
        display: none;
    }
    
    .editor-panel {
        min-height: 150px;
    }
    
    .navbar-brand span {
        display: none;
    }
    
    .code-panel-options {
        flex-wrap: wrap;
        gap: 0.5rem !important;
    }
    
    .editor-header {
        padding: 0.75rem;
    }
}

/* Transitions */
.btn, .form-select, .modal {
    transition: all 0.2s ease-in-out;
}

/* Focus States */
.btn:focus,
.form-select:focus {
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Hover Effects */
.btn:hover {
    transform: translateY(-1px);
}

.editor-header:hover,
.preview-header:hover {
    background-color: #e9ecef !important;
}