/* Global Styles */
:root {
    --dark-bg: #282a36;
    --dark-text: #f8f8f2;
    --dark-secondary: #2d2d2d;
    --dark-border: #6272a4;
    --dark-accent: #44475a;
    --dark-button: #6272a4;
    --dark-button-hover: #8be9fd;
    
    --light-bg: #f5f5f5;
    --light-text: #333;
    --light-secondary: #e5e5e5;
    --light-border: #ccc;
    --light-accent: #ddd;
    --light-button: #ddd;
    --light-button-hover: #0095ff;
    
    --editor-font-size: 14px;
    --spacing: 10px;
    --editor-height: 33.33%; /* Equal height for each editor section */
    
    /* Responsive view settings */
    --preview-width: 100%;
    --preview-height: 100%;
    --preview-orientation: landscape;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: background-color 0.3s, color 0.3s;
}

/* Theme Styles */
body.dark-mode {
    background-color: var(--dark-bg);
    color: var(--dark-text);
}

body.light-mode {
    background-color: var(--light-bg);
    color: var(--light-text);
}

/* Header Styles */
header {
    padding: var(--spacing);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid;
}

body.dark-mode header {
    border-color: var(--dark-border);
    background-color: var(--dark-secondary);
}

body.light-mode header {
    border-color: var(--light-border);
    background-color: var(--light-secondary);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: bold;
}

.controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

button, select {
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

body.dark-mode button, 
body.dark-mode select {
    background-color: var(--dark-secondary);
    color: var(--dark-text);
    border: 1px solid var(--dark-border);
}

body.light-mode button, 
body.light-mode select {
    background-color: var(--light-secondary);
    color: var(--light-text);
    border: 1px solid var(--light-border);
}

button:hover, select:hover {
    opacity: 0.9;
}

button:active, select:active {
    transform: scale(0.98);
}

.font-size-control {
    display: flex;
    gap: 4px;
}

/* Main Layout */
main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.main-container {
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    border-right: 1px solid var(--dark-border);
}

body.light-mode .editor-container {
    border-color: var(--light-border);
}

/* Tabs Styling */
.editor-tabs, .output-tabs {
    display: flex;
    border-bottom: 1px solid var(--dark-border);
    padding: 0 var(--spacing);
    background-color: var(--dark-secondary);
}

body.light-mode .editor-tabs, 
body.light-mode .output-tabs {
    border-color: var(--light-border);
    background-color: var(--light-secondary);
}

.tab-btn, .output-tab {
    padding: 10px 15px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-weight: bold;
    color: var(--dark-text);
}

body.light-mode .tab-btn,
body.light-mode .output-tab {
    color: var(--light-text);
}

.tab-btn.active, .output-tab.active {
    border-bottom-color: var(--dark-accent);
    opacity: 1;
}

body.light-mode .tab-btn.active,
body.light-mode .output-tab.active {
    border-color: var(--light-accent);
}

/* Editor Panels */
.editor-panel {
    display: none;
    flex: 1;
    overflow: hidden;
}

.editor-panel.active {
    display: flex;
    flex-direction: column;
}

#combined-editor .code-editor {
    height: 100%;
}

#separate-editors {
    display: none;
    flex-direction: column;
    height: 100%;
}

#separate-editors.active {
    display: flex;
}

.editor-section {
    height: var(--editor-height);
    min-height: var(--editor-height);
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid var(--dark-border);
    overflow: hidden;
}

body.light-mode .editor-section {
    border-color: var(--light-border);
}

.editor-section:last-child {
    border-bottom: none;
}

.editor-label {
    padding: 5px 10px;
    font-weight: bold;
    background-color: rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

body.light-mode .editor-label {
    background-color: rgba(0, 0, 0, 0.05);
}

.editor-actions {
    display: flex;
    gap: 5px;
}

.file-upload-btn, .file-export-btn, .file-copy-btn {
    padding: 4px 10px;
    font-size: 0.9rem;
    background-color: var(--dark-accent);
    color: white;
    border: none;
    border-radius: 4px;
    opacity: 0.9;
    transition: all 0.2s;
    margin-left: 5px;
}

.file-upload-btn:hover, .file-export-btn:hover, .file-copy-btn:hover {
    opacity: 1;
    transform: scale(1.05);
}

body.light-mode .file-upload-btn, 
body.light-mode .file-export-btn,
body.light-mode .file-copy-btn {
    background-color: var(--light-accent);
    color: var(--light-text);
}

.editor-toolbar {
    display: flex;
    gap: 5px;
    padding: 5px 10px;
    background-color: rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid var(--dark-border);
}

body.light-mode .editor-toolbar {
    background-color: rgba(0, 0, 0, 0.05);
    border-color: var(--light-border);
}

.combined-import-btn, .combined-export-btn, .combined-copy-btn {
    padding: 4px 10px;
    font-size: 0.9rem;
    background-color: var(--dark-accent);
    color: white;
    border: none;
    border-radius: 4px;
    opacity: 0.9;
    transition: all 0.2s;
}

.combined-import-btn:hover, .combined-export-btn:hover, .combined-copy-btn:hover {
    opacity: 1;
    transform: scale(1.05);
}

body.light-mode .combined-import-btn, 
body.light-mode .combined-export-btn,
body.light-mode .combined-copy-btn {
    background-color: var(--light-accent);
    color: var(--light-text);
}

/* Output Panel */
.output-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

.output-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    height: 100%;
}

/* Output Sections */
.output-section {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.output-section.active {
    display: block;
}

/* Preview Section */
#preview {
    background-color: white;
    position: relative;
    padding-top: 0;
}

body.dark-mode #preview {
    background-color: #333;
}

.preview-container {
    height: var(--preview-height);
    background-color: white;
    border-radius: 4px;
    overflow: hidden;
    min-height: 500px;
}

#preview-frame {
    width: 100%;
    height: 100%;
    border: none;
    background-color: white;
    min-height: 450px;
}

.preview-toolbar {
    display: flex;
    gap: 10px;
    padding: 5px 10px;
    background-color: rgba(0, 0, 0, 0.5);
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 100;
    border-radius: 5px;
    align-items: center;
}

.device-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.preview-toolbar button {
    padding: 4px 10px;
    font-size: 0.9rem;
    background-color: var(--dark-accent);
    color: white;
    border: none;
    border-radius: 4px;
    opacity: 0.9;
    transition: all 0.2s;
}

.preview-toolbar button:hover {
    opacity: 1;
    transform: scale(1.05);
}

body.light-mode .preview-toolbar {
    background-color: rgba(200, 200, 200, 0.5);
}

#preview-device-selector {
    padding: 3px 6px;
    border-radius: 4px;
    background-color: var(--dark-secondary);
    color: var(--dark-text);
    border: 1px solid var(--dark-border);
}

body.light-mode #preview-device-selector {
    background-color: var(--light-secondary);
    color: var(--light-text);
    border: 1px solid var(--light-border);
}

#device-selector {
    padding: 3px 6px;
    border-radius: 4px;
    background-color: var(--dark-secondary);
    color: var(--dark-text);
    border: 1px solid var(--dark-border);
}

body.light-mode #device-selector {
    background-color: var(--light-secondary);
    color: var(--light-text);
    border: 1px solid var(--light-border);
}

#toggle-orientation {
    padding: 3px 5px;
    background-color: var(--dark-secondary);
    border: 1px solid var(--dark-border);
    border-radius: 4px;
    color: var(--dark-text);
    cursor: pointer;
}

body.light-mode #toggle-orientation {
    background-color: var(--light-secondary);
    color: var(--light-text);
    border: 1px solid var(--light-border);
}

.orientation-portrait {
    transform: rotate(90deg);
    transform-origin: center center;
    transition: transform 0.3s ease;
}

/* Console Section */
#console-output {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--dark-secondary);
    color: var(--dark-text);
    z-index: 10;
    overflow: hidden;
    height: var(--preview-height);
    min-height: 500px;
}

#console-output.active {
    display: flex !important;
}

body.light-mode #console-output {
    background-color: var(--light-secondary);
    color: var(--light-text);
}

.console-control {
    padding: 8px 10px;
    border-bottom: 1px solid var(--dark-border);
    background-color: var(--dark-secondary);
    display: flex;
    justify-content: space-between;
}

body.light-mode .console-control {
    border-color: var(--light-border);
    background-color: var(--light-secondary);
}

#console-content {
    height: calc(var(--preview-height) - 35px);
    min-height: 450px;
    overflow-y: auto;
    padding: 8px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 14px;
    background-color: #1e1e1e;
    color: #f8f8f2;
}

body.light-mode #console-content {
    background-color: #f5f5f5;
    color: #333;
}

/* Console styles */
.console-output {
    background: var(--dark-bg);
    color: var(--light-text);
    font-family: monospace;
    height: 100%;
    overflow: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
}

.console-item {
    margin-bottom: 8px;
    padding: 6px 8px;
    border-radius: 4px;
    border-left: 3px solid transparent;
    line-height: 1.4;
    font-size: 14px;
    word-break: break-word;
}

.console-item.log {
    border-left-color: var(--accent-color);
    background-color: rgba(0, 0, 0, 0.15);
}

.console-item.info {
    border-left-color: #3498db;
    background-color: rgba(52, 152, 219, 0.1);
}

.console-item.warn {
    border-left-color: #f39c12;
    background-color: rgba(243, 156, 18, 0.1);
}

.console-item.error {
    border-left-color: #e74c3c;
    background-color: rgba(231, 76, 60, 0.1);
}

.console-timestamp {
    color: #777;
    margin-right: 8px;
    font-size: 0.8em;
}

.console-item pre {
    margin: 5px 0 0 0;
    white-space: pre-wrap;
}

/* Remove default badge styles */
.badge {
    display: none;
}

/* Keep only error badge styles */
.error-badge {
    background-color: #ff4444;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    margin-left: 8px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

/* Footer Styles */
footer {
    padding: 10px;
    text-align: center;
    font-size: 0.9rem;
    border-top: 1px solid var(--dark-border);
    background-color: var(--dark-secondary);
}

body.light-mode footer {
    border-color: var(--light-border);
    background-color: var(--light-secondary);
}

footer a {
    color: #8be9fd;
    text-decoration: none;
}

body.light-mode footer a {
    color: #0095ff;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    margin: 10% auto;
    padding: 20px;
    border-radius: 5px;
    width: 60%;
    max-width: 600px;
    background-color: var(--dark-secondary);
    border: 1px solid var(--dark-border);
}

body.light-mode .modal-content {
    background-color: var(--light-secondary);
    border: 1px solid var(--light-border);
}

.close {
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.modal h2 {
    margin-bottom: 15px;
}

.modal h3 {
    margin: 15px 0 10px 0;
}

.modal ul {
    margin-left: 20px;
}

/* CodeMirror Custom Styles */
.CodeMirror {
    height: 100%;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: var(--editor-font-size);
    line-height: 1.5;
}

body.dark-mode .CodeMirror {
    border-color: var(--dark-border);
}

body.light-mode .CodeMirror {
    border-color: var(--light-border);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-container {
        flex-direction: column;
    }
    
    .editor-container {
        border-right: none;
        border-bottom: 1px solid var(--dark-border);
    }
    
    body.light-mode .editor-container {
        border-color: var(--light-border);
    }
    
    .controls {
        flex-wrap: wrap;
    }
}

@media (max-width: 768px) {
    .controls button span {
        display: none;
    }
}

#preview {
    display: none;
}

#preview.active {
    display: block;
}

/* Orientation styles */
.preview-container.orientation-portrait {
    transform: rotate(90deg);
}

/* Ensure buttons are visible */
button {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    background-color: var(--accent-color);
    color: var(--text-light);
    border: none;
    border-radius: 4px;
    font-size: 14px;
    transition: background-color 0.2s;
}

button:hover {
    background-color: var(--accent-hover);
}

/* Mobile Responsive Styles - Comprehensive Fix */
@media screen and (max-width: 768px) {
    /* Global structure fixes */
    body {
        overflow: auto;
        height: auto;
        min-height: 100vh;
    }

    main {
        height: auto;
        min-height: calc(100vh - 150px);
        overflow: visible;
    }

    /* Header adjustments */
    header {
        padding: 8px;
        flex-wrap: wrap;
        gap: 10px;
    }

    .logo h1 {
        font-size: 1.2rem;
    }

    .controls {
        flex-wrap: wrap;
        gap: 8px;
    }

    button, select {
        padding: 5px 10px;
        font-size: 0.8rem;
    }

    /* Main container */
    .main-container {
        flex-direction: column;
        height: auto;
        min-height: 600px;
        overflow: visible;
        padding: 5px;
    }

    /* Editor container */
    .editor-container {
        flex: none;
        height: auto;
        min-height: 400px;
        border-right: none;
        border-bottom: 1px solid var(--dark-border);
        margin-bottom: 10px;
    }

    /* Tabs */
    .editor-tabs, .output-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding: 0 5px;
        -webkit-overflow-scrolling: touch;
    }

    .tab-btn, .output-tab {
        padding: 8px 10px;
        font-size: 0.8rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Editor panels */
    .editor-panel {
        height: auto;
        min-height: 350px;
    }

    #combined-editor {
        height: 350px;
        overflow: hidden;
    }

    #combined-editor .code-editor {
        height: 100%;
    }

    /* Separate editors */
    #separate-editors {
        height: auto;
        min-height: 350px;
    }

    .editor-section {
        flex: none;
        height: 200px;
        min-height: auto;
        max-height: none;
        margin-bottom: 10px;
    }

    .editor-section:last-child {
        margin-bottom: 0;
    }

    .editor-section .code-editor {
        height: calc(100% - 30px);
    }

    .editor-label {
        font-size: 0.9rem;
        padding: 5px 8px;
    }

    .editor-actions {
        display: flex;
        gap: 5px;
        overflow-x: auto;
        padding-bottom: 2px;
        -webkit-overflow-scrolling: touch;
    }

    .editor-actions button {
        padding: 3px 8px;
        font-size: 0.75rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* CodeMirror adjustments */
    .CodeMirror {
        height: 100%;
        font-size: 13px;
    }

    /* Output panel */
    .output-panel {
        flex: none;
        height: 350px;
        overflow: hidden;
    }

    .output-section {
        height: 100%;
    }

    /* Preview section */
    #preview {
        height: 100%;
        overflow: auto;
    }

    .preview-container {
        height: 100%;
        overflow: auto;
    }

    .preview-toolbar {
        top: 5px;
        right: 5px;
        padding: 3px 8px;
    }

    .preview-toolbar button {
        padding: 3px 6px;
        font-size: 0.75rem;
    }

    /* Console section */
    #console-output {
        height: 100%;
    }

    .console-control {
        padding: 5px;
    }

    #console-content {
        height: calc(100% - 35px);
        overflow-y: auto;
        padding: 8px;
        font-size: 13px;
    }

    /* Footer */
    footer {
        padding: 8px;
        font-size: 0.8rem;
    }
}

/* Smaller mobile screens */
@media screen and (max-width: 480px) {
    /* Header simplification */
    header {
        flex-direction: column;
        align-items: stretch;
        padding: 5px;
    }

    .logo {
        text-align: center;
        margin-bottom: 8px;
    }

    .controls {
        justify-content: center;
    }

    /* More compact sections */
    .editor-section {
        height: 180px;
    }

    .editor-label {
        font-size: 0.8rem;
    }

    .editor-actions button {
        padding: 2px 6px;
        font-size: 0.7rem;
    }

    /* Simpler layout for very small screens */
    .tab-btn, .output-tab {
        padding: 6px 8px;
        font-size: 0.75rem;
    }

    /* Button and control simplification */
    button, select {
        padding: 4px 8px;
        font-size: 0.75rem;
    }

    /* Adjust modal for mobile */
    .modal-content {
        width: 95%;
        margin: 5% auto;
        padding: 10px;
    }

    .modal h2 {
        font-size: 1.2rem;
    }

    .modal h3 {
        font-size: 1rem;
    }
}

/* Landscape mode for mobile */
@media screen and (max-width: 768px) and (orientation: landscape) {
    /* Better horizontal layout */
    .main-container {
        flex-direction: row;
        height: calc(100vh - 100px);
    }

    .editor-container,
    .output-panel {
        width: 50%;
        height: 100%;
    }

    .editor-container {
        border-right: 1px solid var(--dark-border);
        border-bottom: none;
        margin-bottom: 0;
        padding-right: 5px;
    }

    /* Adjust editor sections for landscape */
    .editor-section {
        height: 33.33%;
        max-height: 33.33%;
    }

    #combined-editor {
        height: 100%;
    }

    /* Tablet-sized landscape adjustments */
    .tab-btn, .output-tab {
        padding: 8px 12px;
    }

    .CodeMirror {
        font-size: 14px;
    }
}

.file-delete-btn, .combined-delete-btn {
    padding: 4px 10px;
    font-size: 0.9rem;
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    opacity: 0.9;
    transition: all 0.2s;
    margin-left: 5px;
}

.file-delete-btn:hover, .combined-delete-btn:hover {
    opacity: 1;
    transform: scale(1.05);
    background-color: #c0392b;
}

body.light-mode .file-delete-btn, 
body.light-mode .combined-delete-btn {
    background-color: #e74c3c;
    color: white;
}

/* Mobile styles for delete buttons */
@media screen and (max-width: 768px) {
    .file-delete-btn, .combined-delete-btn {
        padding: 3px 8px;
        font-size: 0.75rem;
    }
}

@media screen and (max-width: 480px) {
    .file-delete-btn, .combined-delete-btn {
        padding: 2px 6px;
        font-size: 0.7rem;
    }
}

/* App Conversion Modal Styles */
.app-settings {
    margin: 20px 0;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.form-group input[type="text"] {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-light);
    color: var(--text-dark);
}

.permissions-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 5px;
}

.permissions-list label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: normal;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.primary-btn {
    background-color: var(--accent-color);
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.primary-btn:hover {
    background-color: var(--accent-hover);
}

.secondary-btn {
    background-color: #666;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.secondary-btn:hover {
    background-color: #555;
}

/* Dark mode styles */
body.dark-mode .form-group input[type="text"] {
    background-color: var(--bg-dark);
    color: var(--text-light);
    border-color: #444;
}

body.dark-mode .permissions-list label {
    color: var(--text-light);
} 