:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #252542;
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #6b6b80;
    --accent-primary: #667eea;
    --accent-secondary: #764ba2;
    --success: #4ade80;
    --warning: #fbbf24;
    --error: #f87171;
    --border-color: #3a3a5c;
    --sidebar-width: 300px;
    --header-height: 50px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.app-container {
    width: 100%;
    height: 100vh;
    position: relative;
}

/* Screen transitions */
.screen {
    display: none;
    width: 100%;
    height: 100%;
    animation: fadeIn 0.5s ease;
}

.screen.active {
    display: flex;
}

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

/* Start Screen */
#start-screen {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: radial-gradient(ellipse at top, var(--bg-secondary) 0%, var(--bg-primary) 100%);
}

.logo {
    text-align: center;
    margin-bottom: 3rem;
}

.logo h1 {
    font-size: 3rem;
    margin-top: 1rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-top: 0.5rem;
}

.input-group {
    width: 100%;
    max-width: 400px;
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.input-group input {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: var(--transition);
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-wrapper input {
    padding-right: 3rem;
}

.toggle-password-btn {
    position: absolute;
    right: 0.75rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.toggle-password-btn:hover {
    color: var(--text-primary);
}

.toggle-password-btn svg {
    width: 20px;
    height: 20px;
}

.button-group {
    display: flex;
    gap: 1rem;
    margin-bottom: 3rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

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

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

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

.btn-secondary:hover {
    background: var(--border-color);
    transform: translateY(-2px);
}

.btn-download {
    background: var(--secondary-gradient);
    color: white;
    width: 100%;
    justify-content: center;
    margin-bottom: 0.75rem;
}

.btn-download:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(245, 87, 108, 0.3);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-small:hover {
    background: var(--border-color);
}

.features {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    justify-content: center;
}

.feature {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
}

.feature svg {
    color: var(--accent-primary);
}

/* Workspace Screen */
#workspace-screen {
    flex-direction: row;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
}

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

.sidebar-header h3 {
    font-size: 1rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: var(--transition);
    flex-shrink: 0;
}

.icon-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.sidebar-stats {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
}

.stat-item {
    display: flex;
    gap: 0.5rem;
}

.stat-label {
    color: var(--text-muted);
}

.stat-value {
    color: var(--text-primary);
    font-weight: 600;
}

.stat-value.encrypted-count {
    color: var(--success);
}

.file-tree {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.file-tree-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    transition: var(--transition);
    user-select: none;
}

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

.file-tree-item.active {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
}

.file-tree-item .icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.file-tree-item.folder {
    font-weight: 500;
}

.file-tree-item.folder .folder-icon {
    transition: transform 0.2s ease;
}

.file-tree-item.folder.expanded .folder-icon {
    transform: rotate(90deg);
}

.file-tree-children {
    margin-left: 1.25rem;
    border-left: 1px solid var(--border-color);
    padding-left: 0.5rem;
}

.file-tree-children.collapsed {
    display: none;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.repo-link {
    display: block;
    text-align: center;
    color: var(--accent-primary);
    text-decoration: none;
    font-size: 0.875rem;
    padding: 0.5rem;
    border-radius: 4px;
    transition: var(--transition);
}

.repo-link:hover {
    background: var(--bg-tertiary);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

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

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

.file-path {
    color: var(--text-secondary);
    font-size: 0.875rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 400px;
}

.file-size {
    color: var(--text-muted);
    font-size: 0.75rem;
    background: var(--bg-tertiary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.editor-actions {
    display: flex;
    gap: 0.5rem;
}

.editor-container {
    flex: 1;
    position: relative;
    background: var(--bg-primary);
    overflow: hidden;
}

.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    gap: 1rem;
    padding: 2rem;
    text-align: center;
}

.welcome-message svg {
    opacity: 0.5;
}

.welcome-message .hint {
    font-size: 0.875rem;
    opacity: 0.7;
}

.file-editor {
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: none;
    padding: 1rem;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: none;
    outline: none;
}

.file-preview {
    width: 100%;
    height: 100%;
    padding: 2rem;
    overflow: auto;
    color: var(--text-primary);
}

.file-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.image-preview {
    width: 100%;
    height: 100%;
    border: none;
    background: var(--bg-primary);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 15, 26, 0.9);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loader {
    width: 50px;
    height: 50px;
    border: 3px solid var(--bg-tertiary);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

#loading-text {
    margin-top: 1rem;
    color: var(--text-secondary);
}

/* Scrollbar styling */
::-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);
}

/* Responsive design */
@media (max-width: 768px) {
    #workspace-screen {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: 40%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .button-group {
        flex-direction: column;
        width: 100%;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .features {
        gap: 1rem;
    }
}

/* Animations */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading-overlay.show {
    animation: fadeIn 0.3s ease;
}

/* File type colors */
.file-tree-item[data-type="js"] { color: #f7df1e; }
.file-tree-item[data-type="ts"] { color: #3178c6; }
.file-tree-item[data-type="py"] { color: #3776ab; }
.file-tree-item[data-type="html"] { color: #e34c26; }
.file-tree-item[data-type="css"] { color: #563d7c; }
.file-tree-item[data-type="json"] { color: #f7df1e; }
.file-tree-item[data-type="md"] { color: #083fa1; }
.file-tree-item[data-type="image"] { color: #10b981; }

/* Encrypted file indicator */
.file-tree-item.encrypted::after {
    content: '🔒';
    font-size: 0.75rem;
    margin-left: auto;
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
    z-index: 1001;
}

.toast.error {
    border-left: 4px solid var(--error);
}

.toast.success {
    border-left: 4px solid var(--success);
}

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