
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #3b82f6;
    --secondary-color: #1e293b;
    --accent-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --border-color: #334155;
    --border-radius: 8px;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --transition: all 0.2s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Header */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 4rem;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.tagline {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.status-indicators {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.online-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
}

.online-status.online {
    background: rgba(16, 185, 129, 0.2);
    color: var(--accent-color);
}

.online-status.offline {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error-color);
}

/* Main Content */
.main-content {
    min-height: calc(100vh - 4rem);
    position: relative;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    text-align: center;
}

.spinner {
    width: 3rem;
    height: 3rem;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error Message */
.error-message {
    position: fixed;
    top: 5rem;
    right: 1rem;
    background: var(--error-color);
    color: white;
    padding: 1rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    max-width: 400px;
    z-index: 1000;
    animation: slideInRight 0.3s ease;
}

.error-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    margin-left: auto;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* App Layout */
.app-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    height: calc(100vh - 4rem);
}

/* Sidebar */
.sidebar {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.create-file-form {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.files-list {
    flex: 1;
    overflow-y: auto;
}

.file-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    group: true;
}

.file-item:hover {
    background: var(--bg-tertiary);
}

.file-item.active {
    background: var(--bg-tertiary);
    border-left: 4px solid var(--primary-color);
}

.file-main {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.file-name {
    font-weight: 500;
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

.file-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: var(--transition);
}

.file-item:hover .file-actions {
    opacity: 1;
}

.file-action {
    padding: 0.25rem;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
    transition: var(--transition);
}

.file-action:hover {
    color: var(--text-primary);
    background: var(--bg-primary);
}

.file-action.danger:hover {
    color: var(--error-color);
}

.file-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

/* Editor Container */
.editor-container {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.editor-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.file-info h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.language-badge {
    padding: 0.25rem 0.75rem;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: var(--border-radius);
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.editor-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.editor-content {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.no-file-selected {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
}

.no-file-selected i {
    width: 4rem;
    height: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.code-editor {
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: none;
    outline: none;
    padding: 1.5rem;
    font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: none;
    tab-size: 2;
}

.code-preview {
    height: 100%;
    overflow: auto;
    padding: 1.5rem;
}

.code-preview pre {
    margin: 0;
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    overflow: auto;
}

.code-preview code {
    color: var(--text-primary) !important;
    font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    line-height: 1.6;
}

.editor-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--text-muted);
    flex-wrap: wrap;
    gap: 1rem;
}

.stats {
    display: flex;
    gap: 1rem;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #2563eb;
    transform: translateY(-1px);
}

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

.btn-secondary:hover:not(:disabled) {
    background: #475569;
    color: var(--text-primary);
}

.btn-danger {
    background: var(--error-color);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

/* Form Elements */
.form-input {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: var(--transition);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-input::placeholder {
    color: var(--text-muted);
}

/* Mobile Styles */
.mobile-file-selector {
    display: none;
}

@media (max-width: 768px) {
    .app-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
    
    .sidebar {
        display: none;
    }
    
    .mobile-file-selector {
        display: block;
        padding: 1rem;
        border-bottom: 1px solid var(--border-color);
        background: var(--bg-secondary);
    }
    
    .editor-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .editor-actions {
        justify-content: center;
    }
    
    .stats {
        flex-direction: column;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    .editor-actions {
        justify-content: stretch;
    }
    
    .btn {
        flex: 1;
        justify-content: center;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 5rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    color: white;
    font-weight: 500;
    box-shadow: var(--shadow);
    animation: slideInRight 0.3s ease;
    max-width: 300px;
}

.toast.success {
    background: var(--accent-color);
}

.toast.error {
    background: var(--error-color);
}

.toast.info {
    background: var(--primary-color);
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Prism.js Theme Overrides */
pre[class*="language-"] {
    background: var(--bg-secondary) !important;
    margin: 0;
}

code[class*="language-"] {
    color: var(--text-primary) !important;
    font-family: 'Fira Code', 'Consolas', 'Monaco', monospace !important;
}