/* ===== IMPROVED LAYOUT ===== */
.main-container {
    display: flex;
    height: calc(100vh - 80px);
    /* Reduced header impact */
}

/* ===== BETTER SIDEBAR PROPORTIONS ===== */
.sidebar {
    width: 250px;
    /* Reduced from 300px */
    min-width: 200px;
    /* Minimum width */
    max-width: 300px;
    /* Maximum width */
    background: white;
    border-right: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
    transition: width 0.3s ease;
    /* Smooth transitions */
}

/* ===== IMPROVED HEADER ===== */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: 80px;
    /* Fixed height */
}

.header h1 {
    font-size: 1.6rem;
    /* Slightly smaller */
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.header p {
    opacity: 0.9;
    margin-top: 0;
    font-size: 0.9rem;
}

/* ===== BETTER SIDEBAR CONTENT ===== */
.sidebar-header {
    padding: 0.75rem;
    /* Reduced padding */
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
}

.sidebar-header .btn {
    width: 100%;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    /* Smaller font */
    padding: 0.6rem 0.8rem;
    /* Smaller padding */
}

.file-list {
    flex: 1;
    padding: 0.5rem;
    /* Reduced padding */
    overflow-y: auto;
}

.file-item {
    padding: 0.6rem;
    /* Smaller padding */
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    margin-bottom: 0.4rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-name {
    font-weight: 500;
    margin-bottom: 0.2rem;
    font-size: 0.85rem;
    /* Smaller font */
    line-height: 1.2;
}

.file-date {
    font-size: 0.7rem;
    /* Smaller font */
    opacity: 0.7;
}

/* ===== IMPROVED EDITOR CONTAINER ===== */
.editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* Prevents flex overflow */
}

.editor-toolbar {
    padding: 0.75rem 1rem;
    /* Smaller padding */
    background: white;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    min-height: 60px;
    /* Fixed height */
}

.editor-toolbar h2 {
    color: #495057;
    font-size: 1.1rem;
    /* Smaller font */
    margin: 0;
    flex: 1;
    min-width: 200px;
}

/* ===== BETTER EDITOR CONTENT LAYOUT ===== */
.editor-content {
    flex: 1;
    display: flex;
    min-height: 0;
    /* Important for flex child */
}

.editor-pane,
.preview-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* Prevents overflow */
}

.editor-pane {
    border-right: 1px solid #e9ecef;
}

.pane-header {
    padding: 0.6rem 1rem;
    /* Smaller padding */
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
    font-size: 0.85rem;
    /* Smaller font */
    color: #495057;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 45px;
    /* Fixed height */
}

.markdown-editor {
    flex: 1;
    border: none;
    padding: 1.5rem;
    /* Better padding */
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    /* Slightly smaller */
    line-height: 1.6;
    /* Better line height */
    resize: none;
    outline: none;
    background: #fafafa;
}

.preview-content {
    flex: 1;
    padding: 1.5rem;
    /* Better padding */
    background: white;
    overflow-y: auto;
    font-size: 14px;
    /* Consistent font size */
    line-height: 1.6;
}

/* ===== IMPROVED STATUS BAR ===== */
.status-bar {
    padding: 0.4rem 1rem;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    font-size: 0.8rem;
    /* Smaller font */
    color: #6c757d;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 35px;
    /* Fixed height */
}

.word-count {
    display: flex;
    gap: 1rem;
}

/* ===== RESPONSIVE IMPROVEMENTS ===== */
@media (max-width: 1200px) {
    .sidebar {
        width: 220px;
    }
}

@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
        height: calc(100vh - 70px);
    }

    .header {
        padding: 0.75rem 1rem;
        min-height: 70px;
    }

    .header h1 {
        font-size: 1.4rem;
    }

    .sidebar {
        width: 100%;
        height: 150px;
        border-right: none;
        border-bottom: 1px solid #e9ecef;
    }

    .file-list {
        padding: 0.5rem;
    }

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

    .editor-pane,
    .preview-pane {
        border-right: none;
        border-bottom: 1px solid #e9ecef;
    }

    .editor-pane {
        min-height: 200px;
    }

    .preview-pane {
        min-height: 200px;
    }
}

/* ===== SIDEBAR TOGGLE (Optional Enhancement) ===== */
.sidebar-toggle {
    position: absolute;
    top: 50%;
    right: -15px;
    background: #667eea;
    color: white;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.sidebar.collapsed {
    width: 50px;
    min-width: 50px;
}

.sidebar.collapsed .sidebar-header,
.sidebar.collapsed .file-list {
    display: none;
}

/* ===== BETTER BUTTON STYLING ===== */
.toolbar-actions .btn {
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
}

.btn-small {
    padding: 0.4rem 0.6rem;
    font-size: 0.7rem;
}

/* ===== IMPROVED MODAL ===== */
.modal-content {
    min-width: 350px;
    max-width: 90vw;
}

/* ===== BETTER SCROLLBARS ===== */
.file-list::-webkit-scrollbar,
.preview-content::-webkit-scrollbar {
    width: 6px;
}

.file-list::-webkit-scrollbar-track,
.preview-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.file-list::-webkit-scrollbar-thumb,
.preview-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.file-list::-webkit-scrollbar-thumb:hover,
.preview-content::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* ===== IMPROVED MODAL STYLING ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    backdrop-filter: blur(2px);
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    min-width: 400px;
    max-width: 500px;
    width: 90%;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -60%);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.modal h3 {
    margin-bottom: 1.5rem;
    color: #2c3e50;
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal h3 i {
    color: #667eea;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: #495057;
    font-size: 0.95rem;
}

.form-control {
    width: 100%;
    padding: 1rem;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
    background: #fafafa;
}

.form-control:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    background: white;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #e9ecef;
}

.modal-actions .btn {
    min-width: 100px;
    font-weight: 600;
}

/* ===== BETTER DRAG OVERLAY ===== */
.drag-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(102, 126, 234, 0.1);
    border: 3px dashed #667eea;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1500;
    /* Lower than modal */
    font-size: 1.5rem;
    color: #667eea;
    font-weight: 600;
    backdrop-filter: blur(1px);
}

.drag-overlay.active {
    display: flex;
}

.drag-overlay div {
    background: rgba(255, 255, 255, 0.9);
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

/* ===== RESPONSIVE MODAL ===== */
@media (max-width: 768px) {
    .modal-content {
        min-width: 300px;
        width: 95%;
        padding: 1.5rem;
        margin: 1rem;
    }

    .modal h3 {
        font-size: 1.3rem;
    }

    .modal-actions {
        flex-direction: column;
    }

    .modal-actions .btn {
        width: 100%;
    }
}

/* ===== PREVENT MODAL/OVERLAY CONFLICTS ===== */
.modal.show {
    display: block;
}

.modal.show~.drag-overlay {
    display: none !important;
}

/* ===== BETTER EMPTY STATES ===== */
.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: #6c757d;
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.6;
    color: #667eea;
}

.empty-state p {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.empty-state p:first-of-type {
    font-weight: 600;
    color: #495057;
}