/* CSS Variables */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-tertiary: #eeeeee;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --border-color: #e0e0e0;
    --accent-color: #2563eb;
    --accent-hover: #1d4ed8;
    --danger-color: #dc2626;
    --danger-hover: #b91c1c;
    --success-color: #16a34a;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Dark Mode */
body.dark-mode {
    --bg-primary: #1e1e1e;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3d3d3d;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --border-color: #404040;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.4);
}

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

html,
body {
    height: auto;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

body {
    overflow-x: hidden;
}

/* Landing Page */
.landing-hero {
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.landing-content {
    max-width: 1200px;
    width: 100%;
    text-align: center;
}

.landing-hero h1 {
    font-size: clamp(2rem, 5vw, 4rem);
    font-weight: 700;
    margin-bottom: 20px;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: fadeInDown 0.6s ease;
}

.landing-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 60px;
    line-height: 1.6;
    animation: fadeInUp 0.6s ease 0.1s both;
}

/* Features Grid */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    margin-bottom: 60px;
    animation: fadeInUp 0.6s ease 0.2s both;
}

.feature-card {
    padding: 30px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.feature-card:hover {
    border-color: var(--accent-color);
    box-shadow: var(--shadow-lg);
    transform: translateY(-5px);
}

.feature-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.feature-name {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.feature-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* CTA Button */
.cta-button {
    padding: 16px 48px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 50px;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.6s ease 0.3s both;
}

.cta-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.4);
}

.cta-button:active {
    transform: translateY(-1px);
}

.cta-subtitle {
    margin-top: 15px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    animation: fadeInUp 0.6s ease 0.4s both;
}

/* SEO Content (Hidden but for search engines) */
.seo-content {
    max-width: 900px;
    margin: 100px auto;
    padding: 40px;
    background-color: var(--bg-secondary);
    border-radius: 12px;
    line-height: 1.8;
}

.seo-content h2 {
    font-size: 2rem;
    margin: 40px 0 20px 0;
    color: var(--text-primary);
    font-weight: 700;
}

.seo-content h3 {
    font-size: 1.5rem;
    margin: 30px 0 15px 0;
    color: var(--accent-color);
    font-weight: 600;
}

.seo-content p {
    margin-bottom: 15px;
    color: var(--text-secondary);
    font-size: 1rem;
}

.seo-content ul {
    margin: 15px 0 15px 30px;
    color: var(--text-secondary);
}

.seo-content li {
    margin-bottom: 10px;
    line-height: 1.6;
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Container Layout */
.container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

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

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

.app-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

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

.icon-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: background-color 0.2s;
}

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

/* File Management */
.file-management {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    padding: 20px;
    gap: 15px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.section-header h2 {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin: 0;
}

.file-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-item {
    padding: 12px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    position: relative;
}

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

.file-item.active {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.file-item-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-item-date {
    font-size: 12px;
    opacity: 0.6;
    margin-top: 4px;
}

.sidebar-footer {
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
}

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

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    gap: 20px;
    flex-wrap: wrap;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
}

.file-name-input {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
}

.file-name-input:focus {
    border-color: var(--accent-color);
}

.auto-save-indicator {
    font-size: 12px;
    color: var(--success-color);
    font-weight: 500;
    white-space: nowrap;
}

.auto-save-indicator.saving {
    color: var(--accent-color);
}

.toolbar-right {
    display: flex;
    gap: 10px;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

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

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

.btn-primary:active {
    transform: scale(0.98);
}

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

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

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

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

.btn-danger:active {
    transform: scale(0.98);
}

.icon {
    font-size: 16px;
}

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

.editor-section,
.preview-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid var(--border-color);
}

.preview-section {
    border-right: none;
}

.section-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding: 10px 20px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

/* Editor */
.editor {
    flex: 1;
    padding: 20px;
    border: none;
    outline: none;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    line-height: 1.6;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    resize: none;
    overflow-y: auto;
}

.editor::placeholder {
    color: var(--text-secondary);
    opacity: 0.5;
}

/* Preview */
.preview {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: var(--bg-primary);
}

/* Markdown Styling */
.preview h1 {
    font-size: 2em;
    margin: 0.67em 0;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

.preview h2 {
    font-size: 1.5em;
    margin: 0.75em 0;
    font-weight: 600;
}

.preview h3 {
    font-size: 1.17em;
    margin: 0.83em 0;
    font-weight: 600;
}

.preview h4,
.preview h5,
.preview h6 {
    margin: 1em 0;
    font-weight: 600;
}

.preview p {
    margin: 1em 0;
    line-height: 1.6;
}

.preview a {
    color: var(--accent-color);
    text-decoration: none;
}

.preview a:hover {
    text-decoration: underline;
}

.preview code {
    background-color: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
    color: var(--accent-color);
}

.preview pre {
    background-color: var(--bg-secondary);
    padding: 15px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 1em 0;
    line-height: 1.4;
}

.preview pre code {
    background-color: transparent;
    padding: 0;
    color: var(--text-primary);
}

.preview blockquote {
    border-left: 4px solid var(--accent-color);
    margin: 1em 0;
    padding: 0.5em 15px;
    background-color: var(--bg-secondary);
    border-radius: 3px;
}

.preview ul,
.preview ol {
    margin: 1em 0;
    padding-left: 40px;
}

.preview li {
    margin: 0.5em 0;
}

.preview table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
}

.preview th,
.preview td {
    border: 1px solid var(--border-color);
    padding: 10px;
    text-align: left;
}

.preview th {
    background-color: var(--bg-secondary);
    font-weight: 600;
}

.preview hr {
    border: none;
    border-top: 2px solid var(--border-color);
    margin: 2em 0;
}

.preview img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--bg-primary);
    padding: 30px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    width: 90%;
    animation: slideIn 0.3s ease;
}

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

.modal-content h2 {
    margin-bottom: 20px;
    font-size: 20px;
}

.modal-content p {
    margin-bottom: 20px;
    color: var(--text-secondary);
}

.modal-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 20px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
}

.modal-input:focus {
    border-color: var(--accent-color);
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-buttons .btn {
    flex: 1;
    justify-content: center;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.empty-state-text {
    font-size: 16px;
    text-align: center;
}

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

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

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

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

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: 150px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .file-list {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .file-item {
        flex-shrink: 0;
        min-width: 150px;
    }

    .editor-container {
        flex-direction: column;
    }

    .editor-section,
    .preview-section {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .preview-section {
        border-bottom: none;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-left,
    .toolbar-right {
        width: 100%;
    }

    .toolbar-right {
        justify-content: space-between;
    }

    .btn {
        font-size: 13px;
        padding: 6px 12px;
    }
}

/* Search Bar */
.search-container {
    padding: 0 0 15px 0;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.search-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    outline: none;
    transition: all 0.2s;
}

.search-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-input::placeholder {
    color: var(--text-secondary);
}

/* File Tags in Sidebar */
.file-item-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.tag {
    display: inline-block;
    background-color: var(--accent-color);
    color: white;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 500;
}

.tag-more {
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
}

/* Command Palette */
.command-palette-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    justify-content: center;
    align-items: flex-start;
    padding-top: 100px;
    animation: fadeIn 0.2s ease;
}

.command-palette-modal.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.command-palette-input {
    width: 100%;
    max-width: 600px;
    padding: 16px 20px;
    border: none;
    outline: none;
    font-size: 16px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border-radius: 8px 8px 0 0;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.2);
}

.command-palette-list {
    max-width: 600px;
    max-height: 400px;
    background-color: var(--bg-primary);
    border-radius: 0 0 8px 8px;
    overflow-y: auto;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.2);
}

.command-palette-item {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s;
}

.command-palette-item.selected,
.command-palette-item:hover {
    background-color: var(--bg-secondary);
}

.command-name {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.command-description {
    font-size: 13px;
    color: var(--text-secondary);
}

.command-palette-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
}

/* Error Toast */
.error-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    background-color: var(--danger-color);
    color: white;
    border-radius: 6px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1500;
    max-width: 300px;
    word-wrap: break-word;
}

.error-toast.show {
    opacity: 1;
}

@media (max-width: 480px) {
    .sidebar {
        height: 120px;
    }

    .sidebar-header {
        padding: 15px;
    }

    .app-title {
        font-size: 16px;
    }

    .file-management {
        padding: 15px;
        gap: 10px;
    }

    .editor,
    .preview {
        padding: 15px;
    }

    .modal-content {
        padding: 20px;
    }

    .toolbar {
        padding: 12px 15px;
    }

    .command-palette-input {
        max-width: calc(100% - 20px);
    }

    .command-palette-list {
        max-width: calc(100% - 20px);
    }
}
