/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #e0e0e0;
    height: 100vh;
    overflow: hidden;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.app-header {
    background: rgba(25, 25, 35, 0.95);
    border-bottom: 1px solid #333;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    font-weight: bold;
    color: #6c63ff;
}

.logo i {
    font-size: 1.8rem;
}

.file-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#current-filename {
    font-weight: 500;
    font-size: 1.1rem;
}

#file-status {
    font-size: 0.85rem;
    padding: 2px 8px;
    border-radius: 10px;
    display: inline-block;
    width: fit-content;
}

.status-saved {
    background-color: rgba(76, 175, 80, 0.2);
    color: #4caf50;
}

.status-unsaved {
    background-color: rgba(244, 67, 54, 0.2);
    color: #f44336;
}

.controls-section {
    display: flex;
    gap: 12px;
}

/* Buttons */
.btn {
    background: #2d2d3d;
    color: #e0e0e0;
    border: 1px solid #444;
    padding: 10px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn:hover {
    background: #3a3a4a;
    border-color: #6c63ff;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: #6c63ff;
    border-color: #6c63ff;
}

.btn-primary:hover {
    background: #5a52d5;
}

.btn-success {
    background: #2e7d32;
    border-color: #2e7d32;
}

.btn-success:hover {
    background: #1b5e20;
}

.btn-warning {
    background: #ed6c02;
    border-color: #ed6c02;
}

.btn-warning:hover {
    background: #d45d00;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: rgba(30, 30, 40, 0.95);
    border-right: 1px solid #333;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-section {
    padding: 20px;
    border-bottom: 1px solid #333;
}

.sidebar-section:last-child {
    border-bottom: none;
}

.sidebar-section h3 {
    margin-bottom: 15px;
    color: #6c63ff;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
}

/* Metadata Form */
.metadata-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.9rem;
    color: #aaa;
}

.form-group input, 
.form-group select,
.form-group textarea {
    background: #252535;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 10px;
    color: #e0e0e0;
    font-size: 0.95rem;
}

.form-group textarea {
    resize: vertical;
    min-height: 60px;
    font-family: monospace;
}

/* File Manager */
.file-manager {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.file-actions {
    display: flex;
    gap: 8px;
}

.file-tree {
    background: #252535;
    border-radius: 6px;
    padding: 10px;
    max-height: 250px;
    overflow-y: auto;
}

.file-tree ul {
    list-style: none;
}

.file-tree li {
    padding: 8px 10px;
    margin: 2px 0;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.file-tree li:hover {
    background: #333345;
}

.file-tree li.active {
    background: #3a3a5a;
    border-left: 3px solid #6c63ff;
}

.file-tree .folder {
    color: #ffa726;
}

.file-tree .file {
    color: #42a5f5;
}

.file-tree .folder i,
.file-tree .file i {
    width: 20px;
    text-align: center;
}

/* Info Panel */
.info-panel {
    font-size: 0.9rem;
    line-height: 1.5;
}

.info-panel p {
    margin-bottom: 8px;
}

.info-panel strong {
    color: #6c63ff;
}

/* Editor Area */
.editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.editor-tabs {
    display: flex;
    background: rgba(25, 25, 35, 0.95);
    border-bottom: 1px solid #333;
    overflow-x: auto;
}

.tab {
    padding: 12px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    border-right: 1px solid #333;
    white-space: nowrap;
    transition: background 0.2s;
}

.tab:hover {
    background: #333345;
}

.tab.active {
    background: #252535;
    border-bottom: 2px solid #6c63ff;
}

.tab .close-tab {
    margin-left: 8px;
    opacity: 0.6;
    font-size: 0.9rem;
}

.tab .close-tab:hover {
    opacity: 1;
}

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

.editor-content {
    flex: 1;
    padding: 20px;
    overflow: auto;
}

.empty-editor {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #777;
}

.empty-editor-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    color: #444;
}

.empty-editor h3 {
    margin-bottom: 10px;
    color: #aaa;
}

.file-preview {
    width: 300px;
    border-left: 1px solid #333;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(20, 20, 30, 0.8);
}

#file-preview img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Code Editor */
.code-editor {
    width: 100%;
    height: 100%;
    background: #1e1e2e;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #444;
}

#code-textarea {
    width: 100%;
    height: 100%;
    min-height: 400px;
    background: #1e1e2e;
    color: #e0e0e0;
    border: none;
    padding: 20px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    outline: none;
}

/* Editor Status */
.editor-status {
    background: rgba(25, 25, 35, 0.95);
    border-top: 1px solid #333;
    padding: 10px 20px;
    display: flex;
    gap: 30px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #aaa;
}

.status-item i {
    color: #6c63ff;
}

/* Footer */
.app-footer {
    background: rgba(20, 20, 30, 0.95);
    border-top: 1px solid #333;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.footer-left {
    color: #777;
}

.footer-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

#status-message {
    color: #aaa;
}

/* Loader */
.loader {
    width: 18px;
    height: 18px;
    border: 2px solid #333;
    border-top: 2px solid #6c63ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #252535;
    border-radius: 8px;
    width: 500px;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    color: #e0e0e0;
}

.modal-close {
    background: none;
    border: none;
    color: #aaa;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.modal-body {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #333;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* File Type Selector */
.file-type-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.file-type-option {
    background: #2d2d3d;
    border: 2px solid #444;
    border-radius: 6px;
    padding: 15px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.file-type-option:hover {
    border-color: #6c63ff;
    background: #353545;
}

.file-type-option.selected {
    border-color: #6c63ff;
    background: #3a3a5a;
}

.file-type-option i {
    font-size: 2rem;
    color: #6c63ff;
}

.file-type-option span {
    font-size: 0.9rem;
    text-align: center;
}

/* Upload Area */
.upload-area {
    border: 2px dashed #444;
    border-radius: 8px;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 20px;
}

.upload-area:hover {
    border-color: #6c63ff;
    background: #2d2d3d;
}

.upload-area i {
    font-size: 3rem;
    color: #6c63ff;
}

.upload-area p {
    color: #aaa;
    text-align: center;
}

/* Preview Container */
.preview-container {
    margin-top: 15px;
    display: flex;
    justify-content: center;
}

#image-preview-container img {
    max-width: 200px;
    max-height: 150px;
    border-radius: 4px;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #1a1a2e;
}

::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 5px;
}

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

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        width: 280px;
    }
}

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        max-height: 40vh;
    }
    
    .editor-container {
        flex-direction: column;
    }
    
    .file-preview {
        width: 100%;
        height: 200px;
        border-left: none;
        border-top: 1px solid #333;
    }
}